[Help] Skin saving problem. -
BornHuman - 28.10.2013
I'm almost there! But I am having a bit of a problem with my DINI skin saving system. I don't get any errors but when I click "spawn" when I go on my server it automatically sets my skin to '0' or CJ. Even though I did /setskin 59 or a normal PED.
Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[128], pname[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
new Float:health;
new Float:armour;
new playerskin = GetPlayerSkin(playerid);
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "USERFILES/%s.ini", pname);
if(dini_Exists(file))
{
GetPlayerPos(playerid, x, y, z);
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armour);
dini_FloatSet(file, "CoordinateX", x);
dini_FloatSet(file, "CoordinateY", y);
dini_FloatSet(file, "CoordinateZ", z);
dini_FloatSet(file, "Health", health);
dini_FloatSet(file, "Armour", armour);
dini_FloatSet(file, "Skin", playerskin);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
new file[128], pname[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
new Float:health;
new Float:armour;
new playerskin = GetPlayerSkin(playerid);
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "USERFILES/%s.ini", pname);
if(!dini_Exists(file))
{
dini_Create(file);
return 1;
}
else if(dini_Exists(file))
{
x = dini_Float(file, "CoordinateX");
y = dini_Float(file, "CoordinateY");
z = dini_Float(file, "CoordinateZ");
health = dini_Float(file, "Health");
armour = dini_Float(file, "Armour");
dini_FloatSet(file, "Skin", playerskin);
SetPlayerPos(playerid, x, y, z);
SetPlayerHealth(playerid, health);
SetPlayerArmour(playerid, armour);
SetPlayerSkin(playerid, playerskin);
return 1;
}
return 1;
}
This was my previous thread:
https://sampforum.blast.hk/showthread.php?tid=472353
He kindly told me what to set it as, so I removed my 'AddPlayerClass' (meaning there are no class's now) I'm not sure if this is the problem, or if I should define new playerskin = GetPlayerSkin(playerid); globally and use this as a class. But if this is what I should do let me know, thank you!
Re: [Help] Skin saving problem. -
]Rafaellos[ - 28.10.2013
Why save the skin as float? And when you try to load it, you save it again.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[128], pname[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
new Float:health;
new Float:armour;
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "USERFILES/%s.ini", pname);
if(dini_Exists(file))
{
GetPlayerPos(playerid, x, y, z);
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armour);
dini_FloatSet(file, "CoordinateX", x);
dini_FloatSet(file, "CoordinateY", y);
dini_FloatSet(file, "CoordinateZ", z);
dini_FloatSet(file, "Health", health);
dini_FloatSet(file, "Armour", armour);
dini_IntSet(file, "Skin", GetPlayerSkin(playerid));
}
return 1;
}
public OnPlayerSpawn(playerid)
{
new file[128], pname[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
new Float:health;
new Float:armour;
new playerskin;
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "USERFILES/%s.ini", pname);
if(!dini_Exists(file))
{
dini_Create(file);
}
else
{
x = dini_Float(file, "CoordinateX");
y = dini_Float(file, "CoordinateY");
z = dini_Float(file, "CoordinateZ");
health = dini_Float(file, "Health");
armour = dini_Float(file, "Armour");
playerskin = dini_Int(file, "Skin");
SetPlayerPos(playerid, x, y, z);
SetPlayerHealth(playerid, health);
SetPlayerArmour(playerid, armour);
SetPlayerSkin(playerid, playerskin);
}
return 1;
}
Re: [Help] Skin saving problem. -
SAMProductions - 28.10.2013
Quote:
Originally Posted by ]Rafaellos[
Why save the skin as float? And when you try to load it, you save it again.
pawn Код:
public OnPlayerDisconnect(playerid, reason) { new file[128], pname[MAX_PLAYER_NAME]; new Float:x, Float:y, Float:z; new Float:health; new Float:armour;
GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(file), "USERFILES/%s.ini", pname);
if(dini_Exists(file)) { GetPlayerPos(playerid, x, y, z); GetPlayerHealth(playerid, health); GetPlayerArmour(playerid, armour); dini_FloatSet(file, "CoordinateX", x); dini_FloatSet(file, "CoordinateY", y); dini_FloatSet(file, "CoordinateZ", z); dini_FloatSet(file, "Health", health); dini_FloatSet(file, "Armour", armour); dini_IntSet(file, "Skin", GetPlayerSkin(playerid)); } return 1; }
public OnPlayerSpawn(playerid) { new file[128], pname[MAX_PLAYER_NAME]; new Float:x, Float:y, Float:z; new Float:health; new Float:armour; new playerskin;
GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(file), "USERFILES/%s.ini", pname);
if(!dini_Exists(file)) { dini_Create(file); } else { x = dini_Float(file, "CoordinateX"); y = dini_Float(file, "CoordinateY"); z = dini_Float(file, "CoordinateZ"); health = dini_Float(file, "Health"); armour = dini_Float(file, "Armour"); playerskin = dini_Int(file, "Skin"); SetPlayerPos(playerid, x, y, z); SetPlayerHealth(playerid, health); SetPlayerArmour(playerid, armour); SetPlayerSkin(playerid, playerskin); } return 1; }
|
Agree with ]Rafaellos[, im sorry i was wrong, because it is dini_Int not Float.
Re: [Help] Skin saving problem. -
RowdyrideR - 28.10.2013
If you're new to scripting, I suggest you to use this
https://sampforum.blast.hk/showthread.php?tid=175565
Better than dini... *just saying*
Re: [Help] Skin saving problem. -
Pottus - 28.10.2013
Here is the deal dude dini is prehistoric you should spend some time learning use to sqlite or mysql read through this.
https://sampforum.blast.hk/showthread.php?tid=449536
Re: [Help] Skin saving problem. -
BornHuman - 28.10.2013
Quote:
Originally Posted by ]Rafaellos[
Why save the skin as float? And when you try to load it, you save it again.
pawn Код:
public OnPlayerDisconnect(playerid, reason) { new file[128], pname[MAX_PLAYER_NAME]; new Float:x, Float:y, Float:z; new Float:health; new Float:armour;
GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(file), "USERFILES/%s.ini", pname);
if(dini_Exists(file)) { GetPlayerPos(playerid, x, y, z); GetPlayerHealth(playerid, health); GetPlayerArmour(playerid, armour); dini_FloatSet(file, "CoordinateX", x); dini_FloatSet(file, "CoordinateY", y); dini_FloatSet(file, "CoordinateZ", z); dini_FloatSet(file, "Health", health); dini_FloatSet(file, "Armour", armour); dini_IntSet(file, "Skin", GetPlayerSkin(playerid)); } return 1; }
public OnPlayerSpawn(playerid) { new file[128], pname[MAX_PLAYER_NAME]; new Float:x, Float:y, Float:z; new Float:health; new Float:armour; new playerskin;
GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(file), "USERFILES/%s.ini", pname);
if(!dini_Exists(file)) { dini_Create(file); } else { x = dini_Float(file, "CoordinateX"); y = dini_Float(file, "CoordinateY"); z = dini_Float(file, "CoordinateZ"); health = dini_Float(file, "Health"); armour = dini_Float(file, "Armour"); playerskin = dini_Int(file, "Skin"); SetPlayerPos(playerid, x, y, z); SetPlayerHealth(playerid, health); SetPlayerArmour(playerid, armour); SetPlayerSkin(playerid, playerskin); } return 1; }
|
REP+