Skip to content

Commit 9ba9747

Browse files
committed
Support GUID for future change
1 parent 585938d commit 9ba9747

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

CDK/CDKCommand.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,21 @@ private EKeyReemeResult RedeemCDK(UnturnedPlayer player, string CDK)
130130
}
131131
}
132132

133-
if (cdkdata.Vehicle.HasValue)
133+
if (ushort.TryParse(cdkdata.Vehicle, out ushort vehicleID))
134134
{
135-
player.GiveVehicle(cdkdata.Vehicle.Value);
135+
player.GiveVehicle(vehicleID);
136+
}
137+
else
138+
{
139+
try
140+
{
141+
var asset = Assets.find(Guid.Parse(cdkdata.Vehicle));
142+
VehicleTool.SpawnVehicleForPlayer(player.Player, asset);
143+
}
144+
catch (Exception e)
145+
{
146+
Logger.LogException(e);
147+
}
136148
}
137149

138150
if (cdkdata.Reputation.HasValue)

CDK/Data/CDKData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CDKData
1212
public string CDK { get; internal set; }
1313
public string Items { get; internal set; }
1414
public string Amount { get; internal set; }
15-
public ushort? Vehicle { get; internal set; }
15+
public string Vehicle { get; internal set; }
1616
public ushort? Experience { get; internal set; }
1717
public decimal? Money { get; internal set; }
1818
public int? Reputation { get; internal set; }
@@ -24,7 +24,7 @@ public class CDKData
2424
public ulong Owner { get; internal set; }
2525

2626
public bool UsePermissionSync { get; internal set; }
27-
public CDKData(string cdk, string items, string amount, ushort? vehicle, ushort? exp, decimal? money, int? reputation, string permissonGroup, int redeemedTimes, int maxredeem, DateTime validuntill, ulong steamID, bool renew, bool usePermissionSync)
27+
public CDKData(string cdk, string items, string amount, string vehicle, ushort? exp, decimal? money, int? reputation, string permissonGroup, int redeemedTimes, int maxredeem, DateTime validuntill, ulong steamID, bool renew, bool usePermissionSync)
2828
{
2929
CDK = cdk;
3030
Items = items;

CDK/DatabaseManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ private void CheckSchema() // intial mysql table
226226
Main.Instance.Configuration.Instance.MySQLTableVer = 5;
227227
Main.Instance.Configuration.Save();
228228
}
229+
230+
if(Main.Instance.Configuration.Instance.MySQLTableVer == 5)
231+
{
232+
ExecuteQuery(true,
233+
$"ALTER TABLE `{Main.Instance.Configuration.Instance.DatabaseCDKTableName}` MODIFY `Vehicle` VARCHAR(128)");
234+
Main.Instance.Configuration.Instance.MySQLTableVer++;
235+
Main.Instance.Configuration.Save();
236+
}
229237
}
230238

231239
private MySqlConnection CreateConnection()

CDK/lib/Assembly-CSharp.dll

300 KB
Binary file not shown.

0 commit comments

Comments
 (0)