10.08.2016, 11:21
Learn how to shorten the code, how to use variables and if statements properly. You made the code very big, so I cleaned it up and fixed some bugs. Fix the indentation kindly, i wrote it in the browser. if you want to you can break the helmet and let player get headshot after getting their helmet broke, uncomment the lines to enable it.
PHP код:
public OnPlayerTakeDamage(playerid,issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID)
{
if((weaponid == 34 || weaponid == 33) && bodypart == 9 && gTeam[issuerid] != gTeam[playerid])
{
if(gHelmet[playerid] == false)
{
SetPlayerHealth(playerid,0.0);
GameTextForPlayer(playerid,"~r~YOU GOT HEADSHOT~n~Type /buy To get Helmet",5000,3);
GameTextForPlayer(issuerid,"~r~wOw. Perfect Shot",5000,3);
PlayerPlaySound(playerid, 1050, 0.0, 0.0, 0.0);
PlayerPlaySound(issuerid, 1050, 0.0, 0.0, 0.0);
}
else
{
/*gHelmet[playerid] = false;*/
GameTextForPlayer(issuerid,"~w~Player has a ~r~helmet",5000,3);
/*RemovePlayerAttachedObject(playerid, 1);*/
}
}
// anti-team-attack
if(gTeam[issuerid] == gTeam[playerid] && EDM[playerid] == 0 && weaponid != 18)
{
if(AntiSK[playerid])
{
GetPlayerHealth(issuerid,amount);
SetPlayerHealth(issuerid,amount-5);
GameTextForPlayer(issuerid,"~r~Player Have Anti Spawn Kill Protection", 3000, 3);
}
else
{
GetPlayerHealth(issuerid,amount);
SetPlayerHealth(issuerid,amount-2);
GameTextForPlayer(issuerid,"~r~Your teamattacking ~n~-2 health", 3000, 3);
}
}
// anti team knifing
if(gTeam[issuerid] == gTeam[playerid] && weaponid == 4)
{
GameTextForPlayer(issuerid,"~g~do not knife~n~team mates", 3000, 3);
GameTextForPlayer(playerid,"~g~you got team knifed~n~use /sync", 3000, 3);
SetPlayerHealth(issuerid, 0);
}
new str[26];
format(str, sizeof(str),"-%.0f", amount);
SetPlayerChatBubble(playerid, str, 0xFF0000FF, 100.0, 2000);
}
return 1;
}