Warum geht der autokauf dialog nichtmehr? :/

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
  • Hey,
    mein autohaus hat super funktiniert aber als ich das tachosystem angefangen hab gehts nichtmehr...
    Aber ich schick mal zur sicherheit die Dialoge hier rein.


    Das ifnewstate==change_driver:

    if(newstate==PLAYER_STATE_DRIVER)
    {
    new vID=GetPlayerVehicleID(playerid);
    new vModel=GetVehicleModel(vID);


    for(new i=0; i<sizeof(autosOhneMotor); i++)
    {
    if(autosOhneMotor[i]!=vModel)continue;
    new tmp_engine,
    tmp_lights,
    tmp_alarm,
    tmp_doors,
    tmp_bonnet,
    tmp_boot,
    tmp_objective;
    //Motor an/ausschalten
    GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
    SetVehicleParamsEx(vID, 1, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
    }


    for(new i=0; i<sizeof(ahCars); i++)
    {
    if(ahCars[i][id_x]!=vID)continue;
    //Verkaufsprozess
    SetPVarInt(playerid,"buyCarID",i);
    new string[256];
    format(string,sizeof(string),"Möchten sie das Fahrzeug für %i$ kaufen?",ahCars[i][c_preis]);
    ShowPlayerDialog(playerid,DIALOG_AUTOHAUS,DIALOG_STYLE_MSGBOX,"Autoverkauf",string,"Ja","Nein");
    break;
    }
    return 1;
    }
    return 1;
    }


    Der Dialog:

    if(dialogid==DIALOG_AUTOHAUS)
    {
    if(response)
    {
    //Autoverkauf
    new id=GetPVarInt(playerid,"buyCarID");
    if(GetPlayerMoneyEx(playerid)<ahCars[id][c_preis])
    {
    SendClientMessage(playerid,COLOR_RED,"Du hast nicht genügend Geld.");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    GivePlayerMoneyEx(playerid,-ahCars[id][c_preis]);
    createPlayerCar(playerid,ahCars[id][model],ahInfo[ahCars[id][ah_id]][s_x],ahInfo[ahCars[id][ah_id]][s_y],ahInfo[ahCars[id][ah_id]][s_z],ahInfo[ahCars[id][ah_id]][s_r]);
    SendClientMessage(playerid,COLOR_GREEN,"Du hast das Auto erfolgreich gekauft");
    RemovePlayerFromVehicle(playerid);
    }
    else
    {
    RemovePlayerFromVehicle(playerid);
    SendClientMessage(playerid,COLOR_RED,"Du hast den Kauf abgebrochen");
    }
    return 1;
    }

  • public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    if(newstate == PLAYER_STATE_DRIVER)
    {
    for(new i = 0; i < sizeof(LVPDCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == LVPDCars[i])
    {
    if(sInfo[playerid][fraktion] == 2)
    {
    return 1;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Polizist");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }
    }
    }

    if(oldstate == PLAYER_STATE_DRIVER)
    {
    TextDrawHideForPlayer(playerid, Textdraw7[playerid]);
    }

    if(oldstate==PLAYER_STATE_DRIVER)
    {
    PlayerTextDrawHide(playerid, Textdraw8[playerid]);
    }

    if(oldstate == PLAYER_STATE_DRIVER)
    {
    PlayerTextDrawHide(playerid, Textdraw9[playerid]);
    }


    if(oldstate==PLAYER_STATE_DRIVER)
    {
    PlayerTextDrawHide(playerid, Textdraw10[playerid]);
    }

    if(oldstate == PLAYER_STATE_DRIVER)
    {
    PlayerTextDrawHide(playerid, Textdraw11[playerid]);
    }


    if(oldstate==PLAYER_STATE_DRIVER)
    {
    PlayerTextDrawHide(playerid, Textdraw12[playerid]);
    }


    if(oldstate==PLAYER_STATE_DRIVER)
    {
    PlayerTextDrawHide(playerid, Textdraw13[playerid]);
    }


    if(newstate == PLAYER_STATE_DRIVER)
    {
    for(new i = 0; i < sizeof(MedicalCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == MedicalCars[i])
    {
    if(sInfo[playerid][fraktion] == 15)
    {
    return 1;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Sanitäter");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }
    }
    }


    if(newstate == PLAYER_STATE_DRIVER)
    {
    for(new i = 0; i < sizeof(OrdnungsAmtCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == OrdnungsAmtCars[i])
    {
    if(sInfo[playerid][fraktion] == 5)
    {
    return 1;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Mitglied des Ordnungsamtes");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }
    }
    }

    if(newstate == PLAYER_STATE_DRIVER)
    {
    for(new i = 0; i < sizeof(HitmanCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == HitmanCars[i])
    {
    if(sInfo[playerid][fraktion] == 7)
    {
    return 1;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Hitman");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }
    }
    }
    new w = GetPlayerWeapon(playerid);
    if((newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER) && w != 25 && w != 29 && w != 30 && w != 31) SetPlayerArmedWeapon(playerid, 0);

    if(newstate == PLAYER_STATE_DRIVER)
    {
    for(new i = 0; i < sizeof(SanNewsCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == SanNewsCars[i])
    {
    if(sInfo[playerid][fraktion] == 6)
    {
    return 1;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Mitglied der San News");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }
    }
    }

    if(newstate == PLAYER_STATE_DRIVER)
    {
    for(new i = 0; i < sizeof(Busse); i++)
    {
    if(GetPlayerVehicleID(playerid) == Busse[i])
    {
    if(sInfo[playerid][beruf] == 0)
    {
    return 1;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Busfahrer");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }
    }
    }

    if(newstate == PLAYER_STATE_DRIVER)
    {
    //tacho textdraw
    TextDrawShowForPlayer(playerid, Textdraw6);
    TextDrawShowForPlayer(playerid, Textdraw7[playerid]);
    PlayerTextDrawShow(playerid, Textdraw8[playerid]);
    PlayerTextDrawShow(playerid, Textdraw9[playerid]);
    PlayerTextDrawShow(playerid, Textdraw10[playerid]);
    PlayerTextDrawShow(playerid, Textdraw11[playerid]);
    PlayerTextDrawShow(playerid, Textdraw12[playerid]);
    PlayerTextDrawShow(playerid, Textdraw13[playerid]);
    return 1;
    }


    if(newstate==PLAYER_STATE_DRIVER)
    {
    new vID=GetPlayerVehicleID(playerid);
    new vModel=GetVehicleModel(vID);


    for(new i=0; i<sizeof(autosOhneMotor); i++)
    {
    if(autosOhneMotor[i]!=vModel)continue;
    new tmp_engine,
    tmp_lights,
    tmp_alarm,
    tmp_doors,
    tmp_bonnet,
    tmp_boot,
    tmp_objective;
    //Motor an/ausschalten
    GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
    SetVehicleParamsEx(vID, 1, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
    }


    for(new i=0; i<sizeof(ahCars); i++)
    {
    if(ahCars[i][id_x]!=vID)continue;
    //Verkaufsprozess
    SetPVarInt(playerid,"buyCarID",i);
    new string[256];
    format(string,sizeof(string),"Möchten sie das Fahrzeug für %i$ kaufen?",ahCars[i][c_preis]);
    ShowPlayerDialog(playerid,DIALOG_AUTOHAUS,DIALOG_STYLE_MSGBOX,"Autoverkauf",string,"Ja","Nein");
    break;
    }
    return 1;
    }
    return 1;
    }

  • Siehste. ;)


    So sollte es klappen:

    Spoiler anzeigen
    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    if(oldstate == PLAYER_STATE_DRIVER)
    {
    TextDrawHideForPlayer(playerid, Textdraw7[playerid]);
    PlayerTextDrawHide(playerid, Textdraw8[playerid]);
    PlayerTextDrawHide(playerid, Textdraw9[playerid]);
    PlayerTextDrawHide(playerid, Textdraw10[playerid]);
    PlayerTextDrawHide(playerid, Textdraw11[playerid]);
    PlayerTextDrawHide(playerid, Textdraw12[playerid]);
    PlayerTextDrawHide(playerid, Textdraw13[playerid]);
    }

    if(newstate == PLAYER_STATE_DRIVER)
    {
    for(new i = 0; i < sizeof(LVPDCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == LVPDCars[i])
    {
    if(sInfo[playerid][fraktion] == 2)
    {
    goto AFTERCHECK;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Polizist");
    RemovePlayerFromVehicle(playerid);
    goto AFTERCHECK;
    }
    }
    }
    for(new i = 0; i < sizeof(MedicalCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == MedicalCars[i])
    {
    if(sInfo[playerid][fraktion] == 15)
    {
    goto AFTERCHECK;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Sanitäter");
    RemovePlayerFromVehicle(playerid);
    goto AFTERCHECK;
    }
    }
    }
    for(new i = 0; i < sizeof(OrdnungsAmtCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == OrdnungsAmtCars[i])
    {
    if(sInfo[playerid][fraktion] == 5)
    {
    goto AFTERCHECK;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Mitglied des Ordnungsamtes");
    RemovePlayerFromVehicle(playerid);
    goto AFTERCHECK;
    }
    }
    }
    for(new i = 0; i < sizeof(HitmanCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == HitmanCars[i])
    {
    if(sInfo[playerid][fraktion] == 7)
    {
    goto AFTERCHECK;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Hitman");
    RemovePlayerFromVehicle(playerid);
    goto AFTERCHECK;
    }
    }
    }
    for(new i = 0; i < sizeof(SanNewsCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == SanNewsCars[i])
    {
    if(sInfo[playerid][fraktion] == 6)
    {
    goto AFTERCHECK;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Mitglied der San News");
    RemovePlayerFromVehicle(playerid);
    goto AFTERCHECK;
    }
    }
    }
    for(new i = 0; i < sizeof(Busse); i++)
    {
    if(GetPlayerVehicleID(playerid) == Busse[i])
    {
    if(sInfo[playerid][beruf] == 0)
    {
    goto AFTERCHECK;
    }
    else
    {
    SendClientMessage(playerid, COLOR_BLUE, "Du bist kein Busfahrer");
    RemovePlayerFromVehicle(playerid);
    goto AFTERCHECK;
    }
    }
    }
    AFTERCHECK:
    //tacho textdraw
    TextDrawShowForPlayer(playerid, Textdraw6);
    TextDrawShowForPlayer(playerid, Textdraw7[playerid]);
    PlayerTextDrawShow(playerid, Textdraw8[playerid]);
    PlayerTextDrawShow(playerid, Textdraw9[playerid]);
    PlayerTextDrawShow(playerid, Textdraw10[playerid]);
    PlayerTextDrawShow(playerid, Textdraw11[playerid]);
    PlayerTextDrawShow(playerid, Textdraw12[playerid]);
    PlayerTextDrawShow(playerid, Textdraw13[playerid]);

    new vID=GetPlayerVehicleID(playerid);
    new vModel=GetVehicleModel(vID);

    for(new i=0; i<sizeof(autosOhneMotor); i++)
    {
    if(autosOhneMotor[i]!=vModel)continue;
    new tmp_engine,
    tmp_lights,
    tmp_alarm,
    tmp_doors,
    tmp_bonnet,
    tmp_boot,
    tmp_objective;
    //Motor an/ausschalten
    GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
    SetVehicleParamsEx(vID, 1, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
    }

    for(new i=0; i<sizeof(ahCars); i++)
    {
    if(ahCars[i][id_x]!=vID)continue;
    //Verkaufsprozess
    SetPVarInt(playerid,"buyCarID",i);
    new string[256];
    format(string,sizeof(string),"Möchten sie das Fahrzeug für %i$ kaufen?",ahCars[i][c_preis]);
    ShowPlayerDialog(playerid,DIALOG_AUTOHAUS,DIALOG_STYLE_MSGBOX,"Autoverkauf",string,"Ja","Nein");
    break;
    }
    }

    Spoiler anzeigen
    new w = GetPlayerWeapon(playerid);
    if((newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER) && w != 25 && w != 29 && w != 30 && w != 31)
    {
    SetPlayerArmedWeapon(playerid, 0);
    }
    return 1;
    }