InRange explosion
#1

Hello. I need a script that makes a person blow up if he gets in range of 10 meters of some coordonates! Could somebody help me out with this ? Thank you!
Reply
#2

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, yourx, youry, yourz))   // Change the yourx, youry and yourz to the coordinates you want to use for the explosion point.
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        CreateExplosion(x, y, z, 0, 10.0);
    }
    return 1;
}
You can also do it with a timer.
Note: This code will explode many times per second, not only once, if player is in range of that point.
Reply
#3

Well we can do that in many ways..
One of the ways would be: (Just giving an example now).
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 10, X, Y, Z)) // Change X Y Z to the coordinates you wanted.
{
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(i, PosX, PosY, PosZ);
CreateExplosion(PosX, PosY, PosZ, type, radius) // Change type and radius to your needs, scroll down for the "type" link.
}
}
Click here for the list of "types".
Reply
#4

pawn Код:
new bool: explosion_BOOL[ MAX_PLAYERS ];

public OnPlayerUpdate( playerid )
{
      if(IsPlayerInRangeOfPoint(playerid, 10, MY_X, MY_Y, MY_Z)  
      {
          if( explosion_BOOL[ playerid ] ) return 1;
          new Float:x, Float:y, Float:z;
          GetPlayerPos(playerid, x, y, z);
          CreateExplosion(x, y, z, 0, 10.0);
      }
      return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, MY_X, MY_Y, MY_Z)  
      {
          if( killerid == INVALID_PLAYER_ID )
          {
              if( reason == 51 ) return (explosion_BOOL[playerid] = true );
           }
       }
      return 1;
}
Explodes until the player dies? Reset it whenever you need it or something.. OnPlayerSpawn?
Reply
#5

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
Well we can do that in many ways..
One of the ways would be: (Just giving an example now).
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 10, X, Y, Z)) // Change X Y Z to the coordinates you wanted.
{
new Float:PosX, Float:PosY, Float:PosZ;
GetPlayerPos(i, PosX, PosY, PosZ);
CreateExplosion(PosX, PosY, PosZ, type, radius) // Change type and radius to your needs, scroll down for the "type" link.
}
}
Click here for the list of "types".

Tried this one. It worked like this: exploded the person around 9 times and after that didn't worked anymore. Not for any of the players - (9 players were on the moment of explosion)
Reply
#6

You can use CreateDynamicSphere. (You'll need Incognito's streamer plugin.)

pawn Код:
new explosionarea;

public OnGameModeInit() {
    explosionarea = CreateDynamicSphere(explosion x, explosion y, explosion z, 10.0);
    return 1;
}

public OnPlayerEnterDynamicArea(playerid, areaid) {
    if(areaid == explosionarea) {
        // things & stuff
        CreateExplosion(explosion x, explosion y, explosion z, type, radius);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)