InRange explosion - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: InRange explosion (
/showthread.php?tid=467856)
InRange explosion -
Eugene. - 05.10.2013
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!
Re: InRange explosion -
Dragonsaurus - 05.10.2013
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.
Re: InRange explosion -
JimmyCh - 05.10.2013
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".
Re: InRange explosion -
RajatPawar - 05.10.2013
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?
Re: InRange explosion -
Eugene. - 05.10.2013
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)
Re: InRange explosion -
mendax - 05.10.2013
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;
}