SA-MP Forums Archive
[HELP]unique command for all player stats - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP]unique command for all player stats (/showthread.php?tid=330679)



[HELP]unique function for edit all player stats - xX_Simon_Xx - 02.04.2012

PHP код:
forward ChangePlayerInfo(playerid,campo,valore[]);
public 
ChangePlayerInfo(playerid,campo,valore[])
{
    new 
piu strfind(valore"+"true);
    new 
meno strfind(valore"-"true);
    if(
piu == -&& meno == -1){PlayerInfo[playerid][campo]=valore;}
    else if(
piu != -&& meno == -1){PlayerInfo[playerid][campo]+=valore;}
    else if(
meno != -&& piu == -1){PlayerInfo[playerid][campo]-=valore;}
    
MySQLCheckConnection();
    new 
query[MAX_STRING];
    new 
string[MAX_STRING];
    
format(queryMAX_STRING"UPDATE utenti SET ");
    
format(stringMAX_STRING"%s",campo);
    
MySQLUpdatePlayerInt(queryPlayerInfo[playerid][pSQLID], string,PlayerInfo[playerid][campo]);
    
MySQLUpdateFinish(queryPlayerInfo[playerid][pSQLID]);

So I should use this function to change the statistics of the player but of course in this way by mistake because the "campo" that is in "PlayerInfo [playerid] [campo]" is not a variable of PlayerInfo then the only solution I can see that is this.

PHP код:
if(!strcmp(campo,"pLevel",true))
    {
        if(
piu == -&& meno == -1){PlayerInfo[playerid][pLevel]=valore;}
        else if(
piu != -&& meno == -1){PlayerInfo[playerid][pLevel]+=valore;}
        else if(
meno != -&& piu == -1){PlayerInfo[playerid][pLevel]-=valore;}
    }
    else if(!
strcmp(campo,"pAdmin",true))
    {
        if(
piu == -&& meno == -1){PlayerInfo[playerid][pAdmin]=valore;}
        else if(
piu != -&& meno == -1){PlayerInfo[playerid][pAdmin]+=valore;}
        else if(
meno != -&& piu == -1){PlayerInfo[playerid][pAdmin]-=valore;}
    } 
then continuing for all fields of the user but since it's a bit 'long let me know if you have any other idea to do this


Re: [HELP]unique command for all player stats - BigD - 02.04.2012

So why don't you just do /stats then it likes shows

Name:
Age:
Level:
Admin:
Donator:

ect?


Re: [HELP]unique command for all player stats - xX_Simon_Xx - 02.04.2012

no do not you understand what I do.
Then I want to do that function so that the GM does not have any time to enter eg "PlayerInfo [playerid] [pLevel] += 1;" etc. and so that every time I perform that function the parameter in question is saved to the mysql.
without this feature every time I should do this:
PHP код:
    PlayerInfo [playerid] [pLevel] += 1;
    new 
query[MAX_STRING];
    new 
string[MAX_STRING];
    
format(queryMAX_STRING"UPDATE utenti SET ");
    
MySQLUpdatePlayerInt(queryPlayerInfo[playerid][pSQLID],"pLevel",PlayerInfo[playerid][pLevel]);
    
MySQLUpdateFinish(queryPlayerInfo[playerid][pSQLID]); 
However, I do not need anymore but still want to know how to do