Skin not saving
#1

NEVER SOLVED
Reply
#2

pawn Код:
pinfo[playerid][Skin] = GetPlayerSkin(playerid);
mysql_format(MySQLTunnel,Query,sizeof(Query),"UPDATE `accounts` SET `pskin` = '%d' WHERE `pid` = '%d'",pinfo[playerid][Skin],pinfo[playerid][pMySQLID]);
mysql_pquery(MySQLTunnel,Query);
Reply
#3

It saves it now ye forgot that function but i want to make it so when player registers he choose skin but when he logs in(as registered ofc)he get spawned how this could be implemented?
Reply
#4

Quote:
Originally Posted by vassilis
Посмотреть сообщение
It saves it now ye forgot that function but i want to make it so when player registers he choose skin but when he logs in(as registered ofc)he get spawned how this could be implemented?
I think updating the player skin when they're spawning is not a good idea because it will keep on updating each time when they spawn, you can use a command or something to UPDATE the skin.

Here is the code that you asked for; this should be places under OnPlayerSpawn Callback.

pawn Код:
if((PlayerInfo[playerid][LoggedIn] == 1)) {
    new query[100];
    mysql_format(mysql, query, sizeof(query), "SELECT `pskin` FROM `accounts` WHERE `pid` = '%d'", pinfo[playerid][pMySQLID]);
    new Cache:result = mysql_query(mysql, query);
    if(cache_get_row_count() != 0)
    {
        pinfo[playerid][Skin] = cache_get_field_content_int(0, "pskin");
        SetPlayerSkin(playerid,pinfo[playerid][Skin]);
    }
    cache_delete(result);}
Reply
#5

Ok thanks for that and i use a function named accountload. should i use spawnplayer there?
The accountload is whenplayer logs in succesffuly to load player statistics(at the same time player is at class selection but i want the player to get spawned if he is already registered)
Reply
#6

Quote:
Originally Posted by vassilis
Посмотреть сообщение
Ok thanks for that and i use a function named accountload. should i use spawnplayer there?
The accountload is whenplayer logs in succesffuly to load player statistics(at the same time player is at class selection but i want the player to get spawned if he is already registered)
Yes you can use SpawnPlayer in accountload callback/stock so it will spawn the player right away after they login.
Reply
#7

So i used a timer to save skin but it spawns it as 0 when i relog...
my timer..

pawn Код:
function SkinSaving(playerid)
{
    pinfo[playerid][Skin] = GetPlayerSkin(playerid);
    mysql_format(MySQLTunnel,Query,sizeof(Query),"UPDATE `accounts` SET `pskin` = '%d' WHERE `pid` = '%d'",pinfo[playerid][Skin],pinfo[playerid][pMySQLID]);
    mysql_pquery(MySQLTunnel,Query);
    return 1;
}
onplayerconnect
pawn Код:
skinsaving[playerid] = SetTimerEx("SkinSaving", 600000,1,"i",playerid);
onplayerspawn
pawn Код:
if((pinfo[playerid][pLogged] == 1)) {
        mysql_format(MySQLTunnel, Query, sizeof(Query), "SELECT `pskin` FROM `accounts` WHERE `pid` = '%d'", pinfo[playerid][pMySQLID]);
        new Cache:result = mysql_query(MySQLTunnel, Query);
        if(cache_get_row_count() != 0)
        {
            pinfo[playerid][Skin] = cache_get_field_content_int(0, "pskin");
            SetPlayerSkin(playerid,pinfo[playerid][Skin]);
        }
        cache_delete(result);}
It spawns but sets as skin id 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)