Commands in radius [ REP + ]
#1

Hi guys,

I need a little help, i would really like to learn how to do something like this:

Command: /radiushp [RADIUS]

so.. this command will set all players hp to 100 which are in radius choosed in [RADIUS].

For example if admin writes /radiushp 25

All players in radius of 25 will have 100hp.

Or for example if admin writes /respawncars [RADIUS]

it will respawn all car in radius, which admin selects...

so i just need an example how that command should look with explanation that i can choose things what it should do.. whether to kill players, increase hp, respawn cars and stuff..

thanks guys
Reply
#2

Код:
COMMAND:radiushp(playerid, params[])
{
     new radius, Float:health, Float:x, Float:y, Float:z;
     if(sscanf(params, "df", radius, health)) return SendClientMessage();
     GetPlayerPos(playerid, x, y, z);

     for(new i = 0; i <= GetPlayerPoolSize(); i++) if(IsPlayerInRangeOfPoint(i, radius, x, y, z);
     {
          SetPlayerHealth(playerid, health);
     }
     return 1;
}
Код:
COMMAND:respawncars(playerid, params[])
{
     new radius, Float:x, Float:y, Float:z;
     if(sscanf(params, "d", radius)) return SendClientMessage();

     for(new i = 0; i <= GetVehiclePoolsize(); i++) if(IsPlayerInRangeOfPoint(i, radius, x, y, z);
     {
          GetVehiclePos(i, x, y, z);

          if(IsPlayerInRangeOfPoint(i, radius, x, y, z)
               return SetVehicleToRespawn(i);
     }
     return 1;
}
Reply
#3

PHP код:
CMD:radiushp(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return 0;
    new 
FloatfRadius;
    if(
sscanf(params"f"fRadius)) return SendClientMessage(playerid, -1"Syntax: /radiushp [radius]");
    new 
FloatfPlayerPos[3];
    
GetPlayerPos(playeridfPlayerPos[0], fPlayerPos[1], fPlayerPos[2]);
    for(new 
0<= GetPlayerPoolSize(); i++)
        if(
IsPlayerInRangeOfPoint(ifRadiusfPlayerPos[0], fPlayerPos[1], fPlayerPos[2]))
            
SetPlayerHealth(i100.0);
    return 
1;

@Sledgehammer, your code is wrong..
Reply
#4

Quote:
Originally Posted by J4Rr3x
Посмотреть сообщение
@Sledgehammer, your code is wrong..
What is wrong with it? It works fine for me.

If it is to do with the SendClientMessage's I was a bit too lazy to type out the params of it.
Reply
#5

Thanks guys! Repped both of you.
Reply
#6

Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
What is wrong with it? It works fine for me.

If it is to do with the SendClientMessage's I was a bit too lazy to type out the params of it.
It's to do with the fact that radius is a float, and not an integer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)