SA-MP Forums Archive
Vehicle engine problem - 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: Vehicle engine problem (/showthread.php?tid=335854)



Vehicle engine problem - Xaviour212 - 20.04.2012

I was create a new function for a vehicle engine

pawn Код:
forward SetVehicleEngine(vehicleid, status);
public SetVehicleEngine(vehicleid, status)
{
    new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(vehicleid, status, lights, alarm, doors, bonnet, boot, objective);
    vInfo[vehicleid][vEngine] = status;
    return 1;
}
When I compile, its not showing a error but when I try in my server.. it doesnt work. How to fix it


Re: Vehicle engine problem - Bogdan1992 - 20.04.2012

You better use,
pawn Код:
public SetVehicleEngine(playerid, status){
new vehicleid = GetPlayerVehicleID(playerid);
//...rest of the code.
}



Re: Vehicle engine problem - Xaviour212 - 20.04.2012

Quote:
Originally Posted by Bogdan1992
Посмотреть сообщение
You better use,
pawn Код:
public SetVehicleEngine(playerid, status){
new vehicleid = GetPlayerVehicleID(playerid);
//...rest of the code.
}
I has use your function.. but its still not working

I try with OnPlayerUpdate

pawn Код:
stock GetVehicleEngine(vehicleid) return vInfo[vehicleid][vEngine];

public OnPlayerUpdate(playerid)
{
    new Keys,ud,lr;
    GetPlayerKeys(playerid,Keys,ud,lr);
    if(IsPlayerInAnyVehicle(playerid))
    {
        new v = GetPlayerVehicleID(playerid);
        if(Keys == KEY_FIRE)
        {
            if(GetVehicleEngine(v) != 1)
            {
                new rand = random(2);
                SetVehicleEngine(playerid, rand);
                if(rand == 1)
                {
                    SendClientMessage(playerid, Green2, "Engine on, ");
                }
                else
                {
                    SendClientMessage(playerid, Red, "Busy, try again");
                }
                return 1;
            }
        }
    }
    return 1;
}