SA-MP Forums Archive
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(playeridparams[])
{
     new 
string[256], playername[MAX_PLAYER_NAME], str[256], reas[256], mr;
     for(new 
b=0b<PLAYERSb++)
     {
         if(
GetPlayerWantedLevel(b) > 0) {
             
mr++;
         }
     }
     if(
mr==0) return SendClientMessage(playeridCOLOR_GREY"There are currently no wanted players.");
    for(new 
ii<PLAYERSi++)
    {
        if(
IsPlayerConnected2(i) && GetPlayerWantedLevel(i)>0)
        {
            
GetPlayerName(iplayernamesizeof(playername));
            
GetPVarString(i"WReason"reassizeof(reas));
            
format(string128"%s\n%s (ID:%d)\t%d\t%s\n",stringplayernameiGetPlayerWantedLevel(i), reas);
            
format(strsizeof(str), "Name\tLevel\tReason\n%s"string);
            
ShowPlayerDialog2(playeridDIALOG_WANTEDDIALOG_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