one question
#1

I've about 10-15 timers which just checking if player in a area to set just status that place
how better to use, just all checkers to use in a public or leave single timers for each area?
2 checkers
pawn Код:
forward CheckVehicleArea();
public CheckVehicleArea()
{
    for(new i=0; i<MAX_PLAYERS; i++ )
    {
        if(IsPlayerConnected(i) && IsPlayerInArea(i,2440.7849,2414.9807,-1409.5649,-1433.7346) && ShitInfo[i][pVehReg] == 0) // CHECK:if the player is in the area
        {
            new Float:x,Float:y,Float:z;
            GetPlayerPos(i,x,y,z);
            if(z <= 29.7)
            {
            SendClientMessage(i,COLOR_GREEN,"( ! ) Welcome to the Vehicle Registeration Area !");
            ShitInfo[i][pVehReg] = 1;
            }
            else if(ShitInfo[i][pVehReg] == 1)
            {
            SendClientMessage(i,COLOR_GREEN,"( ! ) You leave the Vehicle Registeration Area !");
            ShitInfo[i][pVehReg] = 0;
            }
        }
        else if(IsPlayerConnected(i) && !IsPlayerInArea(i,2440.7849,2414.9807,-1409.5649,-1433.7346) && ShitInfo[i][pVehReg] == 1)
        {
        SendClientMessage(i,COLOR_YELLOW,"( ! ) You leave the Vehicle Registeration Area !");
        ShitInfo[i][pVehReg] = 0;
        return 1;
        }
    }
    return 1;
}
forward CheckBank();
public CheckBank()
{
    for(new i=0; i<MAX_PLAYERS; i++ )
    {
        if(IsPlayerConnected(i) && IsPlayerInArea(i,1744.2325,1700.6185,-1637.5604,-1678.7394 ) && ShitInfo[i][pBank] == 0 && GetPlayerInterior(i) != 0) // CHECK:if the player is in the area
        {
            new Float:x,Float:y,Float:z;
            GetPlayerPos(i,x,y,z);
            if(z <= 34.4585)
            {
            scm(i,COLOR_RED,"( ! ) Fighting & Killing is Forbidden Here !");
            SendClientMessage(i,COLOR_GREEN,"( ! ) Welcome to the Bank !");
            ShitInfo[i][pBank] = 1;
            }
            else if(ShitInfo[i][pBank] == 1)
            {
            SendClientMessage(i,COLOR_GREEN,"( ! ) You leave the Bank !");
            ShitInfo[i][pBank] = 0;
            }
        }
        else if(IsPlayerConnected(i) && !IsPlayerInArea(i,1744.2325,1700.6185,-1637.5604,-1678.7394 ) && ShitInfo[i][pBank] == 1)
        {
        SendClientMessage(i,COLOR_YELLOW,"( ! ) You leave the Bank !");
        ShitInfo[i][pBank] = 0;
        return 1;
        }
    }
    return 1;
}
I just asking to know how to do less lag on server
Reply
#2

I think in Streamer Plugin by Incognito there's something like this, OnPlayerEnterArea and OnPlayerExitArea (or something like this). Check this
Reply
#3

At first you should stop use MAX_PLAYERS for loops.

Код:
#define MAX_PLAYERS_EX 50 //change to server slot limit
forward PlaceChecker();
public OnGameModeInit()
{
     SetTimer("PlaceChecker",1000,true);//Start timer
}
public PlaceChecker()
{
     for(new p;p<MAX_PLAYERS_EX;p++)
     {
          if(!IsPlayerConnected(p) || IsPlayerNPC(p))continue; // jump to next ID when OFFLINE or NPC
          new interior = GetPlayerInterior(p);
          switch(interior)
          {
               case 0:// the world
               {
                    if(IsPlayerInArea(p,2440.7849,2414.9807,-1409.5649,-1433.7346))// Enter the place
                    {
                         // ...     
                    }else if(ShitInfo[i][pVehReg])// Leave the place
                    {
                         ShitInfo[i][pVehReg] = 0;
                    }
                    if(IsPlayerInArea(p,x,y,z))// Next place enter..
                    {
                         // ...     
                    }else if(ShitInfo[i][pBank])// NextPlaceLeave
                    {
                         ShitInfo[i][pBank] = 0;
                    }
               }
          }          
     }
}
Reply
#4

nice one

Quote:
Originally Posted by papedo
Посмотреть сообщение
At first you should stop use MAX_PLAYERS for loops.

Код:
#define MAX_PLAYERS_EX 50 //change to server slot limit
forward PlaceChecker();
public OnGameModeInit()
{
     SetTimer("PlaceChecker",1000,true);//Start timer
}
public PlaceChecker()
{
     for(new p;p<MAX_PLAYERS_EX;p++)
     {
          if(!IsPlayerConnected(p) || IsPlayerNPC(p))continue; // jump to next ID when OFFLINE or NPC
          new interior = GetPlayerInterior(p);
          switch(interior)
          {
               case 0:// the world
               {
                    if(IsPlayerInArea(p,2440.7849,2414.9807,-1409.5649,-1433.7346))// Enter the place
                    {
                         // ...     
                    }else if(ShitInfo[i][pVehReg])// Leave the place
                    {
                         ShitInfo[i][pVehReg] = 0;
                    }
                    if(IsPlayerInArea(p,x,y,z))// Next place enter..
                    {
                         // ...     
                    }else if(ShitInfo[i][pBank])// NextPlaceLeave
                    {
                         ShitInfo[i][pBank] = 0;
                    }
               }
          }          
     }
}
I already changed max players to my slot amount
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)