DM game, most kills wins... But what about when its a draw... - 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: DM game, most kills wins... But what about when its a draw... (
/showthread.php?tid=72926)
DM game, most kills wins... But what about when its a draw... -
Outbreak - 11.04.2009
I've made a DM script, the winner is the one with the most kills..
Though, if theres 2 players who have both killed the same amount of players.. The player with the lowest id would win..
So id 5 has 10 kills, id 6 has 10 kills. id 5 would be declared the winner...
How can i do a check, so if players have killed the same amount of players each, it would be declared as a draw, and the prize money split between them?
Re: DM game, most kills wins... But what about when its a draw... -
tom_jonez - 11.04.2009
i think i would do:
pawn Код:
public GetWinners()
{
new highestkill = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(Kills[i] > highestkill) highestkill = Kills[i];
}
new winnercount = 0;
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(Kills[p] == highestkill)
{
Winner[p] = 1;
winnercount++;
}
}
new prize = cashprize/winnercount;
for(new a = 0; a < MAX_PLAYERS; a++)
{
if(Winner[a]) GivePlayerMoney(a,prize);
}
return 1;
}
public OnPlayerDeath(playerid,killerid,reason)
{
Kills[killerid] ++;
return 1;
}