I have a script and I wish to edit the damage system because right now it is really OP you can take two shots from any gun and die which I do not like I want to change this so it is more realistic and fit table for SAMP her is the code:
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(GetPVarInt(playerid, "PlayerLogged") == 0) return 1;
if(GetPVarInt(issuerid, "LSPD_Ta") == 0) CallRemoteFunction("ShowBlood", "i", playerid);
if(IsPlayerConnected(issuerid))
{
new Float:damage = 0, string[128], Float:amoun, Float:distance = 0.9, Float:radius, feet, Float:x, Float:y, Float:z, Float:health, Float:armour;
GetPlayerPos(playerid,x,y,z), GetPlayerHealth(playerid,health), GetPlayerArmourEx(playerid,armour);
//==========//
// KO System
if(weaponid <= 15 && GetPVarInt(playerid, "Dead") == 5)
{
SetPlayerHealth(playerid, 99);
return 1;
}
if(weaponid >= 22 && weaponid <= 38 && GetPVarInt(playerid, "Dead") == 5)
{
ResetPlayerWeapons(playerid);
TogglePlayerControllableEx(playerid, false);
SetPVarInt(playerid, "Dead", 2);
SetPlayerPosEx(playerid,GetPVarFloat(playerid, "PosX"),GetPVarFloat(playerid, "PosY"),GetPVarFloat(playerid, "PosZ"));
SetPlayerFacingAngle(playerid,GetPVarFloat(playerid, "Angle"));
SetPlayerInterior(playerid,GetPVarInt(playerid, "Interior"));
SetPlayerVirtualWorld(playerid,GetPVarInt(playerid, "World"));
SetCameraBehindPlayer(playerid);
SendClientMessage(playerid,COLOR_WHITE,"Type (/accept death) to continue.");
SetPlayerHealthEx(playerid,1.0);
GivePlayerWeaponEx(playerid, PlayerInfo[playerid][pPlayerWeapon], PlayerInfo[playerid][pPlayerAmmo]);
if(GetPVarInt(playerid, "Admin") != 10) SetPVarInt(playerid, "DeathTime", GetCount()+60000);
}
if(GetPVarInt(playerid, "Dead") != 0) return 1;
// Taser System
if(weaponid == 23 && GetPVarInt(issuerid, "LSPD_Ta") == 1
&& GetPVarInt(playerid, "Dead") == 0 && GetPVarInt(playerid, "Cuffed") == 0
&& GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && !IsPlayerInRangeOfPoint(issuerid,0.9,x,y,z))
{
if(GetPlayerWeapon(playerid) >= 22 && GetPlayerWeapon(playerid) <= 38) return SendClientMessage(issuerid,COLOR_ERROR,"You can't taze a player who has a weapon in his hand."),SetPlayerHealthEx(playerid,health);
if(!IsPlayerInRangeOfPoint(issuerid, 10.0, x, y, z)) return SendClientMessage(issuerid, COLOR_ERROR,"You are too far away from the player you're shooting at.");
if(GetPVarInt(issuerid, "LSPD_Delay") > GetCount()) return true;
new sendername[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
format(sendername, sizeof(sendername), "%s", PlayerNameEx(playerid));
format(giveplayer, sizeof(giveplayer), "%s", PlayerNameEx(issuerid));
GiveNameSpace(sendername);
GiveNameSpace(giveplayer);
format(string, sizeof(string), "*** %s aims %s taser at %s and fires it.", giveplayer, CheckSex(issuerid), sendername);
ProxDetector(30.0, issuerid, string, COLOR_PURPLE);
TogglePlayerControllableEx(playerid,false);
SetPVarInt(playerid, "Cuffed", 1);
SetPVarInt(playerid, "CuffedTime", 60);
SetPVarInt(playerid, "Tazed", 1);
ApplyAnimationEx(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
SetPlayerArmourEx(playerid,armour);
if(health < 11.0) SetPlayerHealthEx(playerid, 10.0);
else SetPlayerHealthEx(playerid,health);
PlaySoundPlyRadius(playerid, 6003, 10.0);
scm(issuerid, -1, "You must wait a moment before shooting the taser again.");
SetPVarInt(issuerid, "LSPD_Delay", GetCount()+1500);
return true;
}
if(weaponid >= 22 && weaponid <= 38)
{
SetPVarInt(issuerid, "HitMark", 1);
TextDrawHideForPlayer(issuerid, HitMark);
TextDrawShowForPlayer(issuerid, HitMark);
}
if(weaponid == 41)
{
if(GetPVarInt(playerid, "Blinded") == 0 && GetPVarInt(playerid, "BlackScreen") == 0)
{
TextDrawShowForPlayer(playerid,BlindDraw);
SetTimerEx("EndBlackScreen", 2000, false, "i", playerid);
SetPVarInt(playerid, "BlackScreen", 1);
SetPlayerHealthEx(playerid, health);
}
return true;
}
if(PlayerInfo[issuerid][pAmmoType] == 113) // BEANBAG
{
if(weaponid == 25 || weaponid == 26)
{
if(IsPlayerInRangeOfPoint(issuerid, 20.0, x, y, z))
{
SetPlayerArmourEx(playerid,armour);
if(health < 10.0) SetPlayerHealthEx(playerid,10.0);
else SetPlayerHealthEx(playerid,health);
if(PlayerInfo[playerid][pBeanbaggedTime] == 0)
{
if(PlayerInfo[playerid][pBeanbagged] == 0)
{
PlayerInfo[playerid][pBeanbagged] = 1;
PlayerInfo[playerid][pBeanbaggedTime] = 3;
}
else if(PlayerInfo[playerid][pBeanbagged] == 1)
{
PlayerInfo[playerid][pBeanbagged] = 2;
PlayerInfo[playerid][pBeanbaggedTime] = 10;
}
else if(PlayerInfo[playerid][pBeanbagged] == 2)
{
PlayerInfo[playerid][pBeanbagged] = 3;
PlayerInfo[playerid][pBeanbaggedTime] = 20;
}
ClearAnimations(playerid);
format(string, sizeof(string),"You shot %s with a bean bag.", PlayerNameEx(playerid));
SendClientMessage(issuerid,COLOR_WHITE,string);
format(string, sizeof(string),"%s shot you with a bean bag.", PlayerNameEx(issuerid));
SendClientMessage(playerid,COLOR_WHITE,string);
TogglePlayerControllableEx(playerid, false);
ApplyAnimationEx(playerid, "ped", "FLOOR_hit", 4.0, 0, 1, 1, 1, -1);
}
return true;
}
else
{
SetPlayerArmourEx(playerid,armour);
if(health < 10.0) SetPlayerHealthEx(playerid,10.0);
else SetPlayerHealthEx(playerid,health);
return true;
}
}
}
if(PlayerInfo[issuerid][pAmmoType] == 128) // RUBBER
{
if(weaponid == 31)
{
if(IsPlayerInRangeOfPoint(issuerid, 30.0, x, y, z))
{
SetPlayerArmourEx(playerid,armour);
if(health < 10.0) SetPlayerHealthEx(playerid,10.0);
else SetPlayerHealthEx(playerid,health);
if(PlayerInfo[playerid][pBeanbaggedTime] == 0)
{
if(PlayerInfo[playerid][pBeanbagged] == 0)
{
PlayerInfo[playerid][pBeanbagged] = 1;
PlayerInfo[playerid][pBeanbaggedTime] = 3;
}
else if(PlayerInfo[playerid][pBeanbagged] == 1)
{
PlayerInfo[playerid][pBeanbagged] = 2;
PlayerInfo[playerid][pBeanbaggedTime] = 10;
}
else if(PlayerInfo[playerid][pBeanbagged] == 2)
{
PlayerInfo[playerid][pBeanbagged] = 3;
PlayerInfo[playerid][pBeanbaggedTime] = 20;
}
ClearAnimations(playerid);
format(string, sizeof(string),"You shot %s with a rubber bullet.", PlayerNameEx(playerid));
SendClientMessage(issuerid,COLOR_WHITE,string);
format(string, sizeof(string),"%s shot you with a rubber bullet.", PlayerNameEx(issuerid));
SendClientMessage(playerid,COLOR_WHITE,string);
TogglePlayerControllableEx(playerid, false);
ApplyAnimationEx(playerid, "ped", "FLOOR_hit", 4.0, 0, 1, 1, 1, -1);
}
return true;
}
else
{
SetPlayerArmourEx(playerid,armour);
if(health < 10.0) SetPlayerHealthEx(playerid,10.0);
else SetPlayerHealthEx(playerid,health);
return true;
}
}
}
if(bodypart == 9) // HEADSHOT !
{
if(armour > 200)
{
SetPlayerArmourEx(playerid, 100.0);
}
else if(armour > 100)
{
SetPlayerArmourEx(playerid, 50.0);
}
else if(armour > 0)
{
if(armour > 50.0) SetPlayerHealthEx(playerid, 50.0);
SetPlayerArmourEx(playerid, 0.0);
}
else
{
SetPlayerHealthEx(playerid, 0.0), SetPlayerArmourEx(playerid, 0.0);
}
return true;
}
//==========//
radius = GetPlayerDistanceFromPoint(issuerid, x, y, z);
feet = floatround(radius);
switch(weaponid)
{
case 2 .. 3: damage = 5 * 1.5;
case 4: damage = 20 * 1.5;
case 5 .. 8: damage = 15 * 1.5;
case 22: damage = DAMAGE_COLT * 1.5;
case 23: damage = DAMAGE_SILENCER * 1.5;
case 24: damage = DAMAGE_DEAGLE * 1.5;
case 25:
{
damage = DAMAGE_SHOTGUN * 1.5;
if(feet <= 5.0) damage+=50;
}
case 26:
{
damage = DAMAGE_SAWNOFF * 1.5;
if(feet <= 5.0) damage+=50;
}
case 28: damage = DAMAGE_UZI * 1.5;
case 29: damage = DAMAGE_MP5 * 1.5;
case 30: damage = DAMAGE_AK47;
case 31: damage = DAMAGE_M4;
case 32: damage = DAMAGE_TEC9 * 1.5;
case 33: damage = DAMAGE_RIFLE;
case 34: damage = DAMAGE_SNIPER;
}
if(weaponid < 15 && GetPVarInt(playerid,"DrugTime") > 0)
{
switch(GetPVarInt(playerid,"DrugHigh"))
{
case 501: // cocaine
{
damage += 5;
}
case 502: // crack
{
damage -= 5;
}
}
}
if(PlayerInfo[issuerid][pAmmoType] == 113) // BEANBAG
{
damage = 0;
}
else if(PlayerInfo[issuerid][pAmmoType] == 128) // RUBBER
{
damage = 0;
}
if(damage != 0)
{
if(WoundWeapon(weaponid) && PlayerInfo[issuerid][pArcade] == 0 && PlayerInfo[playerid][pArcade] == 0)
{
if(!IsPlayerInRangeOfPoint(issuerid,distance,x,y,z))
{
switch(bodypart)
{
case 3,4: PlayerWound(playerid, 1, 1);
case 5,6: PlayerWound(playerid, 2, 1);
case 7,8: PlayerWound(playerid, 3, 1);
}
}
}
if(armour > 0)
{
amoun = armour - damage;
if(amoun < 0)
{
SetPlayerHealthEx(playerid,health - damage);
}
SetPlayerArmourEx(playerid,armour-damage);
}
else
{
SetPlayerHealthEx(playerid,health-damage);
}
PlayerInfo[playerid][pInjuries][bodypart] += 1;
}
if(weaponid <= 15 && health <= 20.0 && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPVarInt(playerid, "Dead") == 0)
{
new rand = random(5);
switch(rand)
{
case 0: ApplyAnimationEx(playerid, "ped", "FLOOR_hit", 4.0, 0, 1, 1, 1, -1);
case 1: ApplyAnimationEx(playerid, "ped", "FLOOR_hit_f", 4.0, 0, 1, 1, 1, -1);
case 2: ApplyAnimationEx(playerid, "ped", "KO_shot_front", 4.0, 0, 1, 1, 1, -1);
case 3: ApplyAnimationEx(playerid, "ped", "KO_shot_stom", 4.0, 0, 1, 1, 1, -1);
case 4: ApplyAnimationEx(playerid, "ped", "BIKE_fall_off", 4.0, 0, 1, 1, 1, -1);
default: ApplyAnimationEx(playerid, "FINALE", "FIN_Land_Die", 4.0, 0, 1, 1, 1, -1);
}
SetPVarInt(playerid, "Dead", 5);
SetPVarInt(playerid, "CrackTime", GetCount() + 60000);
SendClientMessage(playerid, COLOR_ERROR, "You have been knocked out. (/getup)");
PlayerInfo[playerid][pInjuriesText] = CreateDynamic3DTextLabel("(( Has been injured (/injuries) for more information. ))", COLOR_ERROR, x, y, z, 25.0, playerid, INVALID_VEHICLE_ID, 1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), -1, 20.0);
SetPlayerHealth(playerid, 99);
return 1;
}
}
return true;
}