public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid == INVALID_PLAYER_ID)//They killed them self
{
SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
}
else if(gTeam[killerid] != gTeam[playerid])//They killed a opposite team member
{
SendDeathMessage(killerid,playerid,reason);
SetPlayerScore(killerid,GetPlayerScore(killerid)+2);//Killer Gains 2 Score
SetPlayerScore(playerid,GetPlayerScore(playerid)-1);//Player Loses 1 Score
}
else //else they killed someone
{
SetPlayerScore(killerid,GetPlayerScore(killerid)+2);//Killer Gains 2 Score
SetPlayerScore(playerid,GetPlayerScore(playerid)-1);//Player Loses 1 Score
SendDeathMessage(killerid,playerid,reason);
}
return 1;
}
public OnPlayerDeath(playerid, killerid)
{
SetPlayerScore(playerid,GetPlayerScore(playerid)-1); // Gives -1 point to player who died.
PlayerInfo[playerid][deaths] = PlayerInfo[playerid][deaths] +1; // Gives death point to player who died, you need to adjust this to your script
SetPlayerScore(playerid,GetPlayerScore(killerid)+2); // Gives +2 point to player who killed another player.
PlayerInfo[killerid][deaths] = PlayerInfo[killerid][kills] +1; // Gives kill point to player who killed another player, you need to adjust this to your script
}
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)); |
//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.
//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;
}