How to remove all vehicles from the script?
#1

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
Reply
#2

And tell me if you know any FS to remove veh IG.
Reply
#3

Just delete the lines of vehciles under OnGameModeInit.
Reply
#4

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;
}
Reply
#5

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;
}
Reply
#6

I am talking about permanent vehicle not temp..
Reply
#7

Remove all CreateVehicle, AddStaticVehicle lines from your gamemode under OnGameModeInit()
Reply
#8

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?
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)