In a specfic area , players wont be able to dmg each other - 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: In a specfic area , players wont be able to dmg each other (
/showthread.php?tid=604057)
In a specfic area , players wont be able to dmg each other -
Beasthian - 31.03.2016
Any can explain how you could do this?
Re: In a specfic area , players wont be able to dmg each other -
Threshold - 31.03.2016
Well there are multiple ways of doing this.
OnPlayerTakeDamage
- if(issuerid != INVALID_PLAYER_ID), Give the player back the health they lost.
SetPlayerTeam
When the player enters the certain area, set their team to a specific number. They won't be able to damage any other players on the same team. So they won't be able to damage anyone in the same area. Don't forget to reset the players team to NO_TEAM when they leave the area though.
Re: In a specfic area , players wont be able to dmg each other -
Mencent - 31.03.2016
Hi!
There are more then only one way because you can use two functions.
1. function - IsPlayerInRangeOfPoint:
IsPlayerInRangeOfPoint is a function which you can use to get the distance between a player and a certain point.
The range which is a parameter in that function is circular from the point.
2. function - IsPlayerInArea:
IsPlayerInArea is a function which you can use to get wheather a player is in a certain "area". This area isn't circular but it's square.
So, I think for your intention it is a good way to use IsPlayerInArea.
PHP код:
IsPlayerInArea(playerid,Float:MinX,Float:MinY,Float:MaxX,Float:MaxY)
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
return (X>=MinX && X<= MaxX && Y=>MinY && Y<=MaxY) ? 1 : 0;
}
This is the function you need. You apply this function in the callback OnPlayerTakeDamage
or OnPlayerGiveDamage. It's yours decision.
Try this and feel free to ask if you need help. Good luck!