Wanted Help - 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: Wanted Help (
/showthread.php?tid=635226)
Wanted Help -
silverms - 03.06.2017
hey iv made an wanted system that give me the wanted reason it is working fine but when I set my friend wanted I see him on the command but if I set another one I see the new wanted without my friend so how to fix it please?
PHP код:
CMD:wanted(playerid, params[])
{
new string[256], playername[MAX_PLAYER_NAME], str[256], reas[256], mr;
for(new b=0; b<PLAYERS; b++)
{
if(GetPlayerWantedLevel(b) > 0) {
mr++;
}
}
if(mr==0) return SendClientMessage(playerid, COLOR_GREY, "There are currently no wanted players.");
for(new i; i<PLAYERS; i++)
{
if(IsPlayerConnected2(i) && GetPlayerWantedLevel(i)>0)
{
GetPlayerName(i, playername, sizeof(playername));
GetPVarString(i, "WReason", reas, sizeof(reas));
format(string, 128, "%s\n%s (ID:%d)\t%d\t%s\n",string, playername, i, GetPlayerWantedLevel(i), reas);
format(str, sizeof(str), "Name\tLevel\tReason\n%s", string);
ShowPlayerDialog2(playerid, DIALOG_WANTED, DIALOG_STYLE_TABLIST_HEADERS, "Wanted Players", str, "Done", "");
return 1;
}
}
return 1;
}
Re: Wanted Help -
GoldenLion - 03.06.2017
Quote:
Originally Posted by RahimBashovski
who is using for loop for players when u have very fast foreach...
|
I would use it if I didn't need Iter_Random and custom iterators. I don't see the point of getting foreach if all you need is a player loop.
By the way I didn't understand what's the issue, but you could do this stuff in one loop and it's better to use GetPlayerPoolSize instead of MAX_PLAYERS.
Re: Wanted Help -
silverms - 03.06.2017
it isn't from max players I think it is from the format
my problem is this loop always view one wanted player not all idk I tried a lot didn't work
Re: Wanted Help -
Abagail - 03.06.2017
You're constantly showing a new dialog and overwriting the previous. Instead, you should combine strings into a larger string and show the dialog outside of the loop.
Example:
pawn Код:
new
largestring[500],
smallstring[128],
format(smallstring, ... whatever\n)
strcat(largestring, smallstring);
// outside of loop
ShowPlayerDialog: use largestring as body text.
Make sure you end your format or whatever with \n, this is a new line in the dialog.
Re: Wanted Help -
GoldenLion - 03.06.2017
Quote:
Originally Posted by silverms
it isn't from max players I think it is from the format
my problem is this loop always view one wanted player not all idk I tried a lot didn't work
|
I never said loop was the problem I just suggested you to use GetPlayerPoolSize instead of MAX_PLAYERS in the loop lol. What Abagail said is the solution.
Re: Wanted Help -
silverms - 04.06.2017
ok I will try it and I think I found the bug I shouldn't make the dialog inside the loop xD thanks for the help