[RP] Scripting Engine
#1

Hey people!
My Question is how to script engine in a vehicle.

!BUT!
It mustn't be with "TogglePlayerControllable"
You get in the car but you hear no sound of the vehicle. Then you start your engine and you can hear the sound of the vehicle.

Thank you for help and sorry for my bad english
Reply
#2

Use the new Get and SetVehicleParamsEx (wiki helps)
Reply
#3

I don't get it. Can you give me an example?
Reply
#4

pawn Код:
GetVehicleParamsEx(engine, lights, doors, bonnet, boot, objective);
SetVehicleParamsEx(VEHICLE_PARAMS_ON, lights, doors, bonnet, boot, objective);
Reply
#5

Sorry doublepost
Reply
#6

Can you show me something with a command? For example /engine. Look at this:
pawn Код:
if(!strcmp(cmd, "/engine", true))
{
    if(IsPlayerConnected(playerid))
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
        //How does it go on?
        //In my script it goes on with this:                     
        if(!engineOn[GetPlayerVehicleID(playerid)])
        {
               //But this is with Freeze ( TogglePlayerControllable )
               //What do I have to change?
Here is the full /engine part ( if you need )
pawn Код:
if(!strcmp(cmd, "/engine", true))
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                if(!engineOn[GetPlayerVehicleID(playerid)])
                {
                    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
                    {
                        return 1;
                    }
                    if(IsAnOwnableCar(idcar))
                    {
                        if(PlayerInfo[playerid][pPcarkey] == idcar) { }
                        else if(PlayerInfo[playerid][pPcarkey2] == idcar) { }
                        else if(PlayerInfo[playerid][pPcarkey3] == idcar) { }
                        else { return 1; }
                    }
                    if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509)
                    {
                        return 1;
                    }
                    if(idcar == 59 || idcar == 60)
                    {
                        return 1;
                    }
                    if(idcar >= 135 && idcar <= 154)
                    {
                        if(HireCar[playerid] != idcar)
                        {
                            return 1;
                        }
                    }
                    if(IsAPlane(idcar))
                    {
                        return 1;
                    }
                    if(IsAHarvest(idcar))
                    {
                        return 1;
                    }
                    if(IsADrugHarvest(idcar))
                    {
                        return 1;
                    }
                    if(IsASweeper(idcar))
                    {
                        return 1;
                    }
                    if(gEngine[playerid] == 1) { return 1; }

                    new playerveh = GetPlayerVehicleID(playerid);
                    PutPlayerInVehicle(playerid, playerveh, 0);
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s dreht den Schlьssel und versucht den Motor zu starten.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SetTimerEx("StartingTheVehicle",1500,0,"i",playerid);
                    GameTextForPlayer(playerid, "~w~Starte Motor",1500,1);
                    gEngine[playerid] = 1;
                    return 1;
                }
                if(engineOn[GetPlayerVehicleID(playerid)])
                {
                    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
                    {
                        return 1;
                    }
                    if(IsAnOwnableCar(idcar))
                    {
                        if(PlayerInfo[playerid][pPcarkey] == idcar) { }
                        else if(PlayerInfo[playerid][pPcarkey2] == idcar) { }
                        else if(PlayerInfo[playerid][pPcarkey3] == idcar) { }
                        else { return 1; }
                    }
                    if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509)
                    {
                        return 1;
                    }
                    if(idcar == 59 || idcar == 60)
                    {
                        return 1;
                    }
                    if(idcar >= 135 && idcar <= 154)
                    {
                        if(HireCar[playerid] != idcar)
                        {
                            return 1;
                        }
                    }
                    if(IsAHarvest(idcar))
                    {
                        return 1;
                    }
                    if(IsADrugHarvest(idcar))
                    {
                        return 1;
                    }
                    if(IsAPlane(idcar))
                    {
                        return 1;
                    }
                    if(IsASweeper(idcar))
                    {
                        return 1;
                    }
                    engineOn[GetPlayerVehicleID(playerid)] = false;
                    //RemovePlayerFromVehicle(playerid);
                    TogglePlayerControllable(playerid, 0);
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s dreht den Schlьssel und stellt den Motor aus.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    gEngine[playerid] = 0;
/*                  new keycar = PlayerInfo[playerid][pPcarkey];
                    new keycar2 = PlayerInfo[playerid][pPcarkey2];
                    new keycar3 = PlayerInfo[playerid][pPcarkey3];
                    if(IsAnOwnableCar(idcar))
                    {
                        if(keycar == idcar)
                        {
                            for(new i = 0; i < MAX_PLAYERS; i++)
                            {
                                if (IsPlayerConnected(i))
                                {
                                    SetVehicleParamsForPlayer(keycar,i,0,1);
                                }
                                GameTextForPlayer(playerid, "~w~Vehicle~n~~r~Auto-Locked", 10000, 3);
                                CarInfo[keycar][cLock] = 1;
                            }
                        }
                        else if(keycar2 == idcar)
                        {
                            for(new i = 0; i < MAX_PLAYERS; i++)
                            {
                                if (IsPlayerConnected(i))
                                {
                                    SetVehicleParamsForPlayer(keycar2,i,0,1);
                                }
                                GameTextForPlayer(playerid, "~w~Vehicle~n~~r~Auto-Locked", 10000, 3);
                                CarInfo[keycar2][cLock] = 1;
                            }
                        }
                        else if(keycar3 == idcar)
                        {
                            for(new i = 0; i < MAX_PLAYERS; i++)
                            {
                                if (IsPlayerConnected(i))
                                {
                                    SetVehicleParamsForPlayer(keycar3,i,0,1);
                                }
                                GameTextForPlayer(playerid, "~w~Vehicle~n~~r~Auto-Locked", 10000, 3);
                                CarInfo[keycar3][cLock] = 1;
                            }
                        }
                    }*/

                    return 1;
                }
            }
        }
        return 1;
    }
Reply
#7

pawn Код:
if(!strcmp(cmd, "/engine", true))
{
    if(IsPlayerConnected(playerid))
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vid = GetPlayerVehicleID(playerid);
        GetVehicleParamsEx(vid,engine,lights,doors,bonnet,boot,objective);//Get the engine params
        if(engine = 1)//If the engine is on
        {
            SetVehicleParamsEx(vid,0,lights,doors,bonnet,boot,objective);//Turn off the engine
        }
        else//If the engine is off
        {
            SetVehicleParamsEx(vid,1,lights,doors,bonnet,boot,objective);//Turn on the engine
        }
Reply
#8

That is a huge help, thank you! I'll test it now if it works
Reply
#9

Whole system wrote by myself for my own GM...

pawn Код:
new engine, lights, alarm, doors, bonnet, boot, objective;
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new vid = GetPlayerVehicleID(playerid);
    SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    SendClientMessage(playerid, 0xFF00CC, "Use /ste to start the vehicle engine.");
    return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
    new vid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(vid,false,lights,alarm,doors,bonnet,boot,objective);
    SendClientMessage(playerid, 0xFF00CC, "You turned the engine off.");
    return 1;
}
COMMAND:ste(playerid, param[])
{
    new vid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(vid,true,lights,alarm,doors,bonnet,boot,objective);
    SendClientMessage(playerid, 0xFF00CC, "Engine Started. Use /spe to turn the vehicle engine off again.");
    return 1;
}
COMMAND:spe(playerid, param[])
{
    new vid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(vid,false,lights,alarm,doors,bonnet,boot,objective);
    SendClientMessage(playerid, 0xFF00CC, "Engine Stoped. Use /ste to turn the vehicle engine on again.");
    return 1;
}
Reply
#10

Mh now i've got this problem:
pawn Код:
C:\Games\GTA - San Andreas\gamemodes\gtarp.pwn(13387) : error 017: undefined symbol "engine"
C:\Games\GTA - San Andreas\gamemodes\gtarp.pwn(13388) : error 017: undefined symbol "engine"
C:\Games\GTA - San Andreas\gamemodes\gtarp.pwn(13388) : warning 215: expression has no effect
C:\Games\GTA - San Andreas\gamemodes\gtarp.pwn(13388) : error 001: expected token: ";", but found ")"
C:\Games\GTA - San Andreas\gamemodes\gtarp.pwn(13388) : error 029: invalid expression, assumed zero
C:\Games\GTA - San Andreas\gamemodes\gtarp.pwn(13388) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
Problems are in the following two lines:

pawn Код:
...
GetVehicleParamsEx(vid,engine,lights,doors,bonnet,boot,objective);
if(engine = 1)
...
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)