Auto starten

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Hallo Com.


    Habe eine frage


    Wie kann ich ein auto mit der taste 2 starten?


    if(strcmp(cmd, "/motor", true) == 0)
    {
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
    new engine,lights,alarm,doors,bonnet,boot,objective;
    new vid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(vid != INVALID_VEHICLE_ID)
    {
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    SendClientMessage(playerid, COLOR_LIGHTBLUE,"Motor ausgeschaltet");
    }
    else
    {
    SendClientMessage(playerid, COLOR_LIGHTBLUE,"Du startest den Motor");
    SetTimerEx("motoran",1000,0, "i", playerid);
    }
    }
    return 1;
    }

  • sollte so funken.. hab nicht probiert .. :)


    new engine[MAX_VEHICLES];


    unter Onplayerkeystatechange



    if((newkeys == KEY_SUBMISSION)
    {
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
    new engine,lights,alarm,doors,bonnet,boot,objective;
    new vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine[vehicleid] == 0)
    {
    SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    engine[vehicleid] = 1;
    }
    else
    {
    SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    engine[vehicleid] = 0;
    }
    }
    }


  • new bool:enginebool[MAX_VEHICLES] = false;


    if(strcmp(cmd,"/e",true) == 0)
    {
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,F_O,"Du bist nicht der faher");
    new vehicleid = GetPlayerVehicleID(playerid);
    if(Gas[vehicleid] <= 0.0) return SendClientMessage(playerid,COLOR_RED,"Der Tank ist leer!");
    if(enginebool[vehicleid] == false)
    {
    SetVehicleEngineOn(vehicleid);
    enginebool[vehicleid] = true;
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    }
    else
    {
    SetVehicleEngineOff(vehicleid);
    enginebool[vehicleid] = false;
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    }
    return 1;
    }


    SetVehicleEngineOn(vehicleid)
    {
    new engine,lights,alarm,doors,bonnet,boot22,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot22,objective);
    SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot22,objective);
    }
    SetVehicleEngineOff(vehicleid)
    {
    new engine,lights,alarm,doors,bonnet,boot22,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot22,objective);
    SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot22,objective);
    }


    Bitte schön ein kommpletes motorsystem

  • Armin_x3 war wohl schneller :)




    Dann so ..




    forward Start(playerid);
    #define yellow 0xFFFF00AA


    new carstarted[MAX_PLAYERS];


    public OnPlayerStateChange(playerid, newstate, oldstate)
    { if(newstate==PLAYER_STATE_DRIVER)
    TogglePlayerControllable(playerid,false);
    SendClientMessage(playerid,yellow,"zum starten taste 2 drücken");
    carstarted[playerid] = 0;
    return 1;
    }


    public Start(playerid)
    {
    new RandomlyStart = random(2);
    if(IsPlayerConnected(playerid))
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    switch(RandomlyStart)
    {
    case 0:
    {
    TogglePlayerControllable(playerid,true);
    SendClientMessage(playerid,yellow,"Auto ist gestartet");
    carstarted[playerid] = 1;
    }
    case 1:
    {
    SendClientMessage(playerid,yellow,"Fahrzeug erfolgreich gestartet");
    }
    }
    }
    }
    return 1;
    }


    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    if((newkeys & (KEY_SUBMISSION)) == (KEY_SUBMISSION))
    {
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
    if(carstarted[playerid] == 0)
    SendClientMessage(playerid,yellow,"Fahrzeug konnte nicht gestartet werden");
    SetTimerEx("Start",2790,0,"i",playerid);


    }
    }
    else
    {
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {


    RemovePlayerFromVehicle(playerid);
    TogglePlayerControllable(playerid, true);
    }
    }
    }
    return 1;


    }

  • (17175) : error 017: undefined symbol "SetVehicleEngineOn"
    (17181) : error 017: undefined symbol "SetVehicleEngineOff"
    (17188) : error 017: undefined symbol "SetVehicleEngineOn"
    (17191) : error 017: undefined symbol "vehicleid"
    (17192) : error 017: undefined symbol "vehicleid"
    (17194) : error 017: undefined symbol "SetVehicleEngineOff"
    (17197) : error 017: undefined symbol "vehicleid"
    (17198) : error 017: undefined symbol "vehicleid"
    Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



    8 Errors.

  • SetVehicleEngineOn(vehicleid)
    {
    new engine,lights,alarm,doors,bonnet,boot22,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot22,objective);
    SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot22,objective);
    }
    SetVehicleEngineOff(vehicleid)
    {
    new engine,lights,alarm,doors,bonnet,boot22,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot22,objective);
    SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot22,objective);
    }


    die 2 sachen müssen ganz unten hin sorry vergessen zu erwähnen ^^
    pack an besten unter den stocks