SA-MP Forums Archive
MySQL skins not saving - 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: MySQL skins not saving (/showthread.php?tid=641162)



MySQL skins not saving - Jing_Chan - 11.09.2017

So this is an extract of my script on OnPlayerDisconnect, so when you logout this saves the skin ID into the DB.

pawn Код:
SavePlayerSkin(playerid);
This is my setskin CMD (untidy, I know), at the bottom I tried SavePlayerSkin(targetid); in attempt to make that users skin save instantly after setting. This does not work, any reason why?

pawn Код:
CMD:setskin(playerid, params[])
{
    new targetid, skin, sendername[MAX_PLAYER_NAME], receiver[MAX_PLAYER_NAME], string[128];
    if(sscanf(params,"ui", targetid, skin)) return SendClientMessage(playerid, COLOR_RED,"[SERVER] USAGE: /setskin [PlayerID] [Skinmodel]");
    if(PlayerData[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, COLOR_RED,"[SERVER] You are not authorised to use this command!");
    if(skin > 299 || skin < 1) return SendClientMessage(playerid, COLOR_RED,"[ADMIN] Skins range between 1-299.");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED,"[ADMIN] This player is not connected.");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    GetPlayerName(targetid, receiver,sizeof(receiver));
    format(string, sizeof(string),"[ADMIN] Your skin have been set to model %d by admin %s", skin, sendername);
    SendClientMessage(targetid, COLOR_RED, string);
    format(string, sizeof(string),"You have set %s skin to model %d", receiver, skin);
    SendClientMessage(playerid, COLOR_RED, string);
    SetPlayerSkin(targetid, skin); // just added pSkin to auto set when SetPlayerSkin is called, basically added more functionality to SetPlayerS ah alright, so should it save on
    SavePlayerSkin(targetid);
    return 1;
}



Re: MySQL skins not saving - Eoussama - 11.09.2017

Can you post the code for SavePlayerSkin


Re: MySQL skins not saving - Jing_Chan - 11.09.2017

pawn Код:
Server:SavePlayerSkin(playerid)
{  
    new query[128];
    mysql_format(sqlConnection, query, sizeof(query), "UPDATE players SET Skin = '%d' WHERE Name = '%e' LIMIT 1", PlayerData[playerid][pSkin], GetName(playerid));
    mysql_pquery(sqlConnection, query);
    return true;
}



Re: MySQL skins not saving - Kane - 11.09.2017

You never actually stored the skin into pSkin.


Re: MySQL skins not saving - Jing_Chan - 11.09.2017

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
You never actually stored the skin into pSkin.
On the command you mean?


Re: MySQL skins not saving - Kane - 11.09.2017

Yes.
PHP код:
PlayerData[targetid][pSkin] = skin



Re: MySQL skins not saving - Jing_Chan - 11.09.2017

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Yes.
PHP код:
PlayerData[targetid][pSkin] = skin
Ah, got it. Thank you for your help.