22.12.2018, 18:06
Hello There, first of all let me explain how that system works, on my server, players can create a clan and invite any other player, so I created a system, just give the / cfire command that the idea is that you can not do damage on members of your own clan.
When giving this command, this boolean variable becomes true "FireArmClaBlock [playerid]" so I just did a check, because the clan name of the players was stored in DOF2 then compared the two strings, and I put it so that if they were the same , return zero on OnPlayerGiveDamage, then it would not cause damage.
My problem arises when the player of the / cfire command, he can not hit anyone else and nobody can hit him and I do not know why.
Command:
My Definitions:
Someone can help me?
When giving this command, this boolean variable becomes true "FireArmClaBlock [playerid]" so I just did a check, because the clan name of the players was stored in DOF2 then compared the two strings, and I put it so that if they were the same , return zero on OnPlayerGiveDamage, then it would not cause damage.
PHP код:
hook OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
new PlayerClan[250][MAX_PLAYERS], TargetClan[250][MAX_PLAYERS];
format(pFile, sizeof(pFile), "clas/%s.ini", PlayerName(playerid));
PlayerClan[playerid] = DOF2_GetString(pFile, "cla");
format(pFile, sizeof(pFile), "clas/%s.ini", PlayerName(damagedid));
TargetClan[damagedid] = DOF2_GetString(pFile, "cla");
if(!strcmp(PlayerClan[playerid], TargetClan[damagedid], true))
{
if(FireArmClaBlock[playerid] == true)
{
GameTextForPlayer(playerid,"~r~Friendly fire",1000,5);
return 0;
}
}
_HandleFirearmDamage(playerid, damagedid, bodypart);
return 1;
}
Command:
PHP код:
CMD:cfire(playerid, params[])
{
new NCla[250];
new ActualCla[250];
NCla = "None";
format(pFile, sizeof(pFile), "clas/%s.ini", PlayerName(playerid));
ActualCla = DOF2_GetString(pFile, "cla");
if(!strcmp(ActualCla, NCla, true))
return SendClientMessage(playerid, RED, "[ > ] You do not have a clan.");
if(FireArmClaBlock[playerid] == false)
{
SendClientMessage(playerid, NovoA, "[ > ] Damage to clan members: 'OFF'");
SendClientMessage(playerid, NovoA, "[ > ] You can not now deal damage to members of your own clan.");
FireArmClaBlock[playerid] = true;
}
else
{
SendClientMessage(playerid, NovoA, "[ > ] Damage to clan members: 'ON'");
SendClientMessage(playerid, NovoA, "[ > ] You can now deal damage to members of your own clan.");
FireArmClaBlock[playerid] = false;
}
return 1;
}
PHP код:
new bool:FireArmClaBlock[MAX_PLAYERS];