Give Damage Help! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Give Damage Help! (
/showthread.php?tid=599138)
Give Damage Help! -
danish007 - 21.01.2016
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
if(InTeamDM[playerid] == 1 && InTeamDM[damagedid] == 1)
{
if(PlayerTeam[playerid] == PlayerTeam[damagedid])
{
GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
}
return 1;
}
if(pctp[playerid] == 1 && pctp[damagedid] == 1)
{
if(GetPlayerTeam(playerid) == GetPlayerTeam(damagedid))
{
GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
}
return 1;
}
return 1;
}
this is the code. in this i want that if players are in teamdm or in pctp.. and they attack same team players they should get a message and their health should not decrease,
but it works correct when the players are in TeamDm or pctp. but when there pctp and teamdm variables are = 0; means when they are not in teamDm or pctp.. message doesn't show that don't attack team mates it okk but health is not getting decreased..
please help!
Re: Give Damage Help! -
Lucky13 - 21.01.2016
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
if((InTeamDM[playerid] == 1 && InTeamDM[damagedid] == 1) || pctp[playerid] == 1 && pctp[damagedid] == 1)
{
if(PlayerTeam[playerid] == PlayerTeam[damagedid])
{
new Float:Health;
GetPlayerHealth(damagedid,Health);
GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
SetPlayerHealth(damagedid,Health);
}
}
return 1;
}
This should work.
Re: Give Damage Help! -
danish007 - 21.01.2016
not works.
if player is not in tdm or pctm the health is not getting decreased. and if the player is in tdm or pctp even i shoot other team member it says do not attack team members and when i attack my same team mate it says do not attack team member.
Re: Give Damage Help! -
Lucky13 - 21.01.2016
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
new Float:Health;
GetPlayerHealth(damagedid,Health);
if(InTeamDM[playerid] == 1 && InTeamDM[damagedid] == 1)
{
if(PlayerTeam[playerid] == PlayerTeam[damagedid])
{
GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
SetPlayerHealth(damagedid, Health);
}
return 1;
}
if(pctp[playerid] == 1 && pctp[damagedid] == 1)
{
if(GetPlayerTeam(playerid) == GetPlayerTeam(damagedid))
{
GameTextForPlayer(playerid,"~r~DO NOT ATTACK YOU TEAM MATES", 5000, 3);
SetPlayerHealth(damagedid, Health);
}
return 1;
}
return 1;
}
Re: Give Damage Help! -
danish007 - 21.01.2016
man there is other problem when i remove all this code. and the players is not getting any damage..
Re: Give Damage Help! -
Lucky13 - 21.01.2016
You should call OnPlayerTakeDamage then. It's more accurate when it comes on taken damage, not on given.
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage