Raised This Month: $51 Target: $400
 12% 

[L4D(2)] Survivor Upgrades Reloaded


Post New Thread Reply   
 
Thread Tools Display Modes
CrazMan
Member
Join Date: Jun 2022
Old 10-22-2023 , 08:31   Re: [L4D(2)] Survivor Upgrades Reloaded
Reply With Quote #211

Hello.
Help me fix the bug with perks. No, I can’t fix it.

L 10/22/2023 - 15:27:10: SourceMod error session started
L 10/22/2023 - 15:27:10: Info (map "l4d_smalltown01_caves") (file "/game/left4dead/addons/sourcemod/logs/errors_20231022.log")
L 10/22/2023 - 15:27:10: [SM] Exception reported: Current result set has no fetched rows
L 10/22/2023 - 15:27:10: [SM] Blaming: l4d_upgradesreloaded.smx
L 10/22/2023 - 15:27:10: [SM] Call stack trace:
L 10/22/2023 - 15:27:10: [SM] [0] SQL_FetchInt
L 10/22/2023 - 15:27:10: [SM] [1] Line 589, /home/forums/content/files/5/8/4/6/9/151897.attach::LoadPlayerData
CrazMan is offline
101
Member
Join Date: Nov 2023
Old 11-20-2023 , 09:20   Re: [L4D(2)] Survivor Upgrades Reloaded
Reply With Quote #212

Quote:
Originally Posted by CrazMan View Post
Hello.
Help me fix the bug with perks. No, I can’t fix it.

L 10/22/2023 - 15:27:10: SourceMod error session started
L 10/22/2023 - 15:27:10: Info (map "l4d_smalltown01_caves") (file "/game/left4dead/addons/sourcemod/logs/errors_20231022.log")
L 10/22/2023 - 15:27:10: [SM] Exception reported: Current result set has no fetched rows
L 10/22/2023 - 15:27:10: [SM] Blaming: l4d_upgradesreloaded.smx
L 10/22/2023 - 15:27:10: [SM] Call stack trace:
L 10/22/2023 - 15:27:10: [SM] [0] SQL_FetchInt
L 10/22/2023 - 15:27:10: [SM] [1] Line 589, /home/forums/content/files/5/8/4/6/9/151897.attach::LoadPlayerData
Updated 1/23/2024 : Fix Errors/Game Crash When Loading Or Saving Data Of Players Who Got The Max-Upgrades ! ( F it )
Attached Files
File Type: sp Get Plugin or Get Source (l4d_upgradesreloaded.sp - 23 views - 113.8 KB)
File Type: sp Get Plugin or Get Source (l4d2_upgradesreloaded.sp - 45 views - 125.5 KB)

Last edited by 101; 01-23-2024 at 02:02.
101 is offline
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 01-16-2024 , 15:23   Re: [L4D(2)] Survivor Upgrades Reloaded
Reply With Quote #213

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.
__________________
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
101
Member
Join Date: Nov 2023
Old 01-21-2024 , 04:46   Re: [L4D(2)] Survivor Upgrades Reloaded
Reply With Quote #214

Quote:
Originally Posted by Marcus101RR View Post
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 
0MAX_UPGRADESi++)
    {
        
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(clientAuthId_Steam2SteamIDsizeof(SteamID));
        new 
m_survivorCharacter GetEntProp(clientProp_Send"m_survivorCharacter");
        if(
IsFakeClient(client) && m_survivorCharacter >= 0)
        {
            
Format(SteamIDsizeof(SteamID), "%s_%d"SteamIDm_survivorCharacter);
        }
        
Format(TQuerysizeof(TQuery), "INSERT OR REPLACE INTO accounts VALUES ('%s', %d, %d, %d, '%s', '%s');"SteamIDiSaveFeature[client], iAnnounceText[client], iPerkBonusSlots[client],UpgradeBinaryDisabledBinary);
        
SQL_FastQuery(hDatabaseTQuery);
    }

PHP Code:
public OnClientPostAdminCheck(client)
{
    if(
GetClientTeam(client) != 2)    return;
    
iSaveFeature[client] = 1;
    
iAnnounceText[client] = 1;
    
iPerkBonusSlots[client] = 0;
    
LoadData(client);
    
SDKHook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

stock LoadData(client)
{
    
char TQuery[64],SteamID[32];
    
GetClientAuthId(clientAuthId_Steam2SteamIDsizeof(SteamID));
    new 
m_survivorCharacter GetEntProp(clientProp_Send"m_survivorCharacter");
    if(
IsFakeClient(client) && m_survivorCharacter >= 0)
    {
        
Format(SteamIDsizeof(SteamID), "%s_%d"SteamIDm_survivorCharacter);
    }
    
Format(TQuerysizeof(TQuery), "SELECT * FROM accounts WHERE steamId = '%s';"SteamID);
    
SQL_TQuery(hDatabaseLoadPlayerDataTQueryclient);
}

public 
LoadPlayerData(Handle:ownerHandle: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(hndl1);
    
iAnnounceText[client] = SQL_FetchInt(hndl2);
    
iPerkBonusSlots[client] = SQL_FetchInt(hndl3);
    
SQL_FetchString(hndl4UpgradeBinarysizeof(UpgradeBinary));
    
SQL_FetchString(hndl5DisabledBinarysizeof(DisabledBinary));

    for (new 
0;i<MAX_UPGRADESi++)
    {
        
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'0;
    }
    
LogMessage("Loading Client %N - %d, %d, %s"clientiSaveFeature[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 .
Attached Files
File Type: sp Get Plugin or Get Source (l4d_upgradesreloaded.sp - 11 views - 112.3 KB)

Last edited by 101; 01-21-2024 at 17:42. Reason: F it
101 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:01.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode