Quote:
Originally Posted by Marcus101RR
It has been many years since I worked on this plugin, and seeing how SM has changed alot since 1.11, it will take a bit to adjust all syntaxes. The reason why perks/upgrades are not saving is now that 64 bit length string is being used in total so now it has to be exact. I need to study SM 1.11 and fix all this when I get the chance, I have been slowly pushed back to working on Left 4 Dead 2 plugins, particularly this plugin when I noticed it caused a bunch of issues.
|
U don't need to update syntaxes , every thing is just fine and i have compiled it with the last version of sourcemod , the main problem was In (Saving/Loading Data , and NetProps) . another problem in my opinion is that the whole code needs to be optimized and that refers to you .
this may help you saving time :
PHP Code:
public OnClientDisconnect(client)
{
if(GetClientTeam(client) != 2) return;
SaveData(client);
...
...
}
stock SaveData(client)
{
char UpgradeBinary[64],DisabledBinary[64];
for(new i = 0; i < MAX_UPGRADES; i++)
{
UpgradeBinary[i]=iUpgrade[client][i]?'1':'0';
DisabledBinary[i]=iUpgradeDisabled[client][i]?'1':'0';
iUpgrade[client][i]=iUpgradeDisabled[client][i]=0;
}
if(iSaveFeature[client] == 1)
{
char TQuery[128],SteamID[32];
GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID));
new m_survivorCharacter = GetEntProp(client, Prop_Send, "m_survivorCharacter");
if(IsFakeClient(client) && m_survivorCharacter >= 0)
{
Format(SteamID, sizeof(SteamID), "%s_%d", SteamID, m_survivorCharacter);
}
Format(TQuery, sizeof(TQuery), "INSERT OR REPLACE INTO accounts VALUES ('%s', %d, %d, %d, '%s', '%s');", SteamID, iSaveFeature[client], iAnnounceText[client], iPerkBonusSlots[client],UpgradeBinary, DisabledBinary);
SQL_FastQuery(hDatabase, TQuery);
}
}
PHP Code:
public OnClientPostAdminCheck(client)
{
if(GetClientTeam(client) != 2) return;
iSaveFeature[client] = 1;
iAnnounceText[client] = 1;
iPerkBonusSlots[client] = 0;
LoadData(client);
SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
stock LoadData(client)
{
char TQuery[64],SteamID[32];
GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID));
new m_survivorCharacter = GetEntProp(client, Prop_Send, "m_survivorCharacter");
if(IsFakeClient(client) && m_survivorCharacter >= 0)
{
Format(SteamID, sizeof(SteamID), "%s_%d", SteamID, m_survivorCharacter);
}
Format(TQuery, sizeof(TQuery), "SELECT * FROM accounts WHERE steamId = '%s';", SteamID);
SQL_TQuery(hDatabase, LoadPlayerData, TQuery, client);
}
public LoadPlayerData(Handle:owner, Handle:hndl, const String:error[], any:client)
{
if(hndl == INVALID_HANDLE || !SQL_GetRowCount(hndl) || !SQL_FetchRow(hndl))
{
return;
}
iBitsUpgrades[client] = 0;
char UpgradeBinary[64],DisabledBinary[64];
iSaveFeature[client] = SQL_FetchInt(hndl, 1);
iAnnounceText[client] = SQL_FetchInt(hndl, 2);
iPerkBonusSlots[client] = SQL_FetchInt(hndl, 3);
SQL_FetchString(hndl, 4, UpgradeBinary, sizeof(UpgradeBinary));
SQL_FetchString(hndl, 5, DisabledBinary, sizeof(DisabledBinary));
for (new i = 0;i<MAX_UPGRADES; i++)
{
iUpgrade[client][i] = UpgradeBinary[i] == '1'? UpgradeIndex[i] : 0; //Why not to use : Pow(2, i) OR RoundToFloor( Pow( 2.0 , float(i) ) ) ?
iUpgradeDisabled[client][i] = DisabledBinary[i] == '1'? 1 : 0;
}
LogMessage("Loading Client %N - %d, %d, %s", client, iSaveFeature[client], iAnnounceText[client], UpgradeBinary);
}
compiled by
souremod 1.11 - build 6952 with no warnings , also fixed : cvars type, and netprops espiceally "m_hMyWeapons" and Ammo Offset , you can look at the .sp file below .
And thats all .
Note : i'm talking about l4d1 sp , i don't know if l4d2 has the same approach or not .
for users :
DON'T DOWNLOAD THE FILE BELOW , ITS NOT TESTED .