Heal all
#1

Hello everyone.
Can someone tell me the function of Heal all ?
I mean Set all players health to 100.

I'm beginner, So i don't know how to do this..
Reply
#2

This ? :
Код:
CMD:healall(playerid, params[])
{
	new str[128];
	if(PlayerInfo[playerid][Admin] >= 1)
	{
		foreach(Player, i)
		{
			if(IsPlayerConnected(i) && (i != playerid) && (PlayerInfo[playerid][Admin] < PlayerInfo[i][Admin]))
			{
				SetPlayerHealth(i, 100.0);
			}
		}
		GameTextForAll("~g~Healed by ~w~Admin!", 3000, 3);
		format(str, sizeof(str), "- AS - %s(%d) has healed all players!", GetName(playerid), playerid);
		SendClientMessageToAll(COLOR_BLUE, str);
		SendClientMessage(playerid, COLOR_LIME, "You healed all players!");
	}
	return 1;
}
Reply
#3

Create a loop, check if player is connected (or use foreach) and set his health to 100.

@kirostar: Giving him your code it doesn't mean that is going to work in everyone. I'm pretty sure that he will have errors.
Reply
#4

pawn Код:
CMD:healall(playerid, params[]) //Create a command (you need ZCMD/y_commands to do this thing)
{
    for(new i = 0; i < GetMaxPlayers(); i++) //Looping to all players
    {
        if(IsPlayerConnected(i)) //Check if player are connected
        {
            SetPlayerHealth(i, 100); //Set player health to 100
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by kirostar
Посмотреть сообщение
This ? :
Код:
CMD:healall(playerid, params[])
{
	new str[128];
	if(PlayerInfo[playerid][Admin] >= 1)
	{
		foreach(Player, i)
		{
			if(IsPlayerConnected(i) && (i != playerid) && (PlayerInfo[playerid][Admin] < PlayerInfo[i][Admin]))
			{
				SetPlayerHealth(i, 100.0);
			}
		}
		GameTextForAll("~g~Healed by ~w~Admin!", 3000, 3);
		format(str, sizeof(str), "- AS - %s(%d) has healed all players!", GetName(playerid), playerid);
		SendClientMessageToAll(COLOR_BLUE, str);
		SendClientMessage(playerid, COLOR_LIME, "You healed all players!");
	}
	return 1;
}
Thank you.


Can you give me same but Remove the admin level 1 permissions, And replace it with IsPlayerAdmin please.
Reply
#6

Код:
CMD:healall(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        SendClientMessageToAll(COLOR_GREEN, "All players healed by Admin");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            SetPlayerHealth(i, 100.0);
        }
    }
    else SendClientMessage(playerid,COLOR_RED,"You are not Admin!");
    return true;
}
Try this.
Reply
#7

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
Create a loop, check if player is connected (or use foreach) and set his health to 100.
i dont think a newbee (as he claimed to be) knows what a loop or even foreach is but i understand that you are trying to make him learn.

@ aCloudy

here is more about loops ; https://sampwiki.blast.hk/wiki/Loop

if you have a loop like this;
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
basicly your code could look like this;
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
SetPlayerHealth( i , 100);
just put that in a command..you can call it healall or whatever..

SetPlayerHealth has usually playerid..the playerid has been replaced with an 'i' as you can see. The loop makes it possible that ' i ' area playerids threw all players.

you can loop threw alot more ..for example;

pawn Код:
for(new i = 0; i < MAX_VEHICLES; i++)
loops threw all vehicles...see how it works ?
Reply
#8

Quote:
Originally Posted by AIped
Посмотреть сообщение
i dont think a newbee (as he claimed to be) knows what a loop or even foreach is but i understand that you are trying to make him learn.
This is not script request. This is Scripting Help. Also, if you code it for him, he is probably not going to learn and when he will need something again, he will post here and wait for someone to code it for him.

In case you want someone to code it for you, then use the right section.
Reply
#9

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
This is not script request. This is Scripting Help. Also, if you code it for him, he is probably not going to learn and when he will need something again, he will post here and wait for someone to code it for him.

In case you want someone to code it for you, then use the right section.
Exactly! thats why im explaining things to him instead of showing him a command. If he still trying to get answers elsewhere. I explained a bit because if a newbee reads about things he wont understand he will ask again anyways.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)