Quote:
Originally Posted by GoldenM4
thanks all but it wont save onto the server files the score will save but the kills doesn't how do i edit my register system to save the kills and deaths onto the folder
examples of save how do i make it so it would make senence with the other get player a kill script i used
dini_IntSet(playerfile, "Level", level[playerid]);
dini_IntSet(playerfile, "Cash", GetPlayerMoney(playerid));
dini_IntSet(playerfile, "Score", GetPlayerScore(playerid));
|
This is a snippet of my code.
pawn Код:
//top of the script.
new Kills[MAX_PLAYERS];
new Deaths[MAX_PLAYERS];
//put these under OnPlayerDisconnect, it will save the players current kills/deaths when they disconnect.
//Could also place these in a timer which saves players stats every once and awhile.
dini_IntSet(playerfile, "Kills", Kills[playerid]);
dini_IntSet(playerfile, "Deaths", Deaths[playerid]);
//under OnPlayerDeath
Kills[killerid] ++; //increases the killers "kills" stats by 1
Deaths[playerid] ++; //increases the player who died "deaths" stats by 1.
//put this code when a player registers there account, e.g When a player types /register and it's sucessful.
//or if you use a dialog, place it when the register dialog is sucessful.
dini_IntSet(playerfile, "Deaths", 0);
dini_IntSet(playerfile, "Kills", 0);
//add this when a player logs into there account.
//e.g, When a player types /login and it's sucessful. or if you use dialog when the player types in the correct login password
Kills[playerid] = dini_Int(playerfile, "Kills");
Deaths[playerid] = dini_Int(playerfile, "Deaths");
//the /stats command, you could also add other stats such as admin levels/vip levels to this command if you really wanted to.
COMMAND:stats(playerid, params[])
{
new string1[126];
new plname[25];
GetPlayerName(playerid, plname, 25);
new Float:ratio=floatdiv(Kills[playerid], Deaths[playerid]); //also added in a K/D Ratio for you you can just delete it if you don't want it.
format(string1, sizeof(string1), "%s's Stats: Kills: %d, Deaths %d, K/D Ratio: %.2f", plname,Kills[playerid],Deaths[playerid],ratio);
SendClientMessage(playerid,COLOR_ORANGE, string1);
return 1;
}
//you could add other stats in here like Money by Money[playerid]; or however you saved it.
format(string1, sizeof(string1), "%s's Stats: Kills: %d, Deaths %d, K/D Ratio: %.2f,Money: %d", plname,Kills[playerid],Deaths[playerid],ratio,Money[playerid]);
//then you could also go about adding in your score saving etc, or if you already have a /stats command you could merge these together.
The code works fine on my server but this was just a copy/paste from my GM so hopefully i havn't missed anything out.
If you wanted to get the players stats that you clicked on you could do something like this
Credits to Hiddos for this tut which helped me learn this
https://sampforum.blast.hk/showthread.php?tid=158294
pawn Код:
//not sure if this code will work as i do them differently on my server but yeh, if theres any problems you should beable to work them out with the tut.
public OnPlayerClickPlayer(playerid, clickedclickedplayerid, source)
{
new string2[126];
new plname[25];
GetPlayerName(clickedplayerid, plname, 25);
new Float:ratio=floatdiv(Kills[clickedplayerid], Deaths[clickedplayerid]);
format(string2, sizeof(string2), "%s's Stats: Kills: %d, Deaths %d, K/D Ratio: %.2f", plname,Kills[clickedplayerid],Deaths[clickedplayerid],ratio);
SendClientMessage(playerid,COLOR_ORANGE, string2);
return 1;
}