[HELP]unique command for all player stats
#1

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
Reply
#2

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

Name:
Age:
Level:
Admin:
Donator:

ect?
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)