How to get most Score earned. - 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)
+--- Thread: How to get most Score earned. (
/showthread.php?tid=653610)
How to get most Score earned. -
TadePoleMG - 08.05.2018
Hi mates
Can anyone help me to get highest score earned in the last of round end.
Thank You guys, help me.
rep++.
Re: How to get most Score earned. -
Amads - 08.05.2018
PHP Code:
new topscore, topplayer;
for(new id; id < MAX_PLAYERS; id++) if(GetPlayerScore(id) > topscore) topscore = GetPlayerScore(id), topplayer = id;
topplayer is the ID of a player with the most score.
Re: How to get most Score earned. -
TadePoleMG - 08.05.2018
I wanted it with a variable like Score[MAX_PLAYERS] which set to 0 OnPlayerConnect then it can be set to most scored earned by playerid in one round, then at round ends it showed with a message and resetted.
Re: How to get most Score earned. -
Dayrion - 08.05.2018
Quote:
Originally Posted by TadePoleMG
I wanted it with a variable like Score[MAX_PLAYERS] which set to 0 OnPlayerConnect then it can be set to most scored earned by playerid in one round, then at round ends it showed with a message and resetted. 
|
So do it
Re: How to get most Score earned. -
TadePoleMG - 08.05.2018
I can't can you pls
Re: How to get most Score earned. -
Dayrion - 08.05.2018
Quote:
Originally Posted by TadePoleMG
I can't can you pls 
|
Unfortunately, no. That' "Scripting help" section, not "I'll script 4 u" section.
The answer has been given previsouly (I guess, I didn't checked it). Try to understand it and, if needed, post your questions here.
Re: How to get most Score earned. -
ItsRobinson - 08.05.2018
PHP Code:
new MyScore[MAX_PLAYERS];
public OnPlayerDeath(playerid, killerid, reason) {
MyScore[killerid]++;
return 1;
}
CMD:gameover(playerid, params[])
{
new currentwinner, score, finalwinner[24], string[128];
foreach(Player, i)
{
if(MyScore(i) > score)
{
score = MyScore(i);
currentwinner = i;
}
}
GetPlayerName(currentwinner, finalwinner, sizeof(finalwinner));
format(string, sizeof(string), "%s (ID %d) has won this game with a total score of %d.", finalwinner, currentwinner, score);
return 1;
}
This a very blank way of doing it, you'll have to integrate it with your code by yourself.
(Not tested)