one question (cmd for all)
#1

I want to know how to make a command that does it to all players.
Example: /healall
I want it to heal all players
SetPlayerHealth(playerid, 100.0); <--- what do I replace playerid if I want it for all players??
Reply
#2

Loop through all the players, check if the player is connected or not, then heal. Something like

PHP код:
CMD:healall(playeridparams[])
{
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
SetPlayerHealth(i100.0);
        }
    }
    return 
1;

This is a very basic example, it just heals all the players that are online in-game and anyone can use this command. Ofcourse, you will have to modify the command to make it the way you want it and fit in your server.
Reply
#3

- Delete -
Reply
#4

I prefer foreach

PHP код:
CMD:healall(playeridparams[])
{
    foreach(
Playeri)
    {
            
SetPlayerHealth(i100.0);
        }
    return 
1;

Reply
#5

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
I prefer foreach

PHP код:
CMD:healall(playeridparams[])
{
    foreach(
Playeri)
    {
            
SetPlayerHealth(i100.0);
        }
    return 
1;

if he is using new version of then new syntax of foreach loop is

Код:
foreach(new i : Player)
Reply
#6

Quote:
Originally Posted by Humza
Посмотреть сообщение
if he is using new version of then new syntax of foreach loop is

Код:
foreach(new i : Player)
my bad xD that i am using a older version, where can i find the new version
Reply
#7

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
I prefer foreach

PHP код:
CMD:healall(playeridparams[])
{
    foreach(
Playeri)
    {
            
SetPlayerHealth(i100.0);
        }
    return 
1;

Well, he didn't even know the default looping method, so i wouldn't recommend him using foreach since its an addon to the server.
Reply
#8

Quote:
Originally Posted by Sjn
Посмотреть сообщение
Loop through all the players, check if the player is connected or not, then heal. Something like

PHP код:
CMD:healall(playeridparams[])
{
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
SetPlayerHealth(i100.0);
        }
    }
    return 
1;

This is a very basic example, it just heals all the players that are online in-game and anyone can use this command. Ofcourse, you will have to modify the command to make it the way you want it and fit in your server.
Thanks just what I was looking for +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)