SA-MP Forums Archive
for all 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: for all help (/showthread.php?tid=290459)



for all help - mike_1 - 15.10.2011

hi guys i have got a question..How can i;Example Give to everyone money or heal everyone in the server whats the code to give somethink to everyone in the server??


Re: for all help - SmiT - 15.10.2011

Loop
pawn Код:
for ( new i = 0; i < MAX_PLAYERS; i ++ )
{
    GivePlayerMoney( i, 1000 ) ; // Give all players $1000
}



Re: for all help - Kush - 15.10.2011

PHP код:
for(new 0MAX_PLAYERSi++) { GivePlayerMoney(ival); } 



Re: for all help - Josma_cmd - 15.10.2011

Quote:
Originally Posted by SmiT
Посмотреть сообщение
Loop
pawn Код:
for ( new i = 0; i < MAX_PLAYERS; i ++ )
{
    GivePlayerMoney( i, 1000 ) ; // Give all players $1000
}
This code more optimized:
pawn Код:
for(new i, PP = GetMaxPlayers(); i < PP; i++)
{
    if(!IsPlayerConnected(i)) continue;
    GivePlayerMoney(i, 1000);
}

//Or

#define GiveAllMoney(%0) for(new i,PP=GetMaxPlayers;i<PP;i++), GivePlayerMoney(i,%0)



Re : for all help - Naruto_Emilio - 15.10.2011

What command processor are you using?. zcmd, or what.. string compare?


Re: for all help - SuperViper - 15.10.2011

pawn Код:
#include <foreach>

foreach(Player, i) {
    SetPlayerHealth(i, 100);
}
This is faster and it'll set all players health to 100.


Re: for all help - mike_1 - 17.10.2011

none of them warks!! i made a new command:
Код:
  if (strcmp("/Healall", cmdtext, true, 10) == 0)
	{
	if(IsPlayerAdmin(playerid))	{
	for(new i, PP = GetMaxPlayers(); i < PP; i++)
	{
	if(!IsPlayerConnected(i)) continue;
	GivePlayerMoney(i, 1000);
	GameTextForPlayer(playerid,"~g~1000 money for all!",5000,4);
	}
	}else SendClientMessage(playerid,by,"Sorry Only admins can give money to everyone");
Well i checked my money and npc's money but nothing changed!
How can i fix it another code?