SA-MP Forums Archive
How do I make it so when all vehicles spawn in when the server start the bicyckles are "on" - 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)
+--- Thread: How do I make it so when all vehicles spawn in when the server start the bicyckles are "on" (/showthread.php?tid=522076)



How do I make it so when all vehicles spawn in when the server start the bicyckles are "on" - Don_Cage - 25.06.2014

Like the title say..
Right now you must /engine the bicycle which is kinda weird.. So I'm wondering how I can make it so they are allways on?
Here is my OnVehicleSpawn..
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    new string[64];
    if(IsAnOwnableCar(vehicleid))
    {
        if(CarInfo[vehicleid][cPaintjob] != 999)
        {
            ChangeVehiclePaintjob(vehicleid, CarInfo[vehicleid][cPaintjob]);
        }
        SetVehicleModifications(vehicleid);
        SetVehicleVirtualWorld(vehicleid, CarInfo[vehicleid][cVirWorld]);
        new reg = CarInfo[vehicleid][cReg];
        format(string, sizeof(string),"{157DEC}LS{FF0000}-%d-",reg);
        SetVehicleNumberPlate(vehicleid, string);
        SetVehicleToRespawn(vehicleid);
    }
    if(IsARentableVeh(vehicleid))
    {
        Gas[vehicleid] = 10;
    }
    if(IsACopCar(vehicleid))
    {
        format(string, sizeof(string),"UNIT %d",vehicleid);
        //SetVehicleToRespawn(vehicleid);
        SetVehicleNumberPlate(vehicleid, string);
        //SetVehicleToRespawn(vehicleid);
    }
    if(IsNgCar(vehicleid))
    {
        format(string, sizeof(string),"NG %d",vehicleid);
        //SetVehicleToRespawn(vehicleid);
        SetVehicleNumberPlate(vehicleid, string);
       // SetVehicleToRespawn(vehicleid);
    }
    if(IsAGovernmentCar(vehicleid))
    {
        format(string, sizeof(string),"GOV %d",vehicleid);
        //SetVehicleToRespawn(vehicleid);
        SetVehicleNumberPlate(vehicleid, string);
        //SetVehicleToRespawn(vehicleid);
    }
    if(IsASalesVehicle(vehicleid))
    {
        format(string, sizeof(string),"{FF0000}FOR SALE");
        //SetVehicleToRespawn(vehicleid);
        SetVehicleNumberPlate(vehicleid, string);
        //SetVehicleToRespawn(vehicleid);
    }
    gEngine[vehicleid] = 0;
    engineOn[vehicleid] = 0;
    if(IsModelABycicle(vehicleid))
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        engineOn[vehicleid] = true;
        gEngine[vehicleid] = true;
        engineOn[vehicleid] = true;
        RestartCar(vehicleid);
        return 1;
    }
    return 1;
}



Re: How do I make it so when all vehicles spawn in when the server start the bicyckles are "on" - RedFusion - 25.06.2014

OnVehicleSpawn is only called when a vehicle respawns.
So you need to set the engine parameter to on when the vehicle is created, too.

pawn Код:
new vehicleid = CreateVehicle(....);
if(IsModelABycicle(vehicleid))
{
 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
 SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}



Re: How do I make it so when all vehicles spawn in when the server start the bicyckles are "on" - Don_Cage - 26.06.2014

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
OnVehicleSpawn is only called when a vehicle respawns.
So you need to set the engine parameter to on when the vehicle is created, too.

pawn Код:
new vehicleid = CreateVehicle(....);
if(IsModelABycicle(vehicleid))
{
 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
 SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}
Thanks