Greetings friends, I have a question, I hope you can clarify it for me.
I have around 200 checkpoints in different locations in the city. The function says that if a player is about 20 meters away from a checkpoint, it deletes it and if he gets closer, it creates it again.
My question is that if this would affect the server with delays, what would be more recommended? leave them fixed or if this way I did it is good or open some other more recommended way.
[/color]
This is the function I use
//--Table server
CheckPoint1 <- array( GetMaxPlayers(), 0 );
CheckPoint2 <- array( GetMaxPlayers(), 0 );
CheckPoint3 <- array( GetMaxPlayers(), 0 );
//server Funtions
function onClientScriptData( player )
{
local ReadString = Stream.ReadString();
local ReadInt = Stream.ReadInt();
if ( ReadString == "CreateCheckPoints")
{
if ( player.IsSpawned )
{
onPlayerCheckpint( player )
}
}
}
function onPlayerCheckpint( player )
{
//---------------------
if( CheckPoint1[ player.ID ] == 0 && DistanceFromPoint( player.Pos.x, player.Pos.y, 316.729, 11.0378 ) < 20 )
{
CheckPoint1[ player.ID ] = CreateCheckpoint( player, player.UniqueWorld, true, Vector( 316.729, 11.0378, 10.8006), RGB(255,255,255), 1 );
}
if( CheckPoint1[ player.ID ] != 0 && DistanceFromPoint( player.Pos.x, player.Pos.y, 316.729, 11.0378) > 20 )
{
CheckPoint1[ player.ID ].Remove(), CheckPoint1[ player.ID ] = 0;
}
//---------------------
if( CheckPoint2[ player.ID ] == 0 && DistanceFromPoint( player.Pos.x, player.Pos.y, 318.927, 41.5121 ) < 20 )
{
CheckPoint2[ player.ID ] = CreateCheckpoint( player, player.UniqueWorld, true, Vector(318.927, 41.5121, 500.942), RGB(255,255,255), 1 );
}
if( CheckPoint2[ player.ID ] != 0 && DistanceFromPoint( player.Pos.x, player.Pos.y, 318.927, 41.5121) > 20 )
{
CheckPoint2[ player.ID ].Remove(), CheckPoint2[ player.ID ] = 0;
}
//---------------------
if( CheckPoint3[ player.ID ] == 0 && DistanceFromPoint( player.Pos.x, player.Pos.y, 301.595, 17.9316 ) < 20 )
{
CheckPoint3[ player.ID ] = CreateCheckpoint( player, player.UniqueWorld, true, Vector(301.595, 17.9316, 11.7104), RGB(255,255,255), 1 );
}
if( CheckPoint3[ player.ID ] != 0 && DistanceFromPoint( player.Pos.x, player.Pos.y, 301.595, 17.9316) > 20 )
{
CheckPoint3[ player.ID ].Remove(), CheckPoint3[ player.ID ] = 0;
}
//---------------------
}
///Client Sever
TimerUpdateCheckPoint <- 200;
function Script::ScriptProcess()
{
::PantallaX = GUI.GetScreenSize().X;
::PantallaY = GUI.GetScreenSize().Y;
if ( TimerUpdateCheckPoint > 1 )::TimerUpdateCheckPoint -= 1;
if ( TimerUpdateCheckPoint < 50 )
{
::TimerUpdateCheckPoint = 200;
local plr = World.FindLocalPlayer();
if ( plr != null )
{
local Datos = Stream();
Datos.WriteString( "CreateCheckPoints" );
Server.SendData(Datos);
}
}
}
There won't be any delay.
Hi Habi ,I have done a similar feature acquisition that can help you
Global<-{
CreateObjList=[],
DeleteObjList=[]
}
CreateObjectEx<-CreateObject;
function CreateObject(model,world,pos,alpha)
{
local obj=CreateObjectEx(model,world,pos,alpha);
obj.TrackingShots=true;
obj.TrackingBumps=true;
Global.CreateObjList.append(obj.ID);
return obj;
}
function CObject::DeleteEx()
{
::Global.DeleteObjList.append([this.Model,this.Pos,this.Alpha,this.Rotation]);
this.Delete();
}
if(cmd=="undoobj")
{
if(Global.Map!=null)
{
if(Global.CreateObjList.len()>0)
{
while(true)
{
if(Global.CreateObjList.len()==0) break;
local obj=FindObject(Global.CreateObjList[Global.CreateObjList.len()-1]);
if(obj)
{
obj.DeleteEx();
Global.CreateObjList.remove(Global.CreateObjList.len()-1);
break;
}
else Global.CreateObjList.remove(Global.CreateObjList.len()-1);
}
}
else MessagePlayer("[#FF0000]There's no object left to undo.",player);
}
else MessagePlayer("[#FF0000]You first need to load a map.",player);
}
if(cmd=="redoobj")
{
if(Global.Map!=null)
{
if(Global.DeleteObjList.len()>0)
{
while(true)
{
if(Global.DeleteObjList.len()==0) break;
local arr=Global.DeleteObjList[Global.DeleteObjList.len()-1];
local obj=CreateObject(arr[0],player.World,arr[1],arr[2]).RotateTo(arr[3],0);
Global.DeleteObjList.remove(Global.DeleteObjList.len()-1);
break;
}
}
else MessagePlayer("[#FF0000]There's no object left to redo.",player);
}
else MessagePlayer("[#FF0000]You first need to load a map.",player);
}
This is a function that I made to create buildings and undo buildings, and redo buildings, and I created two lists to store created buildings and deleted buildings for recovery by command, and I think this is very similar to distance judgment, so you can add a timer, and when there is no one around 200 meters around the checkpoint, delete it and record, When there are people around 200 meters, recover through the list.
Quote from: PSL on Nov 27, 2024, 07:27 AMThis is a function that I made to create buildings and undo buildings, and redo buildings, and I created two lists to store created buildings and deleted buildings for recovery by command, and I think this is very similar to distance judgment, so you can add a timer, and when there is no one around 200 meters around the checkpoint, delete it and record, When there are people around 200 meters, recover through the list.
ok bro I'm going to test that function to make the system cleaner :D