13.02.2011, 14:45
(
Последний раз редактировалось Mauzen; 15.03.2011 в 17:57.
Причина: 1.0c
)
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:
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:
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:
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
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)
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)
Example:
pawn Код:
CreateExplosionEx(0, 123.4, 321.0, 342.1, 10.0, 250.0);
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