[Help]Life
#1

someone help me do cmd: life for whom this near

Код:
CMD:lifep(playerid, params[])
	{
                for(new i=0;i<MAX_PLAYERS;i++)
		SetPlayerHealth(i, 100);
   		return true;
	}
is giving life to all the server
Reply
#2

Try this

PHP код:
CMD:lifep(playeridparams[])
    {
        
SetPlayerHealth(playerid100);
           return 
1;
    } 
Reply
#3

He said that he wants to give health for everyone who's near the player who did the command.

PHP код:
CMD:lifep(playeridparams[])
{
    new 
i;
    for(; 
MAX_PLAYERS; ++i)
    {
        if(
IsPlayerConnected(playerid))
       {
            new 
Float:XFloat:YFloat:Z;
            
GetPlayerPos(playeridXYZ);
            if(
IsPlayerInRangeOfPoint(iXYZ5.0))
            {
                 
SetPlayerHealth(iGetPlayerHealth(i)+100.0);
            }
       }
    }
    return 
1;

Remember, when you create a variable, It's value is zero, It will have another value only if you set it to another value, and try to create a variable to use on "for's" before using It, It's faster that way.
Reply
#4

Detoria's code is well ... flawed to the point of not working, I'll try to optimize and fix it
but credits to him for trying
PHP код:
CMD:lifep(playeridparams[])
{
    new 
Float:XFloat:YFloat:Z;
    
GetPlayerPos(playeridXYZ);
    for(new 
iMAX_PLAYERSi++)
    {
            if(
IsPlayerInRangeOfPoint(i5.0XYZ))
                 
SetPlayerHealth(i100.0);
    }
    return 
1;

A couple notes ^
A) when a player does the cmd, he IS connected, there is no need to check
B) natives have a built-in connected check, so just use SetPlayerHealth, if it fails he is not connected
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)