public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) { if(hittype == 1 && gTeam[playerid] == gTeam[hitid]) { SendClientMessage(playerid, COLOR_RED, "Do not shoot your teammates!"); return 0; } return 1; }
SetPlayerTeam(playerid, teamid);
I already have a pretty solid system setting player's teams based on their classid every time they spawn or change class, somehow they are still tking on occasion though.
|
BULLET_HIT_TYPE_PLAYER
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart) {
if(gTeam[playerid] == gTeam[damagedid]) {
switch(weaponid) {
case 0 .. 15: GivePlayerHealth(damagedid,-amount); //positive damage if its a melee weapon
default: { //if its anything else
new Float:MyPos[3];
GetPlayerPos(damagedid,MyPos[0],MyPos[1],MyPos[2]); //getting player thats receiving damage position
if(IsPlayerInRangeOfPoint(playerid,3.0,MyPos[0],MyPos[1],MyPos[3]))
return SendClientMessage(playerid,COLOR_RED,"NO WHIPS!"); //if they are in range of them and they have any other weapon which aint a melee
else if(!IsPlayerInRangeOfPoint(playerid,3.0,MyPos[0],MyPos[1],MyPos[3]))
return GivePlayerHealth(damagedid,-amount);
}
}
}
}
return true;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) {
new playerState = GetPlayerState(playerid);
if(issuerid != INVALID_PLAYER_ID && playerState == PLAYER_STATE_PASSENGER) { //if there is a valid shooter & playerid is passenger
GivePlayerHealth(playerid,amount); //We will restore their health
}
return true;
}
stock GivePlayerHealth(playerid,Float:Health) //credits aircombat
{
new Float:health; GetPlayerHealth(playerid,health);
SetPlayerHealth(playerid,health+Health);
}