SA-MP Forums Archive
skin not saving/loading properly - 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: skin not saving/loading properly (/showthread.php?tid=591431)



skin not saving/loading properly - Counterafk - 11.10.2015

Hi, so basicly when I /skin it does change my skin, and if i die it sets it back to what i had. The problem is that it sets the same skin for other players. Video: https://www.youtube.com/watch?v=uZs7klonbq4

Код:
new oldskin;

CMD:skin(playerid,params[])
{
    new skinid;
    if(sscanf(params, "i", skinid)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /skin [skin ID]") ;
    if(skinid < 1 || skinid > 311) return SendClientMessage(playerid, COLOR_ORANGE, "Invalid skin ID!");
    new Jstring[128];
    format(Jstring, sizeof(Jstring), "You have set your skin ID to %i.", skinid);
    SendClientMessage(playerid, COLOR_ORANGERED, Jstring);
    SetPVarInt(playerid,"Useskin",1);
    SetPlayerSkin(playerid, skinid);
    oldskin = GetPlayerSkin(playerid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
        SetPlayerSkin(playerid, oldskin);
        return 1;
}
Help me please


Re: skin not saving/loading properly - rinori - 11.10.2015

Ok, so what you're exactly doing is this:

You're changing your own SKIN and saving it's value (ex. you set your skin ID to 5 and now the variable oldskin has value 5).

Then OnPlayerSpawn, when you spawn, you spawn with the skin read from variable oldskin.

To make it more smooth, you should make an account system, where all player informations are stored in a file/database and read from there.


Re: skin not saving/loading properly - Unte99 - 11.10.2015

Ehh... don't mind my post. I am getting a little sleepy, so I'm not thinking clearly. Did not read your code carefully.


Re: skin not saving/loading properly - Jefff - 11.10.2015

Use SetPlayerSkin + SetSpawnInfo and you dont need OnPlayerSpawn


Re: skin not saving/loading properly - Counterafk - 11.10.2015

Код:
new skin[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
	skin[playerid]=53; // sets default skin on first connect
	return 1;
}

public OnPlayerSpawn(playerid)
{
        SetPlayerSkin(playerid, skin);
	return 1;
}


CMD:skin(playerid,params[])
{
    new skinid;
    if(sscanf(params, "i", skinid)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /skin [skin ID]") ;
    if(skinid < 1 || skinid > 311) return SendClientMessage(playerid, COLOR_ORANGE, "Invalid skin ID!");
    new Jstring[128];
    format(Jstring, sizeof(Jstring), "You have set your skin ID to %i.", skinid);
    SendClientMessage(playerid, COLOR_ORANGERED, Jstring);
    SetPVarInt(playerid,"Useskin",1);
    SetPlayerSkin(playerid, skinid);
    skin[playerid] = GetPlayerSkin(playerid);
    return 1;
}
Error:
Код:
DM.pwn(365) : error 035: argument type mismatch (argument 2)
I'm a little confused


Re: skin not saving/loading properly - Unte99 - 11.10.2015

Код:
public OnPlayerSpawn(playerid)
{
        SetPlayerSkin(playerid, skin[playerid]);
	return 1;
}
Also
Код:
SetPVarInt(playerid,"Useskin",1);
if you are trying to set the skinid for the pvar, then you are doing it wrong here.

It should be:

Код:
SetPVarInt(playerid,"Useskin",skinid);



Re: skin not saving/loading properly - Counterafk - 11.10.2015

My hero! Thank you good sir!