[Include] Explosive Include V1.0
#1

V1.0c

My last release was quite a long time ago. Today I spontaneously decided to create a small script for custom explosions, especially for 0.3c.

Basically, this is just one function: CreateExplosionEx. It expands the functions of the normal CreateExplosion a lot, with features like assigning explosion kills to players or adjusting damage and radius (in contrast to the normal CreateExplosion this works)
As always I paid attention to customizability, and also to compatibility. This should work with a streamer and also takes advantages of the foreach include, but you do not need them. It detects if they are included, and so also works if you do not have them.

Syntax:
Well, here are the details of the function:
pawn Код:
CreateExplosionEx(playerid, Float:x, Float:y, Float:z, Float:radius, Float:maxdamage, type=EXPLOSION_TYPE_MEDIUM, reason=51, playsound=true)
playerid: "Owner" of the explosion. If the explosion kills a player, this is assigned to this player. Set it to -1 to assign it to no player.
x/y/z: coordinates of the explosion, just like for the normal function
radius: the maximum radius of the explosion in which players/vehicles will get damaged
maxdamage: the maximum damage the explosion will deal. The taken damage depends on the distance of a player/vehicle to the explosion
type: determines the explosion model (supported types follow after this list)
reason: the death reason, like the reason in OnPlayerDeath (determines the icon in SendDeathReason)
playsound: if true, the explosion will make noise, if false it wont.


Available explosion types:
pawn Код:
#define EXPLOSION_TYPE_FUEL_CAR                     (0)
#define EXPLOSION_TYPE_LARGE                        (1)
#define EXPLOSION_TYPE_MEDIUM                       (2)
#define EXPLOSION_TYPE_MOLOTOV                      (3)
#define EXPLOSION_TYPE_SMALL                        (4)
#define EXPLOSION_TYPE_TINY                         (5)
The damage for vehicles is multiplied with 2.5. Please note, that (for better performance) only occupied vehicles will take damage, just like in normal SA-MP.

Example:
pawn Код:
CreateExplosionEx(0, 123.4, 321.0, 342.1, 10.0, 250.0);
Installation
Save the pastebin code as explosives.inc in your include folder and add #include <explosives> to the top of your script.
To use it, add EXPL_main() somewhere in your gamemodes main() or OnGameModeInit() function, and add EXPL_OnPlayerDeath(playerid, killerid, reason) at the top (important!) of your OnPlayerDeath function.
Now you can use CreateExplosionEx as you like.


Thats it, I hope some people might find this useful, as you cant really use the normal CreateExplosion for some things.
I might update this with more functions later. If some people are interested, I could add a knockback feature (throwing players and vehicles away from explosions) or scripted fire (explosions set the ground/players on fire like some normal explosion types)

So here is the link, please note the comment header: http://pastebin.com/ZZGa5pBR (warning: pastebin does not like my indentation)

Changelog:
1.0: Initial release
1.0b: Small performance fix, thanks to wups
1.0c: Another small but stupid mistake, thanks to Th3Angel
Reply
#2

I liked
I will use.

(First ? riairia)
Reply
#3

Sounds great.
Reply
#4

Change
pawn Код:
for(new i = 0; i < GetMaxPlayers(); i ++);
to
pawn Код:
for(new i = 0,j = GetMaxPlayers(); i < j; i ++);
Reply
#5

nice include
Reply
#6

@wups: Oh yes, right. Your line will be a bit faster. Thanks for the tip, reupped it.
Reply
#7

Line 94 and 111 need to be fixed.
It is
pawn Код:
for(new i = 0, j = GetMaxPlayers(); i < j; i ++);
but its supposed to be
pawn Код:
for(new i = 0, j = GetMaxPlayers(); i < j; i ++)
Reply
#8

Really nice. Made something like this before except it had SetDrunkLevel to give a feeling of shock.
Reply
#9

I ve already used the "CreateExplosionEx" name in one of my script, but it's a different thing... But don't worry, nobody downloaded my sucking function Look, I am the only that wrote something in this post...
Reply
#10

god job!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)