PDA

View Full Version : Explosion Damage


Amit1998
12/08/2017, 03:14 PM
Is there a way to adjust the amount of damage an explosion gives(CreateExplosion)?

FuNkYTheGreat
12/08/2017, 03:40 PM
http://wiki.sa-mp.com/wiki/Explosion_List, There are various samp explosions, You can try it some is too large or some small,
OR
A best way to adjust explosion damage is using this include
http://forum.sa-mp.com/showthread.php?t=225350
CreateExplosionEx(playerid, Float:x, Float:y, Float:z, Float:radius, Float:maxdamage, type=EXPLOSION_TYPE_MEDIUM, reason=51, playsound=true)

Amit1998
15/08/2017, 01:28 AM
http://wiki.sa-mp.com/wiki/Explosion_List, There are various samp explosions, You can try it some is too large or some small,
OR
A best way to adjust explosion damage is using this include
http://forum.sa-mp.com/showthread.php?t=225350
CreateExplosionEx(playerid, Float:x, Float:y, Float:z, Float:radius, Float:maxdamage, type=EXPLOSION_TYPE_MEDIUM, reason=51, playsound=true)

What is the playerid used for if the xyz are sent too?
I want the command to operate create an explosion on the given xyz's not on the location of a player.

xLucy
15/08/2017, 05:29 PM
stock CreateExplosionForPlayerEx(playerid, type, Float:radius, Float:damage)
{
new Float:X, Float:Y, Float:Z, Float:health, Float:armour;
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, 100);
GetPlayerPos(playerid, X, Y, Z);
CreateExplosion(X, Y, Z, type, radius);
SetPlayerHealth(playerid, health-damage);
return 1;
}

stock GetPlayerNameEx(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}

stock CreateExplosionEx(type, Float:X, Float:Y, Float:Z, Float:radius, Float:damage)
{
new Float:health, string[144], stringf[256], Float:Xx, Float:Yy, Float:Zz;
foreach(new i : Player)
{
GetPlayerHealth(i, health);
CreateExplosion(X, Y, Z, type, radius);
if(IsPlayerInRangeOfPoint(i, radius, X, Y, Z) // if there are any players in the region of the explosion it will deduct X (from the damage float) amount of health from their current health.
{
GetPlayerPos(i, Xx, Yy, Zz);
SetPlayerHealth(i, 100);
SetPlayerHealth(i, health-damage);
format(string, 144, "[explosion] %s was effected by an explosion at (X: %d) (Y: %i) (Z: %d).", GetPlayerNameEx(i), Xx, Yy, Zz);
printf(string);
}
else if(!IsPlayerInRangeOfPoint(i, radius, X, Y, Z)
{
format(string, 144, "[explosion] %s was not effected by an explosion.", GetPlayerNameEx(i));
printf(string);
if(health == health) SetPlayerHealth(i, health);
}
return 1;
}

Spent some time making this for you, xd. Word of warning, the "CreateExplosionEx" is probably unoptimized code and could be edited for it to become optimized. i'm not the best at PAWN and still learning. If you want to replace the "player was not effected by an explosion" just edit "else if(!IsPlayerInRangeOfPoint(i, radius, X, Y, Z)" and make it "else if(!IsPlayerInRangeOfPoint(i, radius, X, Y, Z) return 1;".

This wont work with armour but with a few IQ points you can easily make it work with armour using the health system already implemented. Also, this is untested code. I can only imagine that the first one will work properly.