SA-MP Forums

SA-MP Forums (http://forum.sa-mp.com/index.php)
-   Scripting Help (http://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Need help with safezone. (http://forum.sa-mp.com/showthread.php?t=472930)

tuuler 31/10/2013 04:44 PM

Need help with safezone.
 
PROBLEM SOLVED

tuuler 01/11/2013 12:04 PM

Re: Need help with safezone.
 
Anyone please ! Help me.

LoLeC 01/11/2013 01:23 PM

Re: Need help with safezone.
 
Code:

public OnGameModeInit()
{
SetTimer("safezone",1000,true);
return 1;
}

forward safezone();
public safezone()
{
        for(new i;i<MAX_PLAYERS;i++)
        {
            if(IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                    if(IsPlayerInRangeOfPoint(i,range,x,y,z)) // put here your coordinates
                    {
                        Kick(i);
                    }
            }
        }
        return 1;
}


Konstantinos 01/11/2013 01:32 PM

Re: Need help with safezone.
 
Code:

stock IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
{
    new Float:X, Float:Y, Float:Z;

    GetPlayerPos(playerid, X, Y, Z);
    if(X >= MinX && X <= MaxX && Y >= MinY && Y <= MaxY) {
        return 1;
    }
    return 0;
}


In OnPlayerDeath:
Code:

if( killerid != INVALID_PLAYER_ID && IsPlayerInArea( killerid, -2144.53125, 750, -1511.71875, 1062.5 ) )
{
    // do your code, he killed inside the safezone
    // Kick( killerid );
}


The use of timer is totally unnecessary!


All times are GMT. The time now is 10:33 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.