[Scripting Request]Vehicle Cleaner - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Scripting Request]Vehicle Cleaner (
/showthread.php?tid=152506)
[Scripting Request]Vehicle Cleaner -
Jay. - 04.06.2010
Hey, Well i've made a vehicle system for my server, But lots of players are spawning to many cars and it lags like hell
Can somone make me a vehicle cleaner that clears all of the vehicles when someone types a command, Please this is inportn't
Thanks alot [XS]XtremE_
Re: [Scripting Request]Vehicle Cleaner -
Rac3r - 04.06.2010
pawn Код:
public OnGameModeInit()
{
SetTimer("DestroyVehicles", 1000*60, 1);
return 1;
}
pawn Код:
forward DestroyVehicles();
public DestroyVehicles()
{
new VOID;
for(new x; x< MAX_VEHICLES; x++)
{
VOID=0;//reset to 0 each vehicle
for(new i; i< MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInVehicle(i, x))
{
VOID=1;//player is in vehicle, void it
}
}
if(!VOID)DestroyVehicle(x);//player is not in vehicle
}
}
Re: [Scripting Request]Vehicle Cleaner -
Jay. - 04.06.2010
Quote:
Originally Posted by Rac3r
Quick bit of code I've just written.
(Either download foreach.nc by Y-Less, or replace it with a loop for all players. Get foreach :P
pawn Код:
//put this OnGameModeInit (or FilterscriptInit ?) SetTimer("DestroyVehicles", 1000*60, 1); // timer, every 60 seconds scan vehicles
//put this at bottom of script DestroyVehicles() { new VOID; for(new i; i < MAX_VEHICLES; i++) { VOID=0;//reset to 0 each vehicle foreach(Player, i) { if(IsPlayerInVehicle(i, veh)) { VOID=1;//player is in vehicle, void it } } if(!VOID)DestroyVehicle(i);//player is not in vehicle } }
|
Thanks are test it
Re: [Scripting Request]Vehicle Cleaner -
Rac3r - 04.06.2010
Updated post, I'm a tit, I put player as i, vehicle as i. Doh!
Re: [Scripting Request]Vehicle Cleaner -
Jay. - 04.06.2010
Quote:
Originally Posted by Rac3r
Updated post, I'm a tit, I put player as i, vehicle as i. Doh!
|
lol, Ok.. thanks
Hmm errors
Код:
C:\Users\(lewis)\Desktop\New Folder (3)\[XS].pwn(47) : error 017: undefined symbol "DestroyVehicles"
C:\Users\(lewis)\Desktop\New Folder (3)\[XS].pwn(53) : error 017: undefined symbol "foreach"
C:\Users\(lewis)\Desktop\New Folder (3)\[XS].pwn(55) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Errors.
Re: [Scripting Request]Vehicle Cleaner -
Rac3r - 04.06.2010
Updated lol
Re: [Scripting Request]Vehicle Cleaner -
Nero_3D - 04.06.2010
pawn Код:
if(strcmp("destroyvehicle", cmdtext[1], true) == 0) {
for(new v = 1, i; v != MAX_VEHICLES; v++) {
for(i = 0; i != MAX_PLAYERS; i++) {
if(IsPlayerInVehicle(i, veh)) {
break;
}
if(i == MAX_PLAYERS) DestroyVehicle(v);
}
}
}