Safe Zone
#1

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:XFloat:YFloat:Z;
  for(new 
i=0MAX_PLAYERSi++)
  {
    if (!
IsPlayerConnected(i))
      continue;
    
GetPlayerPos(iXYZ);
    if (
<= -727.7371 && >= -780.7371 && <= 853.6052 && >= 753.6052 && <= 324.8097 && >= 315.8097)
    {
        
SetPlayerHealth(i999999.9);
        
InArea[i] = 1;
    }
    else if (
InArea[i] == 1)
    {
        
SetPlayerHealth(i100);
        
InArea[i] = 0;
    }
  }

Reply
#2

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
Reply
#3

Dont do this, instead make an actual zone. And then use
PHP код:
public OnPlayerEnterDynamicArea(playeridareaid) {
    
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
Reply
#4

Ok ill try it but how do i disable friendly fire?
Reply
#5

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); 
Reply
#6

ah ok
Reply
#7

ok it worked but when they leave the zone they cant kill eachother
Reply
#8

Quote:
Originally Posted by rambalili2
Посмотреть сообщение
ok it worked but when they leave the zone they cant kill eachother
Add
PHP код:
public OnPlayerLeaveDynamicArea(playeridareaid) { SetPlayerTeam(playerid,0); return true; } 
Reply
#9

I did this

PHP код:
new zone;
 
public 
OnGameModeInit()
{
        
zoneCreateDynamicRectangle(-727.7371,853.6052,635.6359,324.8097, -1, -1, -1);
        return 
1;
}
public 
OnPlayerEnterDynamicArea(playeridareaid);
{
        if(
areaid == zone)
        {
           
SetPlayerTeam(playerid,20);
        }
        return 
1;
}
 
public 
OnPlayerLeaveDynamicArea(playeridareaid);
{
        if(
areaid == zone)
        {
           
SetPlayerTeam(playerid,0);
        }
        return 
1;

I get bunch of errors tho
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)