Skip to content

Commit

Permalink
Merge branch 'hotfix/v1.0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
kgns committed Jul 19, 2017
2 parents ecfed01 + 034e9c7 commit f11838e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
Binary file modified addons/sourcemod/plugins/weapons.smx
Binary file not shown.
28 changes: 21 additions & 7 deletions addons/sourcemod/scripting/weapons.sp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Plugin myinfo =
name = "Weapons & Knives",
author = "kgns - wasdzone",
description = "All in one custom weapon management",
version = "1.0.6",
version = "1.0.7",
url = "http://www.wasdzone.com"
};

Expand Down Expand Up @@ -65,15 +65,25 @@ public void OnPluginStart()

PTaH(PTaH_GiveNamedItemPre, Hook, GiveNamedItemPre);
PTaH(PTaH_GiveNamedItem, Hook, GiveNamedItem);
PTaH(PTaH_WeaponCanUse, Hook, WeaponCanUse);
}

public void OnConfigsExecuted()
{
GetConVarString(g_Cvar_DBConnection, g_DBConnection, sizeof(g_DBConnection));
GetConVarString(g_Cvar_TablePrefix, g_TablePrefix, sizeof(g_TablePrefix));

Database.Connect(SQLConnectCallback, g_DBConnection);
if(g_DBConnectionOld[0] != EOS && strcmp(g_DBConnectionOld, g_DBConnection) != 0 && db != null)
{
delete db;
db = null;
}

if(db == null)
{
Database.Connect(SQLConnectCallback, g_DBConnection);
}

strcopy(g_DBConnectionOld, sizeof(g_DBConnectionOld), g_DBConnection);

g_Cvar_ChatPrefix.GetString(g_ChatPrefix, sizeof(g_ChatPrefix));
g_iKnifeStatTrakMode = g_Cvar_KnifeStatTrakMode.IntValue;
Expand All @@ -91,7 +101,7 @@ public Action CommandWeaponSkins(int client, int args)
{
CreateMainMenu(client).Display(client, MENU_TIME_FOREVER);
}
return Plugin_Continue;
return Plugin_Handled;
}

public Action CommandKnife(int client, int args)
Expand All @@ -100,7 +110,7 @@ public Action CommandKnife(int client, int args)
{
CreateKnifeMenu(client).Display(client, MENU_TIME_FOREVER);
}
return Plugin_Continue;
return Plugin_Handled;
}

public Action CommandWSLang(int client, int args)
Expand All @@ -109,7 +119,7 @@ public Action CommandWSLang(int client, int args)
{
CreateLanguageMenu(client).Display(client, MENU_TIME_FOREVER);
}
return Plugin_Continue;
return Plugin_Handled;
}

public Action CommandNameTag(int client, int args)
Expand Down Expand Up @@ -161,7 +171,7 @@ public Action CommandNameTag(int client, int args)
}
}
}
return Plugin_Continue;
return Plugin_Handled;
}

public void OnClientPutInServer(int client)
Expand Down Expand Up @@ -191,6 +201,10 @@ public void OnClientPostAdminCheck(int client)
temp[index] = '\0';
}
g_iSteam32[client] = StringToInt(temp);
CEconItemView playerItem = PTaH_GetItemInLoadout(client, CS_TEAM_T, 0);
g_iPlayerKnifeDefIndex[0][client] = playerItem.GetItemDefinition().GetDefinitionIndex();
playerItem = PTaH_GetItemInLoadout(client, CS_TEAM_CT, 0);
g_iPlayerKnifeDefIndex[1][client] = playerItem.GetItemDefinition().GetDefinitionIndex();
GetPlayerData(client);
QueryClientConVar(client, "cl_language", ConVarCallBack);
}
Expand Down
11 changes: 11 additions & 0 deletions addons/sourcemod/scripting/weapons/database.sp
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,15 @@ public void T_CreateTableCallback(Database database, DBResultSet results, const
{
LogError("Create table failed! %s", error);
}
else
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i))
{
OnClientPutInServer(i);
OnClientPostAdminCheck(i);
}
}
}
}
3 changes: 3 additions & 0 deletions addons/sourcemod/scripting/weapons/globals.sp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ char configPath[PLATFORM_MAX_PATH];

ConVar g_Cvar_DBConnection;
char g_DBConnection[32];
char g_DBConnectionOld[32];

ConVar g_Cvar_TablePrefix;
char g_TablePrefix[10];
Expand Down Expand Up @@ -74,6 +75,8 @@ int g_iSteam32[MAXPLAYERS+1] = { 0, ... };

int g_iKnife[MAXPLAYERS+1] = { 0, ... };

int g_iPlayerKnifeDefIndex[2][MAXPLAYERS+1];

char g_Language[MAX_LANG][32];
int g_iClientLanguage[MAXPLAYERS+1];
Menu menuWeapons[MAX_LANG][sizeof(g_WeaponClasses)];
Expand Down
11 changes: 2 additions & 9 deletions addons/sourcemod/scripting/weapons/hooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ public void GiveNamedItem(int client, const char[] classname, const CEconItemVie
g_smWeaponDefIndex.GetValue(g_WeaponClasses[g_iKnife[client]], defIndex);
char knifeClassName[32];
GetWeaponClass(entity, knifeClassName, sizeof(knifeClassName));
CEconItemView playerItem = PTaH_GetItemInLoadout(client, GetClientTeam(client), 0);
int playerKnifeDefIndex = playerItem.GetItemDefinition().GetDefinitionIndex();
if(!StrEqual(knifeClassName, g_WeaponClasses[g_iKnife[client]]) || defIndex == playerKnifeDefIndex)
int playerTeam = GetClientTeam(client);
if(!StrEqual(knifeClassName, g_WeaponClasses[g_iKnife[client]]) || (CS_TEAM_T <= playerTeam <= CS_TEAM_CT && defIndex == g_iPlayerKnifeDefIndex[playerTeam - 2][client]))
{
float origin[3], angles[3];
GetClientAbsOrigin(client, origin);
Expand Down Expand Up @@ -114,9 +113,3 @@ public Action OnTakeDamageAlive(int victim, int &attacker, int &inflictor, float
UpdatePlayerData(attacker, updateFields);
return Plugin_Continue;
}

public bool WeaponCanUse(int client, int iEnt, bool pickup)
{
if(IsValidEdict(iEnt) && IsValidEntity(iEnt) && GetEntProp(iEnt, Prop_Send, "m_iItemDefinitionIndex") >= 500) return true;
return pickup;
}

0 comments on commit f11838e

Please sign in to comment.