Skip to content

Commit 88b8326

Browse files
fix: getCode api method now has support for fetching the guest code
1 parent 7b20c8f commit 88b8326

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Default configuration:
7272
## API
7373

7474
```cs
75-
string GetCode(BasePlayer player);
75+
string GetCode(BasePlayer player, bool guest = false);
7676
void SetCode(BasePlayer player, string code, bool guest = false);
7777
void RemoveCode(BasePlayer player, bool guest = false);
7878
bool IsValidCode(string codeString);

src/AutoCode.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,15 @@ protected override void LoadDefaultMessages()
199199
/// Get the code for the given player.
200200
/// </summary>
201201
/// <param name="player">The player to get the code for.</param>
202+
/// <param name="guest">If true, the guest code will be returned instead of the main code.</param>
202203
/// <returns>A string of the player's code or null if the player doesn't have a code.</returns>
203-
public string GetCode(BasePlayer player)
204+
public string GetCode(BasePlayer player, bool guest = false)
204205
{
205206
if (data.Inst.playerSettings.ContainsKey(player.userID))
206207
{
207-
return data.Inst.playerSettings[player.userID].code;
208+
return guest
209+
? data.Inst.playerSettings[player.userID].guestCode
210+
: data.Inst.playerSettings[player.userID].code;
208211
}
209212

210213
return null;

0 commit comments

Comments
 (0)