PDA

View Full Version : Skin saving problem


[RS]Monk
20/11/2011, 07:10 PM
Hi,i have one problem with saving skin.When player chose skin from class selection he gets CJ skin,thats because i put SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]); in OnPlayerSpawn callback.But,when i delete SetPlayerSkin(playerid...from OnPlayerSpawn its work..but when i set player skin with command (/setskin) and kill myself i get old skin.I can't explain better because i don't know good english,i think you understand me.If you don't understand go to 95.180.59.10:7787 and i will show you.Im using y_ini register system.

Tanush123
20/11/2011, 07:45 PM
U should add a timer that saves the player account every 10 seconds so under it you make the skin save

[RS]Monk
20/11/2011, 08:00 PM
@Tanush123
again nothing :(

Tanush123
20/11/2011, 08:10 PM
on top
new SAVETIMER[MAX_PLAYERS];

on your login code


SAVETIMER = SetTimerEx("Save",5000,1,"u",playerid);


on bottom

forward Save(playerid);
public Save(playerid)
{
//your saving code
return 1;
}

DreveN
20/11/2011, 08:10 PM
if(strcmp(cmd, "/setskin", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, ": /setskin [ID/] [skin]");
new playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
new skin = strval(tmp);
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
PlayerInfo[playa][pSkin] == skin;
}
}
return true;
}
}

Sinc
20/11/2011, 08:19 PM
The OnPlayerSpawn callback is called when a player spawns. If you die, you will respawn, OnPlayerSpawn is then called. You must remove the SetPlayerSkin function from OnPlayerSpawn, spawn the player, get his skin id and output the data either as a message or directly to the server console.

DreveN
20/11/2011, 08:24 PM
Also check for the appearance of the player is loading playerinfo [playerid] [pSkin]

[RS]Monk
20/11/2011, 08:49 PM
now its work but only for id 0 save skin..

-Rebel Son-
21/11/2011, 12:43 AM
#Tanush, That's a waste of usage, Timers also lag.

Monk, I've never scripted with Yini, But How much are you trying to save? Alot of things? or small amount of things?
Yinis good for large amounts of data, But if it's like 2 or three things, Get something smaller. I Use Dini for my small saving, and use DJSON for my larger saving. Message me so i can talk to you further.

[RS]Monk
21/11/2011, 04:50 AM
I wont to make two commands,/saveskin [skinid] and /nosaveskin (when you tyre this,the skin will be save only from class selection).For example,if you tyre /saveskin 294 and go relog and on class selection you can chose any skin but when you spawn you will get skin 294.

KfirRP
21/11/2011, 10:50 AM
Look, have a variable of pSkin - you already have
Now you can make a simple thing like this, go to OnPlayerUpdate public and there:

if(PlayerInfo[playerid][pSkin] != GetPlayerSkin(playerid))
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);

And enjoy

All you have to make sure, is that when player exists or somewhere else that he disconnects, it saves his skin by setting the PlayerInfo[playerid][pSkin] in the player file.


OOPS DIDNT NOTICE IT HAD ANOTHER PAGE. ****** is the smartest so.. listen to him then

[RS]Monk
21/11/2011, 03:17 PM
I wont to make this:
I wont to make two commands,/saveskin [skinid] and /nosaveskin (when you tyre this,the skin will be save only from class selection).For example,if you tyre /saveskin 294 and go relog and on class selection you can chose any skin but when you spawn you will get skin 294.
Please help me i really need this..

Tanush123
22/11/2011, 01:21 AM
why did you add this on [ code ] remove the [ code ]

[RS]Monk
22/11/2011, 06:06 AM
i fix all,thanks for trying to help me..now i got this problem http://forum.sa-mp.com/showthread.php?t=298623