09.04.2019, 10:27
Hello, i have problem with OnPlayerWeaponShot. I made script which should prevent players to kill eachother in ammunation but now it also happens even they are not in ammu.
PHP Code:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(hittype == BULLET_HIT_TYPE_PLAYER && IsPlayerConnected(hitid) && !IsPlayerNPC(hitid))
{
if(hitid != INVALID_PLAYER_ID)
{
if(InEvent[hitid] != InEvent[playerid] || InTDM[hitid] != InTDM[playerid] || InParkour[hitid] != InParkour[playerid] || InSkydive[hitid] != InSkydive[playerid] || InDerby[hitid] != InDerby[playerid])
{
GameTextForPlayer(playerid, "NO KILLING!", 3000, 3);
return 0;
}
if(InHouse[hitid] != INVALID_HOUSE_ID)
{
GameTextForPlayer(playerid, "NO KILLING!", 3000, 3);
}
if(InAmmu[hitid] != INVALID_PLAYER_ID)
{
new Float: HP;
GetPlayerHealth(playerid, HP);
GetPlayerHealth(hitid, HP);
SetPlayerHealth(hitid, 100);
GameTextForPlayer(playerid, "NO KILLING!", 3000, 3);
SetPlayerHealth(playerid, HP-30);
}
if(pProtectTick[hitid] > 0)
{
GameTextForPlayer(playerid, "NO SPAWN KILLING!", 5000, 3);
}
if(GetPlayerTeam(playerid) != NO_TEAM && GetPlayerTeam(hitid) != NO_TEAM) {
if(GetPlayerTeam(playerid) == GetPlayerTeam(hitid) || GetPlayerTeam(hitid) == GetPlayerTeam(playerid)) {
GameTextForPlayer(playerid, "NO TEAM KILLING!", 5000, 3);
}
}
if(IsPlayerAFK(hitid))
{
if(gettime() - AbuseTick[playerid] < 20)
{
SetPlayerHealth(hitid, 0);
GameTextForPlayer(hitid, "NO AFK TO AVOID DEATH", 5000, 3);
}
}
if(pProtectTick[playerid] > 0)
{
pProtectTick[playerid] = 0;
SetPlayerHealth(playerid, 100.0);
}
}
}