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



A question. - nogh445 - 19.02.2012

pawn Код:
stock SetPlayerHealthFull()
{
 for(new i=0; i<MAX_PLAYERS;
 SetPlayerHealth(playerid, 100);
 return 1;
}
I saw that in a script and I was wondering what it is. Can anyone help?


Re: A question. - ReneG - 19.02.2012

This is a loop, but this isn't a properly working one.

pawn Код:
stock SetPlayerHealthFull()
{
 for(new i=0; i<MAX_PLAYERS; i++(
 SetPlayerHealth(i, 100);
 return 1;
}
This loops through all the players and refills their health.


Re: A question. - nogh445 - 19.02.2012

How can it be used as a command to set all players health?


Re: A question. - JhnzRep - 19.02.2012

Just do this.

pawn Код:
cmd(healall, playerid,params[])
{
for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
    SetPlayerHealth(i, 100);
    }
SendClientMessageToAll(-1, "Everyone has been healed");
}



Re: A question. - emokidx - 19.02.2012

Quote:
Originally Posted by nogh445
Посмотреть сообщение
How can it be used as a command to set all players health?
you need to call it where you want it.
like
pawn Код:
CMD:healall(playerid, params[])
{
    SetPlayerHealthFull();
    return 1;
}



Re: A question. - JhnzRep - 19.02.2012

Quote:
Originally Posted by emokidx111
Посмотреть сообщение
you need to call it where you want it.
like
pawn Код:
CMD:healall(playerid, params[])
{
    SetPlayerHealthFull();
    return 1;
}
I deleted the stock, as why do you need a stock for such a small piece of code?


Re: A question. - emokidx - 19.02.2012

Because that's what his question was.


Re: A question. - JhnzRep - 19.02.2012

I know, but still..