skin not saving/loading properly
#1

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
Reply
#2

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.
Reply
#3

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

Use SetPlayerSkin + SetSpawnInfo and you dont need OnPlayerSpawn
Reply
#5

Код:
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
Reply
#6

Код:
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);
Reply
#7

My hero! Thank you good sir!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)