SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 13/02/2011, 02:45 PM   #1
Mauzen
Godfather
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 5,098
Reputation: 1522
Default Explosive Include V1.0b - Custom explosions

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:
Code:
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:
Code:
#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:
Code:
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

Last edited by Mauzen; 15/03/2011 at 05:57 PM. Reason: 1.0c
Mauzen is offline   Reply With Quote
Old 13/02/2011, 02:49 PM   #2
$_Pooweer_$
Big Clucker
 
Join Date: Aug 2010
Posts: 86
Reputation: 8
Default Re: Explosive Include

I liked
I will use.

(First ? riairia)
$_Pooweer_$ is offline   Reply With Quote
Old 13/02/2011, 02:53 PM   #3
XoX
Huge Clucker
 
XoX's Avatar
 
Join Date: Jun 2010
Location: Germany
Posts: 226
Reputation: 0
Default AW: Explosive Include V1.0

Sounds great.
__________________
XoX is offline   Reply With Quote
Old 13/02/2011, 03:34 PM   #4
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,290
Reputation: 137
Default Re: Explosive Include V1.0

Change
Code:
for(new i = 0; i < GetMaxPlayers(); i ++);
to
Code:
for(new i = 0,j = GetMaxPlayers(); i < j; i ++);
wups is offline   Reply With Quote
Old 13/02/2011, 05:00 PM   #5
vyper
Huge Clucker
 
vyper's Avatar
 
Join Date: Jul 2009
Location: Hell. x_x
Posts: 371
Reputation: 68
Default Re: Explosive Include V1.0

nice include
vyper is offline   Reply With Quote
Old 14/02/2011, 04:48 PM   #6
Mauzen
Godfather
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 5,098
Reputation: 1522
Default Re: Explosive Include V1.0

@wups: Oh yes, right. Your line will be a bit faster. Thanks for the tip, reupped it.
Mauzen is offline   Reply With Quote
Old 14/03/2011, 01:16 AM   #7
Th3Angel
Big Clucker
 
Join Date: Aug 2010
Posts: 102
Reputation: 0
Default Re: Explosive Include V1.0

Line 94 and 111 need to be fixed.
It is
Code:
for(new i = 0, j = GetMaxPlayers(); i < j; i ++);
but its supposed to be
Code:
for(new i = 0, j = GetMaxPlayers(); i < j; i ++)

Last edited by Th3Angel; 14/03/2011 at 03:50 AM.
Th3Angel is offline   Reply With Quote
Old 14/03/2011, 01:53 AM   #8
s1k
Huge Clucker
 
Join Date: Mar 2008
Posts: 241
Reputation: 7
Default Re: Explosive Include V1.0

Really nice. Made something like this before except it had SetDrunkLevel to give a feeling of shock.
s1k is offline   Reply With Quote
Old 14/03/2011, 03:40 PM   #9
Sasino97
High-roller
 
Sasino97's Avatar
 
Join Date: Dec 2010
Location: Italia
Posts: 1,379
Reputation: 83
Default Re: Explosive Include V1.0

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...
Sasino97 is offline   Reply With Quote
Old 14/03/2011, 03:43 PM   #10
Andrey_Kiryuhin
Little Clucker
 
Andrey_Kiryuhin's Avatar
 
Join Date: Nov 2010
Posts: 32
Reputation: 1
Default Re: Explosive Include V1.0

god job!
Andrey_Kiryuhin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Need Help] Explosive Help. Hash [NL-RP] Help Archive 3 11/05/2010 02:25 AM
Explosive Barrel Ironboy500 Help Archive 14 17/04/2010 03:59 PM
Explosive barrel bug?? MB@ Client Support 3 26/08/2009 05:39 AM


All times are GMT. The time now is 05:24 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.