[Ajuda] Gm com Lag :S - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (
https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Gm com Lag :S (
/showthread.php?tid=438532)
Gm com Lag :S -
BielCOP - 20.05.2013
pawn Код:
stock IsVehicleInRangeOfPoint(vehicleid, Float:range, Float:x, Float:y, Float:z)
{
new Float:px,Float:py,Float:pz; GetVehiclePos(vehicleid,px,py,pz); px -= x; py -= y; pz -= z;
return ((px * px) + (py * py) + (pz * pz)) < (range * range);
}
forward DetectarCarro(vehicleid);
public DetectarCarro(vehicleid)
{
new Float:PosVeh[3];
new VeiculosPerto = 0;
GetVehiclePos(vehicleid,PosVeh[0],PosVeh[1],PosVeh[2]);
for(new i=0; i<MAX_VEHICLES; i++)
{
if(IsVehicleInRangeOfPoint(i,10.0,PosVeh[0],PosVeh[1],PosVeh[2]))
{
VeiculosPerto++;
}
}
if(VeiculosPerto >= 30)
{
for(new f=0; f<MAX_PLAYERS; f++)
{
if(IsPlayerConnected(f))
{
if(IsPlayerInRangeOfPoint(f,20.0,PosVeh[0],PosVeh[1],PosVeh[2]))
{
new Float:Pos[3]; GetPlayerPos(f,Pos[0],Pos[1],Pos[2]);
for(new xy=0; xy<MAX_VEHICLES; xy++)
{
if(IsVehicleInRangeOfPoint(xy,20.0,Pos[0],Pos[1],Pos[2]))
{
SetVehicleToRespawn(xy);
}
}
}
}
}
}
return 1;
}
Fiz este cуdigo e coloquei com um SetTimerEx no ongamemodeinit.
Mas aн dб um pouco de lag, entao gostaria de saber se hб alguma public que a SA-MP team oferece para colocar como DetectarCarro(vehicleid);
Й uma faзanha de anti car spam que eu fiz aqui.
Vlw
Re: Gm com Lag :S -
ProKillerpa - 20.05.2013
Colocou pra atualizar o settimer em quantos segundos?
Re: Gm com Lag :S -
BielCOP - 20.05.2013
1 segundo.
Re: Gm com Lag :S -
SlashPT - 20.05.2013
Eu fiz uma ediзгozita para por mais rapido porem aconcelho-te vivamente a usares sistemas de iteradores pois neste caso o codigo ia ficar reduzido a milesimas de segundo para execuзгo se utilizadas tecnicas como devem ser...
pawn Код:
forward
DetectarCarro ( vehicleid ) ;
public
DetectarCarro ( vehicleid )
{
static
Float:PosPlayer [ 3 ] ,
Float:PosVeh [ 3 ] ,
VecArray [ MAX_VEHICLES ] ,
VeiculosPerto ,
Float:px ,
Float:py ,
Float:pz ,
ii ,
i
;
VeiculosPerto = 0 ;
GetVehiclePos ( vehicleid , PosVeh [ 0 ] , PosVeh [ 1 ] , PosVeh [ 2 ] ) ;
for ( i = 0 ; i < MAX_VEHICLES ; i++ )
{
GetVehiclePos ( i , px , py , pz ) ;
px -= PosVeh [ 0 ] , py -= PosVeh [ 1 ] , pz -= PosVeh [ 2 ] ;
if ( ( ( px * px ) + ( py * py ) + ( pz * pz ) ) < ( 10 * 10 ) )
{
VecArray [ VeiculosPerto ] = i ;
VeiculosPerto++;
}
}
if ( VeiculosPerto >= 30 )
{
for ( i = 0 ; i < MAX_PLAYERS ; i++ )
{
if ( IsPlayerInRangeOfPoint ( i , 20 , PosVeh [ 0 ] , PosVeh [ 1 ] , PosVeh [ 2 ] ) )
{
GetPlayerPos ( i , PosPlayer [ 0 ] , PosPlayer [ 1 ] , PosPlayer [ 2 ] ) ;
for ( ii = 0 ; ii <= VeiculosPerto ; ii++ )
{
GetVehiclePos ( VecArray [ ii ] , pz , py , pz ) ;
px -= PosPlayer [ 0 ] , py -= PosPlayer [ 1 ] , pz -= PosPlayer [ 2 ] ;
if ( ( ( px * px ) + ( py * py ) + ( pz * pz ) ) < ( 10 * 10 ) )
{
SetVehicleToRespawn ( VecArray [ ii ] ) ;
}
}
}
}
}
return 1 ;
}
Jб agora eu nгo testei por isso й melhor testares tu..