Reduce damage ...? - 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: Reduce damage ...? (
/showthread.php?tid=561319)
Reduce damage ...? -
Metharon - 02.02.2015
Ok , i'm trying to create a damage system..
When the player have weapon skill == 1 te reduce game 50%
when is == 5 to don't reduce.
As you can see in the screen i upgraded my weapon skill to 2 , and the damage still 46 was... how can i make it works ?
This is my system
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
new string[128], victim[MAX_PLAYER_NAME], attacker[MAX_PLAYER_NAME];
new weaponname[24];
GetPlayerName(playerid, attacker, sizeof (attacker));
GetPlayerName(damagedid, victim, sizeof (victim));
GetWeaponName(weaponid, weaponname, sizeof (weaponname));
format(string, sizeof(string), "%s has made %.0f damage to %s, weapon: %s", attacker, amount, victim, weaponname);
SendClientMessageToAll(0xFFFFFFFF, string);
new Float:HP;
GetPlayerHealth(damagedid, HP);
new Float: newamount;
if(PlayerInfo[playerid][WeaponSkills] == 1)
{
newamount = amount - 50;
}
if(PlayerInfo[playerid][WeaponSkills] == 2) { newamount = amount - 40; }
if(PlayerInfo[playerid][WeaponSkills] == 3) { newamount = amount - 30; }
if(PlayerInfo[playerid][WeaponSkills] == 4) { newamount = amount - 20; }
if(PlayerInfo[playerid][WeaponSkills] == 5) { newamount = amount; }
if(weaponid != 0)
{
SetPlayerHealth(damagedid, HP-newamount);
}
return 1;
}
Re: Reduce damage ...? -
Metharon - 02.02.2015
Help
Re: Reduce damage ...? -
CalvinC - 02.02.2015
Using a switch instead of all those if's would be both quicker and maybe fix your bug, otherwise try using OnPlayerTakeDamage.
Also, just to mention, there's no reason to put brackets around this when you're using single functions, it won't cause bugs but just saying.
pawn Код:
{ newamount = amount - 20; }