mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-03-05 07:00:00 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb4340cc1d | ||
|
|
bbbf27a751 | ||
|
|
c9d8bb9b5f | ||
|
|
1109c0cf56 | ||
|
|
63869f4c94 | ||
|
|
fa284678e8 | ||
|
|
558f3178f2 | ||
|
|
c5f9cc6429 | ||
|
|
4087d3d016 | ||
|
|
e7919bb468 | ||
|
|
33bd83d0a1 | ||
|
|
73d989c0ce | ||
|
|
f1cecfc73e | ||
|
|
aae6f7e260 |
131
Commands.cs
131
Commands.cs
@@ -19,7 +19,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = player.UserId,
|
||||||
Index = (int)player.Index,
|
Index = (int)player.Index,
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = player?.SteamID.ToString(),
|
||||||
Name = player?.PlayerName,
|
Name = player?.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
@@ -107,44 +107,40 @@ namespace WeaponPaints
|
|||||||
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||||
|
|
||||||
var giveItemMenu = new ChatMenu(Localizer["wp_knife_menu_title"]);
|
var giveItemMenu = new ChatMenu(Localizer["wp_knife_menu_title"]);
|
||||||
var handleGive = (CCSPlayerController? player, ChatMenuOption option) =>
|
giveItemMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
var handleGive = (CCSPlayerController player, ChatMenuOption option) =>
|
||||||
{
|
{
|
||||||
if (Utility.IsPlayerValid(player))
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
|
var knifeName = option.Text;
|
||||||
|
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
||||||
|
if (!string.IsNullOrEmpty(knifeKey))
|
||||||
{
|
{
|
||||||
if (player == null) return;
|
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_select"]))
|
||||||
var knifeName = option.Text;
|
|
||||||
var knifeKey = knivesOnly.FirstOrDefault(x => x.Value == knifeName).Key;
|
|
||||||
if (!string.IsNullOrEmpty(knifeKey))
|
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_select"]))
|
player!.Print(Localizer["wp_knife_menu_select", knifeName]);
|
||||||
{
|
|
||||||
player!.Print(Localizer["wp_knife_menu_select", knifeName]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_kill"]) && Config.Additional.CommandKillEnabled)
|
|
||||||
{
|
|
||||||
player!.Print(Localizer["wp_knife_menu_kill"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
|
||||||
{
|
|
||||||
UserId = player.UserId,
|
|
||||||
Index = (int)player.Index,
|
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
|
||||||
Name = player?.PlayerName,
|
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
g_playersKnife[(int)player!.Index] = knifeKey;
|
|
||||||
|
|
||||||
if (player!.PawnIsAlive && g_bCommandsAllowed)
|
|
||||||
{
|
|
||||||
RefreshWeapons(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (weaponSync != null)
|
|
||||||
Task.Run(async () => await weaponSync.SyncKnifeToDatabase(playerInfo, knifeKey));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Localizer["wp_knife_menu_kill"]) && Config.Additional.CommandKillEnabled)
|
||||||
|
{
|
||||||
|
player!.Print(Localizer["wp_knife_menu_kill"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Index = (int)player.Index,
|
||||||
|
SteamId = player.SteamID.ToString(),
|
||||||
|
Name = player.PlayerName,
|
||||||
|
IpAddress = player.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
g_playersKnife[(int)player!.Index] = knifeKey;
|
||||||
|
|
||||||
|
if (g_bCommandsAllowed && (LifeState_t)player.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
|
RefreshKnife(player);
|
||||||
|
|
||||||
|
_ = weaponSync?.SyncKnifeToDatabase(playerInfo, knifeKey) ?? Task.CompletedTask;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
foreach (var knifePair in knivesOnly)
|
foreach (var knifePair in knivesOnly)
|
||||||
@@ -193,17 +189,16 @@ namespace WeaponPaints
|
|||||||
)?.ToList();
|
)?.ToList();
|
||||||
|
|
||||||
var skinSubMenu = new ChatMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
var skinSubMenu = new ChatMenu(Localizer["wp_skin_menu_skin_title", selectedWeapon]);
|
||||||
|
skinSubMenu.PostSelectAction = PostSelectAction.Close;
|
||||||
|
|
||||||
// Function to handle skin selection for the chosen weapon
|
// Function to handle skin selection for the chosen weapon
|
||||||
var handleSkinSelection = (CCSPlayerController? p, ChatMenuOption opt) =>
|
var handleSkinSelection = (CCSPlayerController p, ChatMenuOption opt) =>
|
||||||
{
|
{
|
||||||
if (p == null || !p.IsValid || p.Index <= 0) return;
|
if (!Utility.IsPlayerValid(p)) return;
|
||||||
|
|
||||||
playerIndex = (int)p.Index;
|
playerIndex = (int)p.Index;
|
||||||
|
|
||||||
if (p.AuthorizedSteamID == null) return;
|
string steamId = p.SteamID.ToString();
|
||||||
|
|
||||||
string steamId = p.AuthorizedSteamID.SteamId64.ToString();
|
|
||||||
var firstSkin = skinsList?.FirstOrDefault(skin =>
|
var firstSkin = skinsList?.FirstOrDefault(skin =>
|
||||||
{
|
{
|
||||||
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
|
if (skin != null && skin.TryGetValue("weapon_name", out var weaponName))
|
||||||
@@ -212,6 +207,7 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
string selectedSkin = opt.Text;
|
string selectedSkin = opt.Text;
|
||||||
string selectedPaintID = selectedSkin.Split('(')[1].Trim(')').Trim();
|
string selectedPaintID = selectedSkin.Split('(')[1].Trim(')').Trim();
|
||||||
|
|
||||||
@@ -221,7 +217,19 @@ namespace WeaponPaints
|
|||||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||||
int.TryParse(selectedPaintID, out var paintID))
|
int.TryParse(selectedPaintID, out var paintID))
|
||||||
{
|
{
|
||||||
p!.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
if (Config.Additional.ShowSkinImage && skinsList != null)
|
||||||
|
{
|
||||||
|
var foundSkin = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == paintID &&
|
||||||
|
skin?["image"] != null
|
||||||
|
);
|
||||||
|
string image = foundSkin?["image"]?.ToString() ?? "";
|
||||||
|
PlayerWeaponImage[p.Slot] = image;
|
||||||
|
AddTimer(2.0f, () => PlayerWeaponImage.Remove(p.Slot));
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
@@ -234,13 +242,16 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
UserId = p.UserId,
|
||||||
Index = (int)player.Index,
|
Index = (int)p.Index,
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = p.SteamID.ToString(),
|
||||||
Name = player?.PlayerName,
|
Name = p.PlayerName,
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
IpAddress = p.IpAddress?.Split(":")[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (g_bCommandsAllowed && (LifeState_t)p.LifeState == LifeState_t.LIFE_ALIVE)
|
||||||
|
RefreshWeapons(p);
|
||||||
|
|
||||||
if (!Config.GlobalShare)
|
if (!Config.GlobalShare)
|
||||||
{
|
{
|
||||||
if (weaponSync != null)
|
if (weaponSync != null)
|
||||||
@@ -280,23 +291,23 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
// Command to open the weapon selection menu for players
|
// Command to open the weapon selection menu for players
|
||||||
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
AddCommand($"css_{Config.Additional.CommandSkinSelection}", "Skins selection menu", (player, info) =>
|
||||||
{
|
{
|
||||||
if (!Utility.IsPlayerValid(player)) return;
|
if (!Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
if (player == null || player.UserId == null) return;
|
if (player == null || player.UserId == null) return;
|
||||||
|
|
||||||
if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) ||
|
if (!commandsCooldown.TryGetValue((int)player.UserId, out DateTime cooldownEndTime) ||
|
||||||
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
DateTime.UtcNow >= (commandsCooldown.TryGetValue((int)player.UserId, out cooldownEndTime) ? cooldownEndTime : DateTime.UtcNow))
|
||||||
{
|
{
|
||||||
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
commandsCooldown[(int)player.UserId] = DateTime.UtcNow.AddSeconds(Config.CmdRefreshCooldownSeconds);
|
||||||
MenuManager.OpenChatMenu(player, weaponSelectionMenu);
|
MenuManager.OpenChatMenu(player, weaponSelectionMenu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
if (!string.IsNullOrEmpty(Localizer["wp_command_cooldown"]))
|
||||||
{
|
{
|
||||||
player!.Print(Localizer["wp_command_cooldown"]);
|
player!.Print(Localizer["wp_command_cooldown"]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,8 +40,12 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
[JsonPropertyName("GiveRandomSkin")]
|
[JsonPropertyName("GiveRandomSkin")]
|
||||||
public bool GiveRandomSkin { get; set; } = false;
|
public bool GiveRandomSkin { get; set; } = false;
|
||||||
|
|
||||||
[JsonPropertyName("GiveKnifeAfterRemove")]
|
[JsonPropertyName("GiveKnifeAfterRemove")]
|
||||||
public bool GiveKnifeAfterRemove { get; set; } = false;
|
public bool GiveKnifeAfterRemove { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonPropertyName("ShowSkinImage")]
|
||||||
|
public bool ShowSkinImage { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WeaponPaintsConfig : BasePluginConfig
|
public class WeaponPaintsConfig : BasePluginConfig
|
||||||
@@ -78,5 +82,4 @@ namespace WeaponPaints
|
|||||||
[JsonPropertyName("Additional")]
|
[JsonPropertyName("Additional")]
|
||||||
public Additional Additional { get; set; } = new Additional();
|
public Additional Additional { get; set; } = new Additional();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
171
Events.cs
171
Events.cs
@@ -9,7 +9,8 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null || player.Connected == PlayerConnectedState.PlayerDisconnecting) return;
|
if (player is null || !player.IsValid || player.IsBot || player.IsHLTV || player.SteamID.ToString().Length != 17 ||
|
||||||
|
weaponSync == null || player.Connected == PlayerConnectedState.PlayerDisconnecting) return;
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
@@ -37,8 +38,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.UserId == null)
|
if (player is null || !player.IsValid || !player.UserId.HasValue || player.IsBot || player.IsHLTV || player.SteamID.ToString().Length != 17) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
if (Config.Additional.KnifeEnabled)
|
||||||
g_playersKnife.TryRemove((int)player.Index, out _);
|
g_playersKnife.TryRemove((int)player.Index, out _);
|
||||||
@@ -74,7 +74,8 @@ namespace WeaponPaints
|
|||||||
if (weapon.OwnerEntity.Value == null) return;
|
if (weapon.OwnerEntity.Value == null) return;
|
||||||
if (weapon.OwnerEntity.Index <= 0) return;
|
if (weapon.OwnerEntity.Index <= 0) return;
|
||||||
int weaponOwner = (int)weapon.OwnerEntity.Index;
|
int weaponOwner = (int)weapon.OwnerEntity.Index;
|
||||||
var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
|
CBasePlayerPawn? pawn = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)weaponOwner);
|
||||||
|
//var pawn = new CBasePlayerPawn(NativeAPI.GetEntityFromIndex(weaponOwner));
|
||||||
if (!pawn.IsValid) return;
|
if (!pawn.IsValid) return;
|
||||||
|
|
||||||
var playerIndex = (int)pawn.Controller.Index;
|
var playerIndex = (int)pawn.Controller.Index;
|
||||||
@@ -87,54 +88,12 @@ namespace WeaponPaints
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnEventItemPurchasePost(EventItemPurchase @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
|
||||||
|
|
||||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (Config.Additional.SkinVisibilityFix)
|
|
||||||
AddTimer(0.2f, () => RefreshSkins(player));
|
|
||||||
*/
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
private HookResult OnItemPickup(EventItemPickup @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
if (@event.Defindex == 42 || @event.Defindex == 59)
|
|
||||||
{
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
|
||||||
if (player == null || !player.IsValid || !g_knifePickupCount.ContainsKey((int)player.Index) || player.IsBot || !g_playersKnife.ContainsKey((int)player.Index))
|
|
||||||
return HookResult.Continue;
|
|
||||||
|
|
||||||
|
|
||||||
if (g_knifePickupCount[(int)player.Index] >= 2) return HookResult.Continue;
|
|
||||||
|
|
||||||
if (g_playersKnife.ContainsKey((int)player.Index)
|
|
||||||
&&
|
|
||||||
g_playersKnife[(int)player.Index] != "weapon_knife")
|
|
||||||
{
|
|
||||||
g_knifePickupCount[(int)player.Index]++;
|
|
||||||
|
|
||||||
RemovePlayerKnife(player, true);
|
|
||||||
|
|
||||||
if (!PlayerHasKnife(player) && Config.Additional.GiveKnifeAfterRemove)
|
|
||||||
AddTimer(0.3f, () => GiveKnifeToPlayer(player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
public HookResult OnPickup(CEntityIOOutput output, string name, CEntityInstance activator, CEntityInstance caller, CVariant value, float delay)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)activator.Index).OriginalController.Value;
|
CCSPlayerController? player = Utilities.GetEntityFromIndex<CCSPlayerPawn>((int)activator.Index).OriginalController.Value;
|
||||||
|
|
||||||
if (player == null || player.IsBot || player.IsHLTV ||
|
if (player == null || player.IsBot || player.IsHLTV ||
|
||||||
player.SteamID.ToString() == "" || !g_knifePickupCount.TryGetValue((int)player.Index, out var pickupCount) ||
|
player.SteamID.ToString().Length != 17 || !g_knifePickupCount.TryGetValue((int)player.Index, out var pickupCount) ||
|
||||||
!g_playersKnife.ContainsKey((int)player.Index))
|
!g_playersKnife.ContainsKey((int)player.Index))
|
||||||
{
|
{
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
@@ -156,10 +115,14 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
pickupCount++;
|
pickupCount++;
|
||||||
g_knifePickupCount[(int)player.Index] = pickupCount;
|
g_knifePickupCount[(int)player.Index] = pickupCount;
|
||||||
player.RemoveItemByDesignerName(weapon.DesignerName);
|
|
||||||
if (Config.Additional.GiveKnifeAfterRemove)
|
if (Config.Additional.GiveKnifeAfterRemove)
|
||||||
{
|
{
|
||||||
AddTimer(0.2f, () => GiveKnifeToPlayer(player));
|
AddTimer(0.37f, () =>
|
||||||
|
{
|
||||||
|
player.RemoveItemByDesignerName(weapon.DesignerName, true);
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,72 +147,14 @@ namespace WeaponPaints
|
|||||||
if (Config.GlobalShare)
|
if (Config.GlobalShare)
|
||||||
GlobalShareConnect();
|
GlobalShareConnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
g_hTimerCheckSkinsData = AddTimer(10.0f, () =>
|
|
||||||
{
|
|
||||||
List<CCSPlayerController> players = Utilities.GetPlayers();
|
|
||||||
|
|
||||||
foreach (CCSPlayerController player in players)
|
|
||||||
{
|
|
||||||
if (player.IsBot || player.IsHLTV || player.SteamID.ToString() == "") continue;
|
|
||||||
if (gPlayerWeaponsInfo.ContainsKey((int)player.Index)) continue;
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
|
||||||
{
|
|
||||||
UserId = player.UserId,
|
|
||||||
Index = (int)player.Index,
|
|
||||||
SteamId = player?.SteamID.ToString(),
|
|
||||||
Name = player?.PlayerName,
|
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
|
||||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
|
||||||
_ = weaponSync.GetKnifeFromDatabase(playerInfo);
|
|
||||||
}
|
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE | CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || weaponSync == null) return HookResult.Continue;
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
|
||||||
{
|
|
||||||
UserId = player.UserId,
|
|
||||||
Index = (int)player.Index,
|
|
||||||
SteamId = player?.SteamID.ToString(),
|
|
||||||
Name = player?.PlayerName,
|
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo.ContainsKey((int)player!.Index))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"[WeaponPaints] Retrying to retrieve player {player.PlayerName} skins");
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
if (Config.Additional.SkinEnabled)
|
|
||||||
await weaponSync.GetWeaponPaintsFromDatabase(playerInfo);
|
|
||||||
if (Config.Additional.KnifeEnabled)
|
|
||||||
await weaponSync.GetKnifeFromDatabase(playerInfo);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
if (player == null || !player.IsValid || !Config.Additional.KnifeEnabled || PlayerHasKnife(player))
|
|
||||||
{
|
if (player is null || !player.IsValid || !Config.Additional.KnifeEnabled)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
|
||||||
|
|
||||||
g_knifePickupCount[(int)player.Index] = 0;
|
g_knifePickupCount[(int)player.Index] = 0;
|
||||||
GiveKnifeToPlayer(player);
|
GiveKnifeToPlayer(player);
|
||||||
@@ -280,7 +185,16 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (player is null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
if (player is null || !player.IsValid || !player.PawnIsAlive || player.SteamID.ToString().Length != 17
|
||||||
|
|| player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Config.Additional.ShowSkinImage && PlayerWeaponImage.ContainsKey(player.Slot) && !string.IsNullOrEmpty(PlayerWeaponImage[player.Slot]))
|
||||||
|
{
|
||||||
|
player.PrintToCenterHtml("<img src='{PATH}'</img>".Replace("{PATH}", PlayerWeaponImage[player.Slot]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.PlayerPawn?.IsValid != true || player.PlayerPawn?.Value?.IsValid != true)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var viewModels = GetPlayerViewModels(player);
|
var viewModels = GetPlayerViewModels(player);
|
||||||
@@ -292,7 +206,7 @@ namespace WeaponPaints
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var weapon = viewModel.Value.Weapon.Value;
|
var weapon = viewModel.Value.Weapon.Value;
|
||||||
if (weapon == null || !weapon.IsValid)
|
if (weapon == null || !weapon.IsValid || weapon.FallbackPaintKit == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (viewModel.Value.VMName.Contains("knife"))
|
if (viewModel.Value.VMName.Contains("knife"))
|
||||||
@@ -306,8 +220,8 @@ namespace WeaponPaints
|
|||||||
if (skeleton == null)
|
if (skeleton == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int[] knifePaintKits = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
if (knifePaintKits.Contains(weapon.FallbackPaintKit))
|
if (newPaints.Contains(weapon.FallbackPaintKit))
|
||||||
{
|
{
|
||||||
skeleton.ModelState.MeshGroupMask = 1;
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
}
|
}
|
||||||
@@ -323,7 +237,6 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// Handle exceptions silently
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,37 +249,13 @@ namespace WeaponPaints
|
|||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
RegisterListener<Listeners.OnTick>(OnTick);
|
RegisterListener<Listeners.OnTick>(OnTick);
|
||||||
|
|
||||||
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnectFull);
|
|
||||||
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
RegisterEventHandler<EventPlayerSpawn>(OnPlayerSpawn);
|
||||||
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
RegisterEventHandler<EventRoundStart>(OnRoundStart, HookMode.Pre);
|
||||||
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
RegisterEventHandler<EventRoundEnd>(OnRoundEnd);
|
||||||
//RegisterEventHandler<EventItemPurchase>(OnEventItemPurchasePost);
|
|
||||||
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
//RegisterEventHandler<EventItemPickup>(OnItemPickup);
|
||||||
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup, HookMode.Pre);
|
|
||||||
|
HookEntityOutput("weapon_knife", "OnPlayerPickup", OnPickup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* WORKAROUND FOR CLIENTS WITHOUT STEAMID ON AUTHORIZATION */
|
|
||||||
/*private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
CCSPlayerController? player = @event.Userid;
|
|
||||||
|
|
||||||
if (player == null || !player.IsValid || !player.EntityIndex.HasValue || player.IsHLTV) return HookResult.Continue;
|
|
||||||
|
|
||||||
int playerIndex = (int)player.EntityIndex.Value.Value;
|
|
||||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
|
||||||
_ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex);
|
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
|
||||||
_ = weaponSync.GetKnifeFromDatabase(playerIndex);
|
|
||||||
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
if (Config.Additional.SkinEnabled && weaponSync != null)
|
|
||||||
if (Config.Additional.KnifeEnabled && weaponSync != null)
|
|
||||||
});
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,4 +8,4 @@
|
|||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public string? IpAddress { get; set; }
|
public string? IpAddress { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
24
SchemaString.cs
Normal file
24
SchemaString.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using CounterStrikeSharp.API;
|
||||||
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WeaponPaints;
|
||||||
|
|
||||||
|
public class SchemaString<TSchemaClass> : NativeObject where TSchemaClass : NativeObject
|
||||||
|
{
|
||||||
|
internal SchemaString(TSchemaClass instance, string member) : base(Schema.GetSchemaValue<nint>(instance.Handle, typeof(TSchemaClass).Name!, member))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
internal unsafe void Set(string str)
|
||||||
|
{
|
||||||
|
var bytes = Encoding.UTF8.GetBytes(str);
|
||||||
|
|
||||||
|
for (var i = 0; i < bytes.Length; i++)
|
||||||
|
{
|
||||||
|
Unsafe.Write((void*)(Handle.ToInt64() + i), bytes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Unsafe.Write((void*)(Handle.ToInt64() + bytes.Length), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
42
Utility.cs
42
Utility.cs
@@ -29,22 +29,38 @@ namespace WeaponPaints
|
|||||||
return builder.ConnectionString;
|
return builder.ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async void CheckDatabaseTables()
|
internal static async Task CheckDatabaseTables()
|
||||||
{
|
{
|
||||||
|
if (WeaponPaints._database is null) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new MySqlConnection(BuildDatabaseConnectionString());
|
await using var connection = await WeaponPaints._database.GetConnectionAsync();
|
||||||
await connection.OpenAsync();
|
|
||||||
|
|
||||||
using var transaction = await connection.BeginTransactionAsync();
|
await using var transaction = await connection.BeginTransactionAsync();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string createTable1 = "CREATE TABLE IF NOT EXISTS `wp_player_skins` (`steamid` varchar(64) NOT NULL, `weapon_defindex` int(6) NOT NULL, `weapon_paint_id` int(6) NOT NULL, `weapon_wear` float NOT NULL DEFAULT 0.000001, `weapon_seed` int(16) NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci";
|
string[] createTableQueries = new[]
|
||||||
string createTable2 = "CREATE TABLE IF NOT EXISTS `wp_player_knife` (`steamid` varchar(64) NOT NULL, `knife` varchar(64) NOT NULL, UNIQUE (`steamid`)) ENGINE = InnoDB";
|
{
|
||||||
|
@"CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
||||||
|
`steamid` varchar(64) NOT NULL,
|
||||||
|
`weapon_defindex` int(6) NOT NULL,
|
||||||
|
`weapon_paint_id` int(6) NOT NULL,
|
||||||
|
`weapon_wear` float NOT NULL DEFAULT 0.000001,
|
||||||
|
`weapon_seed` int(16) NOT NULL DEFAULT 0
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci",
|
||||||
|
@"CREATE TABLE IF NOT EXISTS `wp_player_knife` (
|
||||||
|
`steamid` varchar(64) NOT NULL,
|
||||||
|
`knife` varchar(64) NOT NULL,
|
||||||
|
UNIQUE (`steamid`)
|
||||||
|
) ENGINE = InnoDB"
|
||||||
|
};
|
||||||
|
|
||||||
await connection.ExecuteAsync(createTable1, transaction: transaction);
|
foreach (var query in createTableQueries)
|
||||||
await connection.ExecuteAsync(createTable2, transaction: transaction);
|
{
|
||||||
|
await connection.ExecuteAsync(query, transaction: transaction);
|
||||||
|
}
|
||||||
|
|
||||||
await transaction.CommitAsync();
|
await transaction.CommitAsync();
|
||||||
}
|
}
|
||||||
@@ -56,14 +72,18 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exception("[WeaponPaints] Unknown mysql exception! " + ex.Message);
|
throw new Exception("[WeaponPaints] Unknown MySQL exception! " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsPlayerValid(CCSPlayerController? player)
|
internal static bool IsPlayerValid(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
return (player != null && player.IsValid && !player.IsBot && !player.IsHLTV && player.AuthorizedSteamID != null);
|
if (player is null) return false;
|
||||||
|
|
||||||
|
return (player is not null && player.IsValid && !player.IsBot && !player.IsHLTV
|
||||||
|
&& WeaponPaints.weaponSync != null && player.Connected == PlayerConnectedState.PlayerConnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void LoadSkinsFromFile(string filePath)
|
internal static void LoadSkinsFromFile(string filePath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -168,6 +188,7 @@ namespace WeaponPaints
|
|||||||
Console.WriteLine(" ");
|
Console.WriteLine(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*(
|
||||||
internal static void TestDatabaseConnection()
|
internal static void TestDatabaseConnection()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -186,5 +207,6 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
CheckDatabaseTables();
|
CheckDatabaseTables();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
286
WeaponAction.cs
286
WeaponAction.cs
@@ -11,7 +11,7 @@ namespace WeaponPaints
|
|||||||
{
|
{
|
||||||
internal static void ChangeWeaponAttributes(CBasePlayerWeapon? weapon, CCSPlayerController? player, bool isKnife = false)
|
internal static void ChangeWeaponAttributes(CBasePlayerWeapon? weapon, CCSPlayerController? player, bool isKnife = false)
|
||||||
{
|
{
|
||||||
if (player == null || weapon == null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
|
if (player is null || weapon is null || !weapon.IsValid || !Utility.IsPlayerValid(player)) return;
|
||||||
|
|
||||||
int playerIndex = (int)player.Index;
|
int playerIndex = (int)player.Index;
|
||||||
|
|
||||||
@@ -26,6 +26,8 @@ namespace WeaponPaints
|
|||||||
weapon.AttributeManager.Item.EntityQuality = 3;
|
weapon.AttributeManager.Item.EntityQuality = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
if (_config.Additional.GiveRandomSkin &&
|
if (_config.Additional.GiveRandomSkin &&
|
||||||
!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
@@ -36,13 +38,29 @@ namespace WeaponPaints
|
|||||||
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
weapon.FallbackPaintKit = GetRandomPaint(weaponDefIndex);
|
||||||
weapon.FallbackSeed = 0;
|
weapon.FallbackSeed = 0;
|
||||||
weapon.FallbackWear = 0.000001f;
|
weapon.FallbackWear = 0.000001f;
|
||||||
|
|
||||||
|
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
|
if (fallbackPaintKit == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var foundSkin = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||||
|
skin?["paint_name"] != null
|
||||||
|
);
|
||||||
|
|
||||||
|
string skinName = foundSkin?["paint_name"]?.ToString() ?? "";
|
||||||
|
if (!string.IsNullOrEmpty(skinName))
|
||||||
|
new SchemaString<CEconItemView>(weapon.AttributeManager.Item, "m_szCustomName").Set(skinName);
|
||||||
|
|
||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
{
|
{
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
|
|
||||||
int[] array = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
int fallbackPaintKit = weapon.FallbackPaintKit;
|
|
||||||
if (array.Contains(fallbackPaintKit))
|
if (newPaints.Contains(fallbackPaintKit))
|
||||||
{
|
{
|
||||||
skeleton.ModelState.MeshGroupMask = 1;
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
}
|
}
|
||||||
@@ -54,6 +72,17 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewModels = GetPlayerViewModels(player);
|
||||||
|
if (viewModels == null || viewModels.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var viewModel = viewModels[0];
|
||||||
|
if (viewModel == null || viewModel.Value == null || viewModel.Value.Weapon == null || viewModel.Value.Weapon.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utilities.SetStateChanged(viewModel.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +96,26 @@ namespace WeaponPaints
|
|||||||
weapon.FallbackSeed = weaponInfo.Seed;
|
weapon.FallbackSeed = weaponInfo.Seed;
|
||||||
weapon.FallbackWear = weaponInfo.Wear;
|
weapon.FallbackWear = weaponInfo.Wear;
|
||||||
|
|
||||||
|
fallbackPaintKit = weapon.FallbackPaintKit;
|
||||||
|
|
||||||
|
if (fallbackPaintKit == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var foundSkin1 = skinsList.FirstOrDefault(skin =>
|
||||||
|
((int?)skin?["weapon_defindex"] ?? 0) == weaponDefIndex &&
|
||||||
|
((int?)skin?["paint"] ?? 0) == fallbackPaintKit &&
|
||||||
|
skin?["paint_name"] != null
|
||||||
|
);
|
||||||
|
|
||||||
|
var skinName1 = foundSkin1?["paint_name"]?.ToString() ?? "";
|
||||||
|
if (!string.IsNullOrEmpty(skinName1))
|
||||||
|
new SchemaString<CEconItemView>(weapon.AttributeManager.Item, "m_szCustomName").Set(skinName1);
|
||||||
|
|
||||||
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
if (!isKnife && weapon.CBodyComponent != null && weapon.CBodyComponent.SceneNode != null)
|
||||||
{
|
{
|
||||||
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
var skeleton = GetSkeletonInstance(weapon.CBodyComponent.SceneNode);
|
||||||
int[] array = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
int[] newPaints = { 1171, 1170, 1169, 1164, 1162, 1161, 1159, 1175, 1174, 1167, 1165, 1168, 1163, 1160, 1166, 1173 };
|
||||||
int fallbackPaintKit = weapon.FallbackPaintKit;
|
if (newPaints.Contains(fallbackPaintKit))
|
||||||
if (array.Contains(fallbackPaintKit))
|
|
||||||
{
|
{
|
||||||
skeleton.ModelState.MeshGroupMask = 1;
|
skeleton.ModelState.MeshGroupMask = 1;
|
||||||
}
|
}
|
||||||
@@ -84,6 +127,16 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var viewModels1 = GetPlayerViewModels(player);
|
||||||
|
if (viewModels1 == null || viewModels1.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var viewModel1 = viewModels1[0];
|
||||||
|
if (viewModel1 == null || viewModel1.Value == null || viewModel1.Value.Weapon == null || viewModel1.Value.Weapon.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utilities.SetStateChanged(viewModel1.Value, "CBaseEntity", "m_CBodyComponent");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
internal static void GiveKnifeToPlayer(CCSPlayerController? player)
|
||||||
@@ -144,78 +197,9 @@ namespace WeaponPaints
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RefreshPlayerKnife(CCSPlayerController? player)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
|
|
||||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
|
|
||||||
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
|
||||||
if (weapons != null && weapons.Count > 0)
|
|
||||||
{
|
|
||||||
CCSPlayer_ItemServices service = new(player.PlayerPawn.Value.ItemServices.Handle);
|
|
||||||
//var dropWeapon = VirtualFunction.CreateVoid<nint, nint>(service.Handle, GameData.GetOffset("CCSPlayer_ItemServices_DropActivePlayerWeapon"));
|
|
||||||
|
|
||||||
foreach (var weapon in weapons)
|
|
||||||
{
|
|
||||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
|
||||||
{
|
|
||||||
//if (weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 42 || weapon.Value.AttributeManager.Item.ItemDefinitionIndex == 59)
|
|
||||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
|
||||||
{
|
|
||||||
if (weapon.Index <= 0) return;
|
|
||||||
int weaponEntityIndex = (int)weapon.Index;
|
|
||||||
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
|
||||||
AddTimer(0.22f, () =>
|
|
||||||
{
|
|
||||||
if (player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("knife")
|
|
||||||
||
|
|
||||||
player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value!.DesignerName.Contains("bayonet")
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (player.PawnIsAlive)
|
|
||||||
{
|
|
||||||
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
|
||||||
service.DropActivePlayerWeapon(weapon.Value);
|
|
||||||
GiveKnifeToPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Task.Delay(TimeSpan.FromSeconds(3.5)).ContinueWith(_ =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
|
||||||
|
|
||||||
if (knife != null && knife.IsValid && knife.Handle != -1 && knife.Index > 0)
|
|
||||||
{
|
|
||||||
knife.Remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception) { }
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void RefreshSkins(CCSPlayerController? player)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
if (!Utility.IsPlayerValid(player) || !player!.PawnIsAlive) return;
|
|
||||||
|
|
||||||
AddTimer(0.18f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3"));
|
|
||||||
AddTimer(0.25f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot2"));
|
|
||||||
AddTimer(0.38f, () => NativeAPI.IssueClientCommand((int)player.Index - 1, "slot1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void RefreshWeapons(CCSPlayerController? player)
|
internal void RefreshWeapons(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || !player.PawnIsAlive)
|
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
||||||
@@ -225,40 +209,98 @@ namespace WeaponPaints
|
|||||||
if (weapons == null || weapons.Count == 0)
|
if (weapons == null || weapons.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var itemServices = new CCSPlayer_ItemServices(player.PlayerPawn.Value.ItemServices.Handle);
|
if (weapons != null && weapons.Count > 0)
|
||||||
|
|
||||||
foreach (var weapon in weapons)
|
|
||||||
{
|
{
|
||||||
if (weapon == null || !weapon.IsValid || weapon.Value == null || !weapon.Value.IsValid || weapon.Index <= 0 || !weapon.Value.DesignerName.Contains("weapon_"))
|
//Dictionary<string, (int, int)> weaponsWithAmmo = new Dictionary<string, (int, int)>();
|
||||||
continue;
|
Dictionary<string, List<(int, int)>> weaponsWithAmmo = new Dictionary<string, List<(int, int)>>();
|
||||||
|
bool bomb = false;
|
||||||
|
bool defuser = player.PawnHasDefuser;
|
||||||
|
bool healthshot = false;
|
||||||
|
|
||||||
try
|
// Iterate through each weapon
|
||||||
|
foreach (var weapon in weapons)
|
||||||
{
|
{
|
||||||
string? weaponByDefindex = null;
|
if (weapon == null || !weapon.IsValid || weapon.Value == null ||
|
||||||
|
!weapon.Value.IsValid || !weapon.Value.DesignerName.Contains("weapon_"))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
try
|
||||||
{
|
{
|
||||||
player.RemoveItemByDesignerName(weapon.Value.DesignerName, false);
|
string? weaponByDefindex = null;
|
||||||
GiveKnifeToPlayer(player);
|
|
||||||
}
|
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||||
else
|
|
||||||
{
|
if (weaponData != null)
|
||||||
if (weaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
|
{
|
||||||
|
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_C4)
|
||||||
|
bomb = true;
|
||||||
|
|
||||||
|
if (weaponData.Name.Equals("weapon_healtshot"))
|
||||||
|
healthshot = true;
|
||||||
|
|
||||||
|
if (weaponData.GearSlot == gear_slot_t.GEAR_SLOT_GRENADES || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_UTILITY || weaponData.GearSlot == gear_slot_t.GEAR_SLOT_BOOSTS)
|
||||||
|
{
|
||||||
|
int clip1 = weapon.Value.Clip1;
|
||||||
|
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||||
|
|
||||||
|
weaponsWithAmmo.Add(weapon.Value.DesignerName, new List<(int, int)>() { (clip1, reservedAmmo) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!weapon.Value.DesignerName.Contains("knife") && WeaponDefindex.TryGetValue(weapon.Value.AttributeManager.Item.ItemDefinitionIndex, out weaponByDefindex) && weaponByDefindex != null)
|
||||||
{
|
{
|
||||||
int clip1 = weapon.Value.Clip1;
|
int clip1 = weapon.Value.Clip1;
|
||||||
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
int reservedAmmo = weapon.Value.ReserveAmmo[0];
|
||||||
|
|
||||||
player.RemoveItemByDesignerName(weapon.Value.DesignerName, false);
|
if (!weaponsWithAmmo.ContainsKey(weaponByDefindex))
|
||||||
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(weaponByDefindex));
|
{
|
||||||
|
weaponsWithAmmo.Add(weaponByDefindex, new List<(int, int)>());
|
||||||
|
}
|
||||||
|
|
||||||
|
weaponsWithAmmo[weaponByDefindex].Add((clip1, reservedAmmo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning(ex.Message);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.RemoveWeapons();
|
||||||
|
AddTimer(0.2f, () =>
|
||||||
|
{
|
||||||
|
if (bomb)
|
||||||
|
player.GiveNamedItem("weapon_c4");
|
||||||
|
|
||||||
|
if (defuser)
|
||||||
|
{
|
||||||
|
var itemServ = player.PlayerPawn?.Value?.ItemServices;
|
||||||
|
if (itemServ != null)
|
||||||
|
{
|
||||||
|
var items = new CCSPlayer_ItemServices(itemServ.Handle);
|
||||||
|
items.HasDefuser = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (healthshot)
|
||||||
|
player.GiveNamedItem("weapon_healtshot");
|
||||||
|
|
||||||
|
GiveKnifeToPlayer(player);
|
||||||
|
|
||||||
|
foreach (var entry in weaponsWithAmmo)
|
||||||
|
{
|
||||||
|
foreach (var ammo in entry.Value)
|
||||||
|
{
|
||||||
|
var newWeapon = new CBasePlayerWeapon(player.GiveNamedItem(entry.Key));
|
||||||
Server.NextFrame(() =>
|
Server.NextFrame(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (newWeapon != null)
|
if (newWeapon != null)
|
||||||
{
|
{
|
||||||
newWeapon.Clip1 = clip1;
|
newWeapon.Clip1 = ammo.Item1;
|
||||||
newWeapon.ReserveAmmo[0] = reservedAmmo;
|
newWeapon.ReserveAmmo[0] = ammo.Item2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -267,62 +309,45 @@ namespace WeaponPaints
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.LogWarning("Unable to find weapon by defindex.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogWarning("Refreshing weapons exception: " + ex.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RemovePlayerKnife(CCSPlayerController? player, bool force = false)
|
internal void RefreshKnife(CCSPlayerController? player)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PawnIsAlive) return;
|
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE)
|
||||||
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null) return;
|
return;
|
||||||
|
|
||||||
|
if (player.PlayerPawn.Value.WeaponServices == null || player.PlayerPawn.Value.ItemServices == null)
|
||||||
|
return;
|
||||||
|
|
||||||
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
|
||||||
if (weapons != null && weapons.Count > 0)
|
if (weapons != null && weapons.Count > 0)
|
||||||
{
|
{
|
||||||
CCSPlayer_ItemServices service = new CCSPlayer_ItemServices(player.PlayerPawn.Value.ItemServices.Handle);
|
|
||||||
|
|
||||||
foreach (var weapon in weapons)
|
foreach (var weapon in weapons)
|
||||||
{
|
{
|
||||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid && weapon.Index > 0)
|
||||||
{
|
{
|
||||||
if (weapon.Value.DesignerName.Contains("knife") || weapon.Value.DesignerName.Contains("bayonet"))
|
try
|
||||||
{
|
{
|
||||||
if (!force)
|
CCSWeaponBaseVData? weaponData = weapon.Value.As<CCSWeaponBase>().VData;
|
||||||
{
|
|
||||||
if ((int)weapon.Index <= 0) return;
|
|
||||||
int weaponEntityIndex = (int)weapon.Index;
|
|
||||||
NativeAPI.IssueClientCommand((int)player.Index - 1, "slot3");
|
|
||||||
AddTimer(0.35f, () => service.DropActivePlayerWeapon(weapon.Value));
|
|
||||||
|
|
||||||
AddTimer(1.0f, () =>
|
if (weapon.Value.DesignerName.Contains("knife") || weaponData?.GearSlot == gear_slot_t.GEAR_SLOT_KNIFE)
|
||||||
{
|
|
||||||
CEntityInstance? knife = Utilities.GetEntityFromIndex<CEntityInstance>(weaponEntityIndex);
|
|
||||||
if (knife != null && knife.IsValid)
|
|
||||||
{
|
|
||||||
knife.Remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
weapon.Value.Remove();
|
RefreshWeapons(player);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Cannot remove knife: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetRandomPaint(int defindex)
|
private static int GetRandomPaint(int defindex)
|
||||||
{
|
{
|
||||||
if (skinsList == null || skinsList.Count == 0)
|
if (skinsList == null || skinsList.Count == 0)
|
||||||
@@ -370,6 +395,5 @@ namespace WeaponPaints
|
|||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,13 +81,15 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
internal static List<JObject> skinsList = new List<JObject>();
|
internal static List<JObject> skinsList = new List<JObject>();
|
||||||
internal static WeaponSynchronization? weaponSync;
|
internal static WeaponSynchronization? weaponSync;
|
||||||
internal bool g_bCommandsAllowed = true;
|
internal bool g_bCommandsAllowed = true;
|
||||||
|
internal Dictionary<int, string> PlayerWeaponImage = new();
|
||||||
|
|
||||||
internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php");
|
internal Uri GlobalShareApi = new("https://weaponpaints.fun/api.php");
|
||||||
internal int GlobalShareServerId = 0;
|
internal int GlobalShareServerId = 0;
|
||||||
internal static Dictionary<int, DateTime> commandsCooldown = new Dictionary<int, DateTime>();
|
internal static Dictionary<int, DateTime> commandsCooldown = new Dictionary<int, DateTime>();
|
||||||
internal static Database? _database;
|
internal static Database? _database;
|
||||||
|
|
||||||
//private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
//private CounterStrikeSharp.API.Modules.Timers.Timer? g_hTimerCheckSkinsData = null;
|
||||||
public static Dictionary<int, string> weaponDefindex { get; } = new Dictionary<int, string>
|
public static Dictionary<int, string> WeaponDefindex { get; } = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
{ 1, "weapon_deagle" },
|
{ 1, "weapon_deagle" },
|
||||||
{ 2, "weapon_elite" },
|
{ 2, "weapon_elite" },
|
||||||
@@ -150,7 +152,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
public override string ModuleAuthor => "Nereziel & daffyy";
|
public override string ModuleAuthor => "Nereziel & daffyy";
|
||||||
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
public override string ModuleDescription => "Skin and knife selector, standalone and web-based";
|
||||||
public override string ModuleName => "WeaponPaints";
|
public override string ModuleName => "WeaponPaints";
|
||||||
public override string ModuleVersion => "1.6a";
|
public override string ModuleVersion => "1.7a";
|
||||||
|
|
||||||
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
public static WeaponPaintsConfig GetWeaponPaintsConfig()
|
||||||
{
|
{
|
||||||
@@ -159,13 +161,14 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
if (hotReload && weaponSync != null)
|
if (hotReload)
|
||||||
{
|
{
|
||||||
OnMapStart(string.Empty);
|
OnMapStart(string.Empty);
|
||||||
|
|
||||||
foreach (var player in Utilities.GetPlayers())
|
foreach (var player in Utilities.GetPlayers())
|
||||||
{
|
{
|
||||||
if (weaponSync == null || player is null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
if (weaponSync == null || player is null || !player.IsValid || player.SteamID.ToString().Length != 17 || !player.PawnIsAlive || player.IsBot ||
|
||||||
|
player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
g_knifePickupCount[(int)player.Index] = 0;
|
g_knifePickupCount[(int)player.Index] = 0;
|
||||||
@@ -207,6 +210,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
Logger.LogError("You need to setup Database credentials in config!");
|
Logger.LogError("You need to setup Database credentials in config!");
|
||||||
throw new Exception("[WeaponPaints] You need to setup Database credentials in config!");
|
throw new Exception("[WeaponPaints] You need to setup Database credentials in config!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DatabaseConnectionString = Utility.BuildDatabaseConnectionString();
|
DatabaseConnectionString = Utility.BuildDatabaseConnectionString();
|
||||||
Utility.TestDatabaseConnection();
|
Utility.TestDatabaseConnection();
|
||||||
@@ -223,6 +227,8 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig<WeaponPaintsConfig
|
|||||||
};
|
};
|
||||||
|
|
||||||
_database = new(builder.ConnectionString);
|
_database = new(builder.ConnectionString);
|
||||||
|
|
||||||
|
_ = Utility.CheckDatabaseTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config = config;
|
Config = config;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.163" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.167" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.28" />
|
<PackageReference Include="Dapper" Version="2.1.28" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ namespace WeaponPaints
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await using (var connection = await _database.GetConnectionAsync())
|
await using (var connection = await _database.GetConnectionAsync())
|
||||||
{
|
{
|
||||||
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
string query = "SELECT `knife` FROM `wp_player_knife` WHERE `steamid` = @steamid";
|
||||||
@@ -189,6 +188,7 @@ namespace WeaponPaints
|
|||||||
Utility.Log(e.Message);
|
Utility.Log(e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task SyncWeaponPaintsToDatabase(PlayerInfo player)
|
internal async Task SyncWeaponPaintsToDatabase(PlayerInfo player)
|
||||||
{
|
{
|
||||||
if (player == null || player.Index <= 0 || player.SteamId == null) return;
|
if (player == null || player.Index <= 0 || player.SteamId == null) return;
|
||||||
|
|||||||
@@ -11,4 +11,4 @@
|
|||||||
"wp_skin_menu_weapon_title": "Ieroču Izvēlne",
|
"wp_skin_menu_weapon_title": "Ieroču Izvēlne",
|
||||||
"wp_skin_menu_skin_title": "Izvēlies skinu ierocim: {lime}{0}{default}",
|
"wp_skin_menu_skin_title": "Izvēlies skinu ierocim: {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "Tu esi izvēlējies {lime}{0}{default} kā savu skinu"
|
"wp_skin_menu_select": "Tu esi izvēlējies {lime}{0}{default} kā savu skinu"
|
||||||
}
|
}
|
||||||
@@ -11,4 +11,4 @@
|
|||||||
"wp_skin_menu_weapon_title": "Menu de Armas",
|
"wp_skin_menu_weapon_title": "Menu de Armas",
|
||||||
"wp_skin_menu_skin_title": "Selecionou a skin para {lime}{0}{default}",
|
"wp_skin_menu_skin_title": "Selecionou a skin para {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin"
|
"wp_skin_menu_select": "Você escolheu {lime}{0}{default} como sua skin"
|
||||||
}
|
}
|
||||||
@@ -11,4 +11,4 @@
|
|||||||
"wp_skin_menu_weapon_title": "Menu de Armas",
|
"wp_skin_menu_weapon_title": "Menu de Armas",
|
||||||
"wp_skin_menu_skin_title": "Escolhe a skin para {lime}{0}{default}",
|
"wp_skin_menu_skin_title": "Escolhe a skin para {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "Tu escolheste {lime}{0}{default} como a tua skin"
|
"wp_skin_menu_select": "Tu escolheste {lime}{0}{default} como a tua skin"
|
||||||
}
|
}
|
||||||
@@ -11,4 +11,4 @@
|
|||||||
"wp_skin_menu_weapon_title": "Silah Menüsü",
|
"wp_skin_menu_weapon_title": "Silah Menüsü",
|
||||||
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
"wp_skin_menu_skin_title": "Select skin for {lime}{0}{default}",
|
||||||
"wp_skin_menu_select": "Teniniz olarak {lime}{0}{default} seçtiniz"
|
"wp_skin_menu_select": "Teniniz olarak {lime}{0}{default} seçtiniz"
|
||||||
}
|
}
|
||||||
@@ -11,4 +11,4 @@
|
|||||||
"wp_skin_menu_weapon_title": "武器菜单",
|
"wp_skin_menu_weapon_title": "武器菜单",
|
||||||
"wp_skin_menu_skin_title": "选择 {lime}{0}{default} 的皮肤",
|
"wp_skin_menu_skin_title": "选择 {lime}{0}{default} 的皮肤",
|
||||||
"wp_skin_menu_select": "你选择了 {lime}{0}{default} 作为你的皮肤"
|
"wp_skin_menu_select": "你选择了 {lime}{0}{default} 作为你的皮肤"
|
||||||
}
|
}
|
||||||
12078
website/data/skins.json
12078
website/data/skins.json
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@ $weapons = array (
|
|||||||
"weapon_aug" => 8,
|
"weapon_aug" => 8,
|
||||||
"weapon_awp" => 9,
|
"weapon_awp" => 9,
|
||||||
"weapon_famas" => 10,
|
"weapon_famas" => 10,
|
||||||
"weapon_g3sg1" => 10,
|
"weapon_g3sg1" => 11,
|
||||||
"weapon_galilar" => 13,
|
"weapon_galilar" => 13,
|
||||||
"weapon_m249" => 14,
|
"weapon_m249" => 14,
|
||||||
"weapon_m4a1" => 16,
|
"weapon_m4a1" => 16,
|
||||||
@@ -53,7 +53,14 @@ $weapons = array (
|
|||||||
"weapon_knife_stiletto" => 522,
|
"weapon_knife_stiletto" => 522,
|
||||||
"weapon_knife_widowmaker" => 523,
|
"weapon_knife_widowmaker" => 523,
|
||||||
"weapon_knife_skeleton" => 525);
|
"weapon_knife_skeleton" => 525);
|
||||||
$json = json_decode(file_get_contents('skins.json'));
|
|
||||||
|
|
||||||
|
|
||||||
|
$
|
||||||
|
|
||||||
|
$json = json_decode(file_get_contents('https://bymykel.github.io/CSGO-API/api/en/skins.json'));
|
||||||
|
|
||||||
|
die(var_dump($json));
|
||||||
echo "<pre>";
|
echo "<pre>";
|
||||||
foreach($json as $skin)
|
foreach($json as $skin)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
.bg-primary {
|
.bg-primary {
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-title item-name{
|
.card-title item-name {
|
||||||
//text-align:center;
|
//text-align:center;
|
||||||
font-weight:bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skin-image {
|
.skin-image {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
display:block;
|
display: block;
|
||||||
text-align:center;
|
text-align: center;
|
||||||
width:50%;
|
width: 50%;
|
||||||
//border-bottom: solid 1px #eee;
|
//border-bottom: solid 1px #eee;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user