dini_Float help -
Danny - 14.08.2010
Hello,
My login script is acting very weird since i added this. If you login, it will load everything correctly, but if you restart the server the player's position and health won't load. When that happens, the player get teleported to the 0-point of San Andreas, and he will die cause his health and armor is set to 0. My conclusion is that maybe dini_Float returns 0 instead of the right value's. Here you have my code:
Код:
public Loadmorestats(playerid)
{
new Float:POS[3];
GetPlayerName(playerid, pname, sizeof (pname));
skin[playerid] = dini_Int((pname), "skin");
POS[0] = dini_Float((pname), "spawnX");
POS[1] = dini_Float((pname), "spawnY");
POS[2] = dini_Float((pname), "spawnZ");
new Float:hp2 = dini_Float((pname),"health");
new Float:am2 = dini_Float((pname),"armour");
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, POS[0], POS[1], POS[2]);
SetPlayerHealth(playerid, floatround(hp2));
SetPlayerArmour(playerid, floatround(am2));
SetPlayerSkin(playerid, skin[playerid]);
TogglePlayerControllable(playerid,1);
return 1;
}
Note: All things without float load correctly. Please tell me what's wrong.
Greetz,
Danny
Re: dini_Float help -
Danny - 14.08.2010
bump, i really need some help cuz my server is running already online and this bug is VERY annoying.
Re: dini_Float help -
armyoftwo - 14.08.2010
just don't restart with GMX it's buggy as hell
Re: dini_Float help -
Cameltoe - 14.08.2010
Cause when player disconnects @ GMX the players pos gets set to 0,0,0 then saves.
Show me the "savemorestats" function.
Re: dini_Float help -
Vince - 14.08.2010
Why'd you want to floatround something that's supposed to be a float?
Also, learn how to debug. Add prints and see if the functions actually return something.
Re: dini_Float help -
MrDeath537 - 14.08.2010
Maybe because the file doesn't exists?
Or the spawnX/Y/Z value is 0.0...
Re: dini_Float help -
Cameltoe - 14.08.2010
The xyz value is 0 when player disconnects @ GMX. post the public Savemorestats(playerid) i'll edit it to work.
Re: dini_Float help -
Danny - 14.08.2010
@armyoftwo: Sometimes you have no choice, if you want to change something in the script F.E
@Cameltoe: Hmm, maybe i can make a timer that gives the server some time to save the coords.
And here you have the savescript:
Код:
public SavePlayerStats(playerid)
{
new Float:hp;
new Float:am;
new Float:saveX, Float:saveY, Float:saveZ;
GetPlayerName(playerid, pname, sizeof (pname));
GetPlayerHealth(playerid,hp);
GetPlayerArmour(playerid,am);
GetPlayerPos(playerid, saveX, saveY, saveZ);
money[playerid] = GetPlayerMoney(playerid);
SaveWeaponsToFile(playerid);
dini_IntSet((pname), "money", money[playerid]);
dini_IntSet((pname), "kills", kills[playerid]);
dini_IntSet((pname), "deaths", deaths[playerid]);
dini_IntSet((pname), "bankmoney", bankmoney[playerid]);
dini_IntSet((pname), "beer", beer[playerid]);
dini_IntSet((pname), "cigarets", cigarets[playerid]);
dini_IntSet((pname), "carlocks", carlocks[playerid]);
dini_IntSet((pname), "sprunk", sprunk[playerid]);
dini_IntSet((pname), "rope", rope[playerid]);
dini_FloatSet((pname), "health", floatround(hp));
dini_FloatSet((pname), "armour", floatround(am));
dini_FloatSet((pname),"spawnX", saveX);
dini_FloatSet((pname),"spawnY", saveY);
dini_FloatSet((pname),"spawnZ", saveZ);
dini_IntSet((pname), "weed", weed[playerid]);
dini_IntSet((pname), "seeds", seeds[playerid]);
dini_IntSet((pname), "prepaid", prepaid[playerid]);
return 1;
}
@Vince: Yeah, youre right, it look like a bit stupid now
@MrDeath: Im sure the files exist, i always check the files before testing
Re: dini_Float help -
Cameltoe - 14.08.2010
GetPlayerPos(playerid, saveX, saveY, saveZ);
if(saveX != 0 && saveY != 0 && saveZ != 0)
{
dini_FloatSet((pname),"spawnX", saveX);
dini_FloatSet((pname),"spawnY", saveY);
dini_FloatSet((pname),"spawnZ", saveZ);
}
else SendClientMessage(playerid, COLOR, "The pos = 0.. the position werent saved!");
Make a timer that saves the pos every 5/30 sec and u have a fix!
Re: dini_Float help -
Claude - 14.08.2010
You are now saving it on the playername.. You should save it in an scriptfile, for example:
pawn Код:
new file[100];
format(file, 100, "accounts/%s.ini", pname);
dini_IntSet(file, "money", money[playerid]);