Wanted list - 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: Wanted list (
/showthread.php?tid=192836)
Wanted list -
zack3021 - 23.11.2010
I made i wanted list and placed it into a MSGBOX (dialog), it works and all but when i type /wanted in game, it just shows the name of the last player that i set wanted to.
So if A, B and C are wanted, it only shows C.
pawn Код:
COMMAND:wanted(playerid, params[])
{
new count, namestr[64];
for(new i; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i) || i == INVALID_PLAYER_ID)continue;
if(GetPlayerWantedLevel(i)!=0)
{
count++;
GetPlayerName(i,namestr,MAX_PLAYER_NAME);
format(namestr,64,"%s level: %d",namestr,GetPlayerWantedLevel(i));
ShowPlayerDialog(playerid,500, DIALOG_STYLE_MSGBOX, "Wanted List.",namestr,"Ok", "Cancel");
}
}
if(count == 0)return SendClientMessage(playerid,White,"There are no wanted Players");
return 1;
}
Re: Wanted list -
cessil - 23.11.2010
that's because you're getting the players name and then showing it in a dialog instead of getting all the names and putting them in a string and then putting that into a dialog
pawn Код:
COMMAND:wanted(playerid, params[])
{
new count, namestr[MAX_PLAYER_NAME], string[128];//64 is too much since the max length of a name is like ~20
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerWantedLevel(i)!=0)
{
count++;
GetPlayerName(i,namestr,MAX_PLAYER_NAME);
if(!strlen(string))
{
format(string,sizeof(string),"%s level: %d",namestr,GetPlayerWantedLevel(i));
}
else
{
format(string,sizeof(string),"\n%s level: %d",namestr,GetPlayerWantedLevel(i));
}
}
}
}
//also you'd use ShowPlayerDialog outside of the loop, just after it's finished
ShowPlayerDialog(playerid,500, DIALOG_STYLE_MSGBOX, "Wanted List.",string,"Ok", "Cancel");
if(count == 0)return SendClientMessage(playerid,White,"There are no wanted Players");
return 1;
}
Re: Wanted list -
zack3021 - 24.11.2010
Still shows one player in the MSGBOX.