SA-MP Forums Archive
loop - 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: loop (/showthread.php?tid=657609)



loop - cdoubleoper - 11.08.2018

loops in samp are weird. it's supposed to show the client message if the dialog is empty (no players with wanted level) but it shows up no matter what. what is going on? :<

Код:
		if(GetPlayerWantedLevel(i) > 0)
		{
			format(strx, 64, "%s (ID: %d)\n", name, i);
			strcat(stry, strx);
			
			ShowPlayerDialog(playerid, boop1, DIALOG_STYLE_LIST, "wanted", stry, "OK", "");
		}
		else if(GetPlayerWantedLevel(i) < 1)
		{
			SendClientMessage(playerid, -1, "boop no wanted");
			break;
		}



Re: loop - KinderClans - 11.08.2018

pawn Код:
if(GetPlayerWantedLevel(i) >= 1)
        {
            format(strx, 64, "%s (ID: %d)\n", name, i);
            strcat(stry, strx);
           
            ShowPlayerDialog(playerid, boop1, DIALOG_STYLE_LIST, "wanted", stry, "OK", "");
        }
        else return SendClientMessage(playerid, -1, "boop no wanted");



Re: loop - cdoubleoper - 11.08.2018

It won't make a difference :<


Re: loop - Kraeror - 11.08.2018

Show us more like the loop maybe?


Re: loop - KinderClans - 11.08.2018

Quote:
Originally Posted by cdoubleoper
Посмотреть сообщение
It won't make a difference :<
Do you tried?


Re: loop - cdoubleoper - 11.08.2018

Quote:
Originally Posted by Kraeror
Посмотреть сообщение
Show us more like the loop maybe?
It's everything in this simple loop
Код:
for(new i = 0; i < MAX_PLAYERS; i++)



Re: loop - Florin48 - 11.08.2018

Quote:

new x=0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerWantedLevel(i) > 0)
{
format(strx, 64, "%s (ID: %d)\n", name, i);
strcat(stry, strx);
x++;
ShowPlayerDialog(playerid, boop1, DIALOG_STYLE_LIST, "wanted", stry, "OK", "");
}
}
if(x==0) SendClientMessage(playerid, -1, "boop no wanted");

try now


Re: loop - cdoubleoper - 11.08.2018

This is pointless. There has to be a proper way to do it in pawn.


Re: loop - Florin48 - 11.08.2018

use foreach, Iterator and Iter_Count


Re: loop - NeXTGoD - 11.08.2018

Код:
	new Iterator:wanted<10>; 
	foreach(new i : wanted) 
	{
		if(GetPlayerWantedLevel(i) > 0)
		{
			Iter_Add(wanted, 1); 
		}
		if(!Iter_Count(wanted))return SendClientMessage(playerid, -1, "boop no wanted");
		else
		{
			Iter_Clear(wanted);
			foreach(new i : wanted)
			{
				if(GetPlayerWantedLevel(i) > 0)
				{
					Iter_Add(wanted, 1); 
					format(strx, 64, "%d. %s (ID: %d)\n",Iter_Count(wanted), name, i);
					strcat(stry, strx);
				}
			}
			ShowPlayerDialog(playerid, boop1, DIALOG_STYLE_LIST, "wanted", stry, "OK", "");
		}
	}