SA-MP Forums Archive
Saving health and armour - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving health and armour (/showthread.php?tid=256983)



Saving health and armour - Osviux - 23.05.2011

How to save health and armour of a user to that users .ini file? I want to save it just before the player disconnects.


Re: Saving health and armour - Cjgogo - 23.05.2011

with dini or Y_ini?


Re: Saving health and armour - Osviux - 23.05.2011

dini


Re: Saving health and armour - Cjgogo - 23.05.2011

nevermind here's for dini

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new pName[MAX_PLAYER_NAME];
    new string[64];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(string,sizeof(string),"/scriptfiles/Users.ini",pName);
    dini_IntSet(string,"Health",GetPlayerHealth(playerid));
    dini_IntSet(string,"Armour",GetPlayerArmour(playerid));
    return 1;
}



Re: Saving health and armour - Cjgogo - 23.05.2011

Did it work?(post comment if yes and also if no)


Re: Saving health and armour - Osviux - 23.05.2011

I tried to compile it and i get two warnings.

Код:
C:\Documents and Settings\Labas\Desktop\MPG 2.0 R2\gamemodes\MPG.pwn(125) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Labas\Desktop\MPG 2.0 R2\gamemodes\MPG.pwn(126) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Here are the lines:

Код:
    dini_IntSet(string,"Health",GetPlayerHealth(playerid));
    dini_IntSet(string,"Armour",GetPlayerArmour(playerid));



Re: Saving health and armour - Markx - 23.05.2011

Under OnPlayerDisconnect

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[128];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(string,sizeof(string),"/Users/%s.ini",pName);
    dini_IntSet(file, "Health", GetPlayerHealth(playerid));
    dini_IntSet(file, "Armour",GetPlayerArmour(playerid)]);
    return true;
}
Create a folder in scriptfiles called Users.


Re: Saving health and armour - Cjgogo - 23.05.2011

hmm i'll try to fix as it gaves same error for me and marks you wrote the same thing that I did so pls wait a few sec Osviux(I don't promise I can fix it but I'll try)

LaterI was too blind lol)

Here's working evrsion:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new pName[MAX_PLAYER_NAME];
    new string[64];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(string,sizeof(string),"/scriptfiles/Users.ini",pName);
    new Float:health;
    new Floath:armour;
    dini_IntSet(string,"Health",GetPlayerHealth(playerid,health));
    dini_IntSet(string,"Armour",GetPlayerArmour(playerid,armour));
    return 1;
}



Re: Saving health and armour - Osviux - 23.05.2011

I can only give you wanted level for comparison.

Код:
dini_IntSet(file,"Wanted",GetPlayerWantedLevel(playerid));

dini_IntSet(file,"Health",GetPlayerHealth(playerid));
dini_IntSet(file,"Armour",GetPlayerArmour(playerid));



Re: Saving health and armour - Cjgogo - 23.05.2011

yes take a look at my last post that's gonna work