Saving player colors
#1

hi guys ,

I need some help with this my problem is when I save player colors it saves correctly but when I load them it load the 1 color but I choosed other color pls help me here is the code

pawn Код:
new const P_Colors[ ] = {0x00FFFFFF,0xFFE4C4FF,0x0000FFFF,0x00FF00FF,0xFF0000FF,0xFFFF00FF,0xFFA500FF,0xFFD700FF,0x8A2BE2FF,0xA52A2AFF,0xFF7F50FF,0x8B008BFF};

//dialog

case DIALOG_COLORS+1:
        {
        if ( !response )
                return ( 1 );

            SetPlayerColor(playerid, P_Colors[ listitem ] );
            format(gsQuery,sizeof(gsQuery),"UPDATE `Accounts` SET `Color` = '%d'  WHERE `Name` = '%s'",listitem, getPlayerName(playerid));
            mysql_query( gsQuery, THREAD_NONE, playerid, connection );
            return 1;
        }

//loading player data
cache_get_field_content(0, "Color",savingstring, connection);SetPlayerColor(playerid, P_Colors[strval(savingstring)]);
Reply
#2

Try this for the loading:
new PlayerColour[MAX_PLAYERS];
PlayerColour = cache_get_field_content_int(0, "Color", connection); SetPlayerColor(playerid,P_Colors[PlayerColour]);

Also, Have you debugged the loading? (I.e- What value it returns).
Reply
#3

pawn Код:
error 017: undefined symbol "cache_get_field_content_int"
error 033: array must be indexed (variable "PlayerColour")
error 033: array must be indexed (variable "PlayerColour")
sorry bro it's not working and what do you mean by debugged the loading ?
Reply
#4

Hello!

PHP код:
case DIALOG_COLORS+1:
{
    if(!
response)return 1;
    
SetPlayerColor(playerid,P_Colors[listitem]);
    
format(gsQuery,sizeof gsQuery,"UPDATE `Accounts` SET `Color`='%i' WHERE `Name`='%s'",listitem,getPlayerName(playerid));
    
mysql_query(gsquery,THREAD_NONE,playerid,connection);
    print(
gsQuery);
    return 
1;
}
//loading player data
cache_get_field_content(0,"Color",savingstring,connection);
SetPlayerColor(playerid,P_Colors[strval(savingstring)]); 
If that does not work, then give me the code that was issued by the print.

Mencent
Reply
#5

it printing this bro and it's working awesome thank you so much bro <3 thanks
UPDATE `Accounts` SET `Color`='4' WHERE `Name`='Name`
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)