Safe Zone - 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: Safe Zone (
/showthread.php?tid=596545)
Safe Zone -
rambalili2 - 19.12.2015
Im trying to make a safe zone and when i go to that location it doesnt work can anyone help me please ?
PHP код:
new InArea[MAX_PLAYERS];
forward IsPlayerInArea();
public IsPlayerInArea()
{
new Float:X, Float:Y, Float:Z;
for(new i=0; i < MAX_PLAYERS; i++)
{
if (!IsPlayerConnected(i))
continue;
GetPlayerPos(i, X, Y, Z);
if (X <= -727.7371 && X >= -780.7371 && Y <= 853.6052 && Y >= 753.6052 && Z <= 324.8097 && Z >= 315.8097)
{
SetPlayerHealth(i, 999999.9);
InArea[i] = 1;
}
else if (InArea[i] == 1)
{
SetPlayerHealth(i, 100);
InArea[i] = 0;
}
}
}
Re: Safe Zone -
prineside - 19.12.2015
Where do you call IsPlayerInArea()? Looks like it must be called each few seconds by timer.
By the way, almost any gamemode needs Streamer plugin. If you have streamer plugin, you can simply create an area of any shape for safe zone and don't waste performance on calling this loop by timer
Re: Safe Zone -
TwinkiDaBoss - 19.12.2015
Dont do this, instead make an actual zone. And then use
PHP код:
public OnPlayerEnterDynamicArea(playerid, areaid) {
SetPlayerTeam(playerid,20); //or some team id so friendly fire is off
return true;
}
And you can do that with
https://sampforum.blast.hk/showthread.php?tid=467190
Re: Safe Zone -
rambalili2 - 19.12.2015
Ok ill try it but how do i disable friendly fire?
Re: Safe Zone -
TwinkiDaBoss - 19.12.2015
Quote:
Originally Posted by rambalili2
Ok ill try it but how do i disable friendly fire?
|
Set the player team. If players have same team, friendly fire is automaticly disabled.
PHP код:
SetPlayerTeam(playerid,TeamID);
Re: Safe Zone -
rambalili2 - 19.12.2015
ah ok
Re: Safe Zone -
rambalili2 - 19.12.2015
ok it worked but when they leave the zone they cant kill eachother
Re: Safe Zone -
TwinkiDaBoss - 19.12.2015
Quote:
Originally Posted by rambalili2
ok it worked but when they leave the zone they cant kill eachother
|
Add
PHP код:
public OnPlayerLeaveDynamicArea(playerid, areaid) { SetPlayerTeam(playerid,0); return true; }
Re: Safe Zone -
rambalili2 - 19.12.2015
I did this
PHP код:
new zone;
public OnGameModeInit()
{
zone= CreateDynamicRectangle(-727.7371,853.6052,635.6359,324.8097, -1, -1, -1);
return 1;
}
public OnPlayerEnterDynamicArea(playerid, areaid);
{
if(areaid == zone)
{
SetPlayerTeam(playerid,20);
}
return 1;
}
public OnPlayerLeaveDynamicArea(playerid, areaid);
{
if(areaid == zone)
{
SetPlayerTeam(playerid,0);
}
return 1;
}
I get bunch of errors tho
Re: Safe Zone -
vassilis - 19.12.2015
NO. Even if you put SetPlayerTeam ID at 0 They will still have friendly fire. Use NO_TEAM which is Invalid Team ID and you can't escape friendly fire issue.