top 3 players - 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: top 3 players (
/showthread.php?tid=658162)
top 3 players -
severance - 25.08.2018
So I've got 4 errors in one line :
PHP код:
C:\Users\fomina.janett1919\Desktop\test\gamemodes\test.pwn(7060) : error 012: invalid function call, not a valid address
C:\Users\fomina.janett1919\Desktop\test\gamemodes\test.pwn(7060) : warning 215: expression has no effect
C:\Users\fomina.janett1919\Desktop\test\gamemodes\test.pwn(7060) : error 001: expected token: ";", but found ")"
C:\Users\fomina.janett1919\Desktop\test\gamemodes\test.pwn(7060) : error 029: invalid expression, assumed zero
C:\Users\fomina.janett1919\Desktop\test\gamemodes\test.pwn(7060) : fatal error 107: too many error messages on one line
PHP код:
if(id1 != -1 && PlayerDamage[id1] != 0){ SendClientMessageToAll(-1, "*** 1st: %s with %d damage", PlayerName(id1), PlayerDamage[id1]);}
Full script:
PHP код:
stock top3players(playerid){
new id1 = -1, id2 = -1, id3 = -1, pPlayerDamage = -100, string[115];
for(new i; i < MAX_PLAYERS; i++) if(PlayerDamage[i] > pPlayerDamage && PlayerDamage[i] != 0) id1 = i;
pPlayerDamage = -100;
for(new i; i < MAX_PLAYERS; i++) if(PlayerDamage[i] > pPlayerDamage && i != id1 && PlayerDamage[i] != 0) id2 = i;
pPlayerDamage = -100;
for(new i; i < MAX_PLAYERS; i++) if(PlayerDamage[i] > pPlayerDamage && i != id2 && i != id1 && PlayerDamage[i] != 0) id3= i;
SendClientMessageToAll(-1, "{e6b3ff}*** Top 3 Players by damage");
if(id1 != -1 && PlayerDamage[id1] != 0){ SendClientMessageToAll(-1, "*** 1st: %s with %d damage", PlayerName(id1), PlayerDamage[id1]);}
else if(id2 != -1 && PlayerDamage[id2] != 0){ SendClientMessageToAll(-1, "*** 2dn: %s with %d damage", PlayerName(id1), PlayerDamage[id2]);}
else if(id3 != -1 && PlayerDamage[id3] != 0){ SendClientMessageToAll(-1, "*** 3rd: %s with %d damage", PlayerName(id1), PlayerDamage[id3]);}
return 1;
}
Re: top 3 players -
NeXTGoD - 25.08.2018
Use format bro
new str[128];
format(str, sizeof str,"*** 1st: %s with %d damage", PlayerName(id1), PlayerDamage[id1]);
SendClientMessageToAll(-1, str);
Re: top 3 players -
severance - 25.08.2018
code fucked up now
no errors but it doesn't give the player names
and damage aswell
Re: top 3 players -
NeXTGoD - 25.08.2018
Check your PlayerName stock maybe its wrong it should be like this:
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}