Saving health and armour
#1

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

with dini or Y_ini?
Reply
#3

dini
Reply
#4

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;
}
Reply
#5

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

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));
Reply
#7

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

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;
}
Reply
#9

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));
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)