SA-MP Forums Archive
Engine System - 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: Engine System (/showthread.php?tid=249201)



Engine System - Bates - 17.04.2011

Hi! I need help with my engine system. Here is the command

pawn Код:
command(engine, playerid, params[])
{
    new string[128];
    new newcar;
    newcar = GetPlayerVehicleID(playerid);
    new VehicleName[128];

    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not the driver.");
    }
    else
    {
        if(CarSystem[newcar][cEngine] == 0 )
        {
            format(string, sizeof(string), "%s spins the %s's key into the ignition and turns on the engine.", UnderscoreToSpaceName(playerid), VehicleName[GetVehicleModel(newcar)-400]);
            NearByMessage( playerid, NICESKY, string);
            new engine,lights,alarm,doors,bonnet,boot,objective;
            GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(newcar,1,1,alarm,doors,bonnet,boot,objective);
            SendClientMessage(playerid, WHITE, "Engine {62E36A}ON!");
            CarSystem[newcar][cEngine] = 1;
            return 1;
        }
        else
        {
            format(string, sizeof(string), "%s spins the %s's key into the ignition and turns off the engine.", UnderscoreToSpaceName(playerid), VehicleName[GetVehicleModel(newcar)-400]);
            NearByMessage( playerid, NICESKY, string);
            new engine,lights,alarm,doors,bonnet,boot,objective;
            GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(newcar,0,0,alarm,doors,bonnet,boot,objective);
            SendClientMessage(playerid, WHITE, "Engine {F24B5C}OFF!");
            CarSystem[newcar][cEngine] = 0;
        }
    }
    return true;
}
And when you enter a vehicle,

pawn Код:
if(CarSystem[newcar][cEngine] == 0 )
        {
            new engine,lights,alarm,doors,bonnet,boot,objective;
            GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(newcar,0,0,alarm,doors,bonnet,boot,objective);
            SendClientMessage(playerid, COLOR_GREY, "Turn on this vehicles engine by typing /eon.");
        }
        else
        {
            new engine,lights,alarm,doors,bonnet,boot,objective;
            GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(newcar,1,1,alarm,doors,bonnet,boot,objective);
        }
Can't add whole OnPlayerStateChange, it's kinda much code. Anyways, if i'm outside a vehicle i get the "You are not the driver" message, but if im inside a car, nothing happens.


Re: Engine System - Stigg - 17.04.2011

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
?


Re: Engine System - Bates - 17.04.2011

Ye, i added it but took it away to see if that caused the problem. It wasn't.


Re: Engine System - Bates - 17.04.2011

Remove this post pelase.


Re: Engine System - nemesis_567 - 17.04.2011

CarSystem[newcar][cEngine]. I don't recommend this. You should use a function to determine the vehicle parameters.