MOTOR Befehl

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 ich brauche mal eure Hilfe bei meinem Motor Befehl. Ich habe ein Autohaus was wie folgt geladen wird




    forward OnPlayerCarsLoad(playerid);
    public OnPlayerCarsLoad(playerid)
    {
    for(new i=0; i<cache_num_rows(); i++)
    {
    new id = getFreeCarID();
    cache_get_value_name_int(i, "id", cInfo[id][db_id] );//Integer
    cache_get_value_name_int(i, "model", cInfo[id][model]);//Integer
    cache_get_value_name_int(i, "besitzer", cInfo[id][besitzer]);//Integer
    cache_get_value_name_float(i, "x", cInfo[id][c_x]); //Float
    cache_get_value_name_float(i, "y", cInfo[id][c_y]);//Float
    cache_get_value_name_float(i, "z", cInfo[id][c_z]);//Float
    cache_get_value_name_float(i, "r", cInfo[id][c_r]);//Float
    cache_get_value_name_int(i, "c1", cInfo[id][color1]);//Integer
    cache_get_value_name_int(i, "c2", cInfo[id][color2]);//Integer
    cache_get_value_name_int(i, "c3", cInfo[id][color3]);//Integer

    cache_get_value_name_int(i, "c_gesperrt", cInfo[id][c_gespeert] );//Integer
    if(cInfo[id][c_gespeert] == 0)
    {
    cInfo[id][id_x] = CreateVehicle(cInfo[id][model],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],cInfo[id][color1],cInfo[id][color2],cInfo[id][color3]);
    }
    }
    return 1;
    }


    Gerne möchte ich nun das die User auch Ihren Motor von Ihrem Fahrzeug starten können allerdings komme ich nicht sehr weit worum ich dann um Hilfe bitte.


    Hier mein aktueller Motor Befehl




    ocmd:motor(playerid,params[])
    {



    if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)return
    SendClientMessage(playerid,COLOR_RED,"Du bist nicht der Fahrer eines Fahrzeugs.");



    new Vehicle = GetPlayerVehicleID(playerid), engine,lights,alarm,doors,bonnet,boot,objective;
    if(IsAFahrschule(Vehicle) && (PlayerInfo[playerid][pFahrschulmotor]==0))
    {
    SendClientMessage(playerid,COLOR_RED,"Es findet kein Termin in der Fahrschule statt.");
    return 1;
    }
    if(IsAFahrschule(Vehicle) && (PlayerInfo[playerid][pFahrschulmotor]==1))
    {
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    DestroyVehicle(playerid);
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));
    PlayerInfo[playerid][pFahrschulmotor]=0;
    }
    }
    if(IsAbus(Vehicle) && PlayerInfo[playerid][pJob] == 1)
    {
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],30,"%s",getPlayerName(playerid));
    }
    }
    return 1;
    }

  • Das kannst du so machen:


    ocmd:motor(playerid,params[])
    {
    if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)return
    SendClientMessage(playerid,COLOR_RED,"Du bist nicht der Fahrer eines Fahrzeugs.");
    new Vehicle = GetPlayerVehicleID(playerid), engine,lights,alarm,doors,bonnet,boot,objective;

    //Fahrschule
    if(IsAFahrschule(Vehicle))
    {
    if(PlayerInfo[playerid][pFahrschulmotor]==0)
    {
    SendClientMessage(playerid,COLOR_RED,"Es findet kein Termin in der Fahrschule statt.");
    return 1;
    }
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    DestroyVehicle(playerid);
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));
    PlayerInfo[playerid][pFahrschulmotor]=0;
    }
    return 1;
    }

    //Bus
    if(IsAbus(Vehicle) && PlayerInfo[playerid][pJob] == 1)
    {
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],30,"%s",getPlayerName(playerid));
    }
    return 1;
    }

    //Private Fahrzeuge
    for(new id = 0; id < sizeof(cInfo); id++)
    {
    if(cInfo[id][id_x] == Vehicle)
    {
    if(cInfo[id][besitzer] == PlayerInfo[playerid][p_id])
    {
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    }
    }
    else
    {
    SendClientMessage(playerid, 0xFF0000FF, "Dieses Fahrzeug gehört nicht dir.");
    }
    return 1;
    }
    }
    return 1;
    }

    3HZXdYd.png

    Einmal editiert, zuletzt von Jeffry ()

  • Hallo @Jeffry ,


    leider ist wohl noch ein Fehler in den Motor Befehl enthalten. Ich kann von einem Fahrzeug was ich besitze den Motor starten aber nicht bei dem zweiten.


    Im Chat und in den Logs wird mir nichts angezeigt was auf einen Fehler im Motor System hinweißt.

  • Ich hab grade gesehen, dass ich in der Schleife die falsche Variable mitkopiert habe (i anstatt id).
    Versuche es so:
    ocmd:motor(playerid,params[])
    {
    if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)return
    SendClientMessage(playerid,COLOR_RED,"Du bist nicht der Fahrer eines Fahrzeugs.");
    new Vehicle = GetPlayerVehicleID(playerid), engine,lights,alarm,doors,bonnet,boot,objective;

    //Fahrschule
    if(IsAFahrschule(Vehicle))
    {
    if(PlayerInfo[playerid][pFahrschulmotor]==0)
    {
    SendClientMessage(playerid,COLOR_RED,"Es findet kein Termin in der Fahrschule statt.");
    return 1;
    }
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    DestroyVehicle(playerid);
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));
    PlayerInfo[playerid][pFahrschulmotor]=0;
    }
    return 1;
    }

    //Bus
    if(IsAbus(Vehicle) && PlayerInfo[playerid][pJob] == 1)
    {
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],30,"%s",getPlayerName(playerid));
    }
    return 1;
    }

    //Private Fahrzeuge
    for(new id = 0; id < sizeof(cInfo); id++)
    {
    if(cInfo[id][id_x] == Vehicle)
    {
    if(cInfo[id][besitzer] == PlayerInfo[playerid][p_id])
    {
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    }
    }
    else
    {
    SendClientMessage(playerid, 0xFF0000FF, "Dieses Fahrzeug gehört nicht dir.");
    }
    return 1;
    }
    }
    return 1;
    }
    Falls du das bereits abgeändert hattest, sitzt du im Fahrzeug?

  • In Schleifen bin ich noch nicht sogut. Aber es hat nun geklappt


    // Edit


    Ich muss das Thema doch nochmal aufrollen


    Funktioniert leider noch nicht Richtig. Bzw nur bei einem Spieler aber bei kein anderen



    ocmd:motor(playerid,params[])
    {
    if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)return
    SendClientMessage(playerid,COLOR_RED,"Du bist nicht der Fahrer eines Fahrzeugs.");
    new Vehicle = GetPlayerVehicleID(playerid), engine,lights,alarm,doors,bonnet,boot,objective;



    //Fahrschule
    if(IsAFahrschule(Vehicle))
    {
    if(PlayerInfo[playerid][pFahrschulmotor]==0)
    {
    SendClientMessage(playerid,COLOR_RED,"Es findet kein Termin in der Fahrschule statt.");
    return 1;
    }
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));
    DestroyVehicle(playerid);



    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));
    PlayerInfo[playerid][pFahrschulmotor]=0;
    }
    return 1;
    }



    //Bus
    if(IsAbus(Vehicle) && PlayerInfo[playerid][pJob] == 1)
    {
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));
    }
    return 1;
    }
    if(IsAOamtCar(Vehicle) && PlayerInfo[playerid][pLeader] == 1)
    {
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));
    }
    else
    {
    SetVehicleParamsEx(Vehicle,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));
    }
    return 1;
    }



    //Private Fahrzeuge



    for(new id = 0; id < sizeof(cInfo); id++)
    {
    if(cInfo[id][id_x] == Vehicle)
    {



    if(cInfo[id][besitzer] == PlayerInfo[playerid][p_id])
    {
    GetVehicleParamsEx(Vehicle, engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == 1)
    {
    SetVehicleParamsEx(Vehicle,0,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~r~aus!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(playerid));



    }
    else
    { new pID;
    SetVehicleParamsEx(Vehicle,1,lights,alarm,doors,bonnet,boot,objective);
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Motor ~g~an!", 2000, 5);
    format(LastDriver[Vehicle],50,"%s",getPlayerName(pID));



    }
    }
    else
    {
    SendClientMessage(playerid, 0xFF0000FF, "Dieses Fahrzeug gehört nicht dir.");
    }
    return 1;
    }
    SendClientMessage(playerid,COLOR_RED,"Du besitzt keinen Schlüssel für dieses Fahrzeug.");
    return 1;
    }
    return 1;
    }

    Einmal editiert, zuletzt von robbi2304 ()

  • Dafür habe ich dir diese Meldung hinzugefügt:
    SendClientMessage(playerid, 0xFF0000FF, "Dieses Fahrzeug gehört nicht dir.");
    Die kannst du bearbeiten, auf den Text den du willst.


    Entferne Zeile 109 und 110 (SendClientMessage und return 1) in obigem Code, sonst wird die Schleife immer nach dem ersten Fahrzeug beendet.

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen