05.10.2013, 11:08
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!
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;
}
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.
}
}
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;
}
Well we can do that in many ways..
One of the ways would be: (Just giving an example now). 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;
}