How to remove all vehicles from the script? -
jamesmercer1947 - 10.09.2012
Hello,
There are a lot of veh in my script and I want to remove them all.
How to remove all the vehs from the script?
Thank you
Re: How to remove all vehicles from the script? -
jamesmercer1947 - 10.09.2012
And tell me if you know any FS to remove veh IG.
Re: How to remove all vehicles from the script? -
Faisal_khan - 10.09.2012
Just delete the lines of vehciles under OnGameModeInit.
Re: How to remove all vehicles from the script? -
clarencecuzz - 10.09.2012
STRCMP
pawn Код:
if(strcmp(cmdtext, "/removeallcars", true) == 0)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
DestroyVehicle(i);
}
return 1;
}
ZCMD
pawn Код:
CMD:removeallcars(playerid,params[])
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
DestroyVehicle(i);
}
return 1;
}
Re: How to remove all vehicles from the script? -
antonio112 - 10.09.2012
At the top of your script:
pawn Код:
native IsValidVehicle(vehicleid);
And then the command:
pawn Код:
if(!strcmp(cmdtext,"/removeallveh",true))
{
new count, msg[60];
for(new i; i < MAX_VEHICLES; i++)
{
if(IsValidVehicle(i))
{
DestroyVehicle(i);
count++;
}
}
format(msg, sizeof msg, "You removed %i vehicles from your server.", count);
SendClientMessage(playerid, -1, msg);
return 1;
}
Re: How to remove all vehicles from the script? -
jamesmercer1947 - 10.09.2012
I am talking about permanent vehicle not temp..
Re: How to remove all vehicles from the script? -
clarencecuzz - 10.09.2012
Remove all CreateVehicle, AddStaticVehicle lines from your gamemode under
OnGameModeInit()
Re: How to remove all vehicles from the script? -
Roko_foko - 10.09.2012
Antonio,clarencecuzz. To loop all vehicles, I think, this is the loop :
pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
as vehicle ids start from 1?
Also, how did you know that there exist native IsValidVehicle(vehicleid);? and that isn't included(called,defined) in a_samp include?
Re: How to remove all vehicles from the script? -
antonio112 - 10.09.2012
Quote:
Originally Posted by Roko_foko
Antonio,clarencecuzz. To loop all vehicles, I think, this is the loop :
pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
as vehicle ids start from 1?
Also, how did you know that there exist native IsValidVehicle(vehicleid);? and that isn't included(called,defined) in a_samp include?
|
Does it matter if the count starts from 0 or 1 ? It checks if the vehicle is valid or not and then removes it, so it doesn't matter 0 or 1.
I knew about IsValidVehicle from wiki:
https://sampwiki.blast.hk/wiki/IsValidVehicle
But, you can also do something like, check vehicle model, see if it's > 0 and if that's true, the vehicle is valid.
Re: How to remove all vehicles from the script? -
Roko_foko - 10.09.2012
Quote:
Originally Posted by antonio112
Does it matter if the count starts from 0 or 1 ? It checks if the vehicle is valid or not and then removes it, so it doesn't matter 0 or 1.
I knew about IsValidVehicle from wiki: https://sampwiki.blast.hk/wiki/IsValidVehicle
But, you can also do something like, check vehicle model, see if it's > 0 and if that's true, the vehicle is valid. 
|
Your loop won't check last vehicle( i= MAX_VEHICLES). I know, there is low possibility that there will be number of vehicles that reaches the limit, but it is still a mistake xD. Thank your for answer.