Car System bugt.

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
  • Folgendes:
    if(newstate == PLAYER_STATE_DRIVER){
    gLastCar[playerid] = GetPlayerVehicleID(playerid);
    new veh = GetPlayerVehicleID(playerid);
    new VID = GetPlayerVehicleID(playerid);
    new value,
    Float:xX,
    Float:yY,
    Float:zZ,
    Float:X,
    Float:Y,
    Float:Z;
    GetVehiclePos(VID, xX, yY, zZ);
    GetVehicleVelocity(VID, X, Y, Z);
    value = floatround(floatsqroot((X*X) + (Y*Y) + (Z*Z)) * 100 * 1.40);
    new Speed[20];
    new Float:leben;
    if(value >= 0 && value <= 75){Speed = "~g~";}
    if(value > 75){Speed = "~r~";}
    new Tank[20];
    if(Gas[VID] > 10 && Gas[VID] <= 20){Tank = "~y~";}
    if(Gas[VID] <= 10){Tank = "~r~";}
    if(Gas[VID] > 20){Tank = "~g~";}
    VehSpeed[VID] = value;
    GetVehicleHealth(VID,leben);
    format(string,sizeof(string),"~r~%s",VehNames[GetVehicleModel(VID)-400]);
    format(string1,sizeof(string1),"~r~KM/H:~g~ %d ",value);
    format(string2,sizeof(string2),"~r~Tank:~g~ %s.1f ", Tank, Gas[VID]);
    format(string4,sizeof(string4),"~r~Zustand:~g~ %",leben/10);
    format(string3,sizeof(string3),"~r~Kilometer:~g~ %d Km",floatround(Kilometer[veh]));
    TextDrawSetString(Tacho3[playerid], string);
    TextDrawSetString(Tacho4[playerid],string1);
    TextDrawSetString(Tacho6[playerid],string2);
    TextDrawSetString(Tacho5[playerid],string4);
    TextDrawSetString(Tacho7[playerid],string3);
    TextDrawShowForPlayer(playerid, Tacho[playerid]);
    TextDrawShowForPlayer(playerid, Tacho1[playerid]);
    TextDrawShowForPlayer(playerid, Tacho2[playerid]);
    TextDrawShowForPlayer(playerid, Tacho3[playerid]);
    TextDrawShowForPlayer(playerid, Tacho4[playerid]);
    TextDrawShowForPlayer(playerid, Tacho5[playerid]);
    TextDrawShowForPlayer(playerid,Tacho6[playerid]);
    TextDrawShowForPlayer(playerid, Tacho7[playerid]);
    TextDrawShowForPlayer(playerid, Tacho9[playerid]); //Hier
    new newcar = GetPlayerVehicleID(playerid);
    new typ = IsAutohausCar(newcar);
    new GATyp = IsGangAutohausCar(newcar);

  • Habe es mit TextDrawHideForPlayer(playerid,Tacho9[playerid]); gelöst habs ganz vergessen das einzufügen der /carsell befehl bugt kommt immer Server Unknown Command:
    if(strcmp("/carsell", cmd, true) == 0)
    {
    if(Carlist[playerid][CarKey[playerid]][Typ] != -1)
    {
    if(Carlist[playerid][CarKey[playerid]][Carid] != -1)
    {
    new preis = (Kaufliste[Carlist[playerid][CarKey[playerid]][Typ]][Preis]/5)*4;
    GivePlayerMoneys(playerid, preis);
    DestroyVehicleSelfmade(Carlist[playerid][CarKey[playerid]][Carid]);
    Carlist[playerid][CarKey[playerid]][Typ]=-1;
    Carlist[playerid][CarKey[playerid]][pos_x]=0.0;
    Carlist[playerid][CarKey[playerid]][pos_y]=0.0;
    Carlist[playerid][CarKey[playerid]][pos_z]=0.0;
    Carlist[playerid][CarKey[playerid]][z_angle]=0.0;
    Carlist[playerid][CarKey[playerid]][Status]=0;
    Carlist[playerid][CarKey[playerid]][Lock]=0;
    Carlist[playerid][CarKey[playerid]][Carid]=-1;
    Carlist[playerid][CarKey[playerid]][Farbe1]=-1;
    Carlist[playerid][CarKey[playerid]][Farbe2]=-1;
    Carlist[playerid][CarKey[playerid]][mod1]=-1;
    Carlist[playerid][CarKey[playerid]][mod2]=-1;
    Carlist[playerid][CarKey[playerid]][mod3]=-1;
    Carlist[playerid][CarKey[playerid]][mod4]=-1;
    Carlist[playerid][CarKey[playerid]][mod5]=-1;
    Carlist[playerid][CarKey[playerid]][mod6]=-1;
    Carlist[playerid][CarKey[playerid]][mod7]=-1;
    Carlist[playerid][CarKey[playerid]][mod8]=-1;
    Carlist[playerid][CarKey[playerid]][mod9]=-1;
    Carlist[playerid][CarKey[playerid]][mod10]=-1;
    Carlist[playerid][CarKey[playerid]][mod11]=-1;
    Carlist[playerid][CarKey[playerid]][mod12]=-1;
    Carlist[playerid][CarKey[playerid]][mod13]=-1;
    Carlist[playerid][CarKey[playerid]][mod14]=-1;
    Carlist[playerid][CarKey[playerid]][mod15]=-1;
    Carlist[playerid][CarKey[playerid]][mod16]=-1;
    Carlist[playerid][CarKey[playerid]][mod17]=-1;
    Carlist[playerid][CarKey[playerid]][Paintjob]=-1;
    Carlist[playerid][CarKey[playerid]][OwnerID] = playerid;
    Carlist[playerid][CarKey[playerid]][SpawnSaveX]=0.0;
    Carlist[playerid][CarKey[playerid]][SpawnSaveY]=0.0;
    Carlist[playerid][CarKey[playerid]][SpawnSaveZ]=0.0;
    Carlist[playerid][CarKey[playerid]][SpawnSaveRot]=0.0;
    Carlist[playerid][CarKey[playerid]][TankVolumen]=0;
    Carlist[playerid][CarKey[playerid]][StandTime] = 0;
    Carlist[playerid][CarKey[playerid]][Neon]=0;
    Carlist[playerid][CarKey[playerid]][NeonType]=1;
    format(string, sizeof(string), "Du hast erfolgreich dein Auto für %s$ verkauft!",GetPoint(preis));
    SendClientMessage(playerid, COLOR_RED, string);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "%s hat sein Auto verkauft!",sendername,preis);
    printf(string);
    }
    else
    {
    SendClientMessage(playerid, COLOR_ERRORTEXT, " Du besitzt zur Zeit kein Auto auf dem ausgewählten Schlüssel !");
    return 1;
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_ERRORTEXT, " Du besitzt kein Auto auf dem ausgewählten Schlüssel !");
    return 1;
    }
    return 1;
    }

    Einmal editiert, zuletzt von Corvus ()

  • Ja da soll das Auto verkauft werden.
    Beim Connecten wird der wert auf 0 gesetzt und mit /carkey hoch gesetzt.
    if(strcmp("/carkey", cmd, true) == 0)
    {
    if(MaxVeh[playerid] > 1)
    {
    CarKey[playerid] += 1;
    if(CarKey[playerid] == MaxVeh[playerid])
    {
    CarKey[playerid] = 0;
    }
    if(Carlist[playerid][CarKey[playerid]][Typ] != -1)
    {
    new index = -1;
    for(new i=0; i<sizeof(Kaufliste); i++)
    {
    if(Kaufliste[i][Modelid] == Carlist[playerid][CarKey[playerid]][Typ])
    {
    index = i;
    break;
    }
    }
    if(index == -1) format(string, sizeof(string), "Du nimmst deinen %dten Auto-Schlüssel, für deinen <unbekannt> !", CarKey[playerid]+1);
    else format(string, sizeof(string), "Du nimmst deinen %dten Auto-Schlüssel, für deinen %s !", CarKey[playerid]+1, Kaufliste[index][Name]);
    }
    else
    {
    format(string, sizeof(string), "Du nimmst deinen %dten Auto-Schlüssel !",CarKey[playerid]+1);
    }
    SendClientMessage(playerid,COLOR_YELLOW,string);
    }
    return 1;
    }

  • Schreibe es mal so, was steht im Log?

    Spoiler anzeigen
    if(strcmp("/carsell", cmd, true) == 0)
    {
    printf("carkey: %d", CarKey[playerid]);
    if(Carlist[playerid][CarKey[playerid]][Typ] != -1)
    {
    if(Carlist[playerid][CarKey[playerid]][Carid] != -1)
    {
    printf("typ: %d", Carlist[playerid][CarKey[playerid]][Typ]);
    new preis = (Kaufliste[Carlist[playerid][CarKey[playerid]][Typ]][Preis]/5)*4;
    GivePlayerMoneys(playerid, preis);
    printf("preis: %d", preis);
    DestroyVehicleSelfmade(Carlist[playerid][CarKey[playerid]][Carid]);
    Carlist[playerid][CarKey[playerid]][Typ]=-1;
    Carlist[playerid][CarKey[playerid]][pos_x]=0.0;
    Carlist[playerid][CarKey[playerid]][pos_y]=0.0;
    Carlist[playerid][CarKey[playerid]][pos_z]=0.0;
    Carlist[playerid][CarKey[playerid]][z_angle]=0.0;
    Carlist[playerid][CarKey[playerid]][Status]=0;
    Carlist[playerid][CarKey[playerid]][Lock]=0;
    Carlist[playerid][CarKey[playerid]][Carid]=-1;
    Carlist[playerid][CarKey[playerid]][Farbe1]=-1;
    Carlist[playerid][CarKey[playerid]][Farbe2]=-1;
    Carlist[playerid][CarKey[playerid]][mod1]=-1;
    Carlist[playerid][CarKey[playerid]][mod2]=-1;
    Carlist[playerid][CarKey[playerid]][mod3]=-1;
    Carlist[playerid][CarKey[playerid]][mod4]=-1;
    Carlist[playerid][CarKey[playerid]][mod5]=-1;
    Carlist[playerid][CarKey[playerid]][mod6]=-1;
    Carlist[playerid][CarKey[playerid]][mod7]=-1;
    Carlist[playerid][CarKey[playerid]][mod8]=-1;
    Carlist[playerid][CarKey[playerid]][mod9]=-1;
    Carlist[playerid][CarKey[playerid]][mod10]=-1;
    Carlist[playerid][CarKey[playerid]][mod11]=-1;
    Carlist[playerid][CarKey[playerid]][mod12]=-1;
    Carlist[playerid][CarKey[playerid]][mod13]=-1;
    Carlist[playerid][CarKey[playerid]][mod14]=-1;
    Carlist[playerid][CarKey[playerid]][mod15]=-1;
    Carlist[playerid][CarKey[playerid]][mod16]=-1;
    Carlist[playerid][CarKey[playerid]][mod17]=-1;
    Carlist[playerid][CarKey[playerid]][Paintjob]=-1;
    Carlist[playerid][CarKey[playerid]][OwnerID] = playerid;
    Carlist[playerid][CarKey[playerid]][SpawnSaveX]=0.0;
    Carlist[playerid][CarKey[playerid]][SpawnSaveY]=0.0;
    Carlist[playerid][CarKey[playerid]][SpawnSaveZ]=0.0;
    Carlist[playerid][CarKey[playerid]][SpawnSaveRot]=0.0;
    Carlist[playerid][CarKey[playerid]][TankVolumen]=0;
    Carlist[playerid][CarKey[playerid]][StandTime] = 0;
    Carlist[playerid][CarKey[playerid]][Neon]=0;
    Carlist[playerid][CarKey[playerid]][NeonType]=1;
    format(string, sizeof(string), "Du hast erfolgreich dein Auto für %s$ verkauft!",GetPoint(preis));
    SendClientMessage(playerid, COLOR_RED, string);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "%s hat sein Auto verkauft!",sendername,preis);
    printf(string);
    }
    else
    {
    SendClientMessage(playerid, COLOR_ERRORTEXT, " Du besitzt zur Zeit kein Auto auf dem ausgewählten Schlüssel !");
    return 1;
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_ERRORTEXT, " Du besitzt kein Auto auf dem ausgewählten Schlüssel !");
    return 1;
    }
    return 1;
    }

  • Jetzt folgendes:
    [18:54:56] [debug] Run time error 4: "Array index out of bounds"
    [18:54:56] [debug] Accessing element at index 482 past array upper bound 44
    [18:54:56] [debug] AMX backtrace:
    [18:54:56] [debug] #0 000a9728 in public ocmdOnPlayerCommandText (0, 4233448) from irp(3).amx
    [18:54:56] [debug] #1 native CallLocalFunction () from samp03svr
    [18:54:56] [debug] #2 00002164 in public OnPlayerCommandText (0, 4233412) from irp(3).amx
    [18:54:59] [debug] Run time error 19: "File or function is not found"

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen
  • Nächstes mal bitte auch die prints von mir dazu posten, dann erspare ich mir die Sucherei.
    new preis = (Kaufliste[Carlist[playerid][CarKey[playerid]][Typ]][Preis]/5)*4;
    zu:
    new preis = (Kaufliste[Carlist[playerid][CarKey[playerid]][Typ]-400][Preis]/5)*4;

  • Folgendes:
    new Kaufliste[45][ahModell] =
    Er sendet mir das:


    [19:38:21] carkey: 0
    [19:38:21] typ: 545
    [19:38:21] [debug] Run time error 4: "Array index out of bounds"
    [19:38:21] [debug] Accessing element at index 145 past array upper bound 44
    [19:38:21] [debug] AMX backtrace:
    [19:38:21] [debug] #0 000a97dc in public ocmdOnPlayerCommandText (0, 4233448) from irp(3).amx
    [19:38:21] [debug] #1 native CallLocalFunction () from samp03svr
    [19:38:21] [debug] #2 00002164 in public OnPlayerCommandText (0, 4233412) from irp(3).amx
    [19:38:31] Gas: 97.5 | playerid: 8 | veh: 221 Mehr aber auch nicht.

  • Schreibe es so:

    Spoiler anzeigen
    if(strcmp("/carsell", cmd, true) == 0)
    {
    printf("carkey: %d", CarKey[playerid]);
    if(Carlist[playerid][CarKey[playerid]][Typ] != -1)
    {
    if(Carlist[playerid][CarKey[playerid]][Carid] != -1)
    {
    printf("typ: %d", Carlist[playerid][CarKey[playerid]][Typ]);
    new id = -1;
    for(new i=0; i<sizeof(Kaufliste); i++)
    {
    if(Carlist[playerid][CarKey[playerid]][Typ] == Kaufliste[i][Modelid])
    {
    id = i;
    break;
    }
    }
    if(id == -1) return SendClientMessage(playerid, 0xFF0000FF, "Fahrzeug existiert nicht.");
    new preis = (Kaufliste[id][Preis]/5)*4;
    GivePlayerMoneys(playerid, preis);
    printf("preis: %d", preis);
    DestroyVehicleSelfmade(Carlist[playerid][CarKey[playerid]][Carid]);
    Carlist[playerid][CarKey[playerid]][Typ]=-1;
    Carlist[playerid][CarKey[playerid]][pos_x]=0.0;
    Carlist[playerid][CarKey[playerid]][pos_y]=0.0;
    Carlist[playerid][CarKey[playerid]][pos_z]=0.0;
    Carlist[playerid][CarKey[playerid]][z_angle]=0.0;
    Carlist[playerid][CarKey[playerid]][Status]=0;
    Carlist[playerid][CarKey[playerid]][Lock]=0;
    Carlist[playerid][CarKey[playerid]][Carid]=-1;
    Carlist[playerid][CarKey[playerid]][Farbe1]=-1;
    Carlist[playerid][CarKey[playerid]][Farbe2]=-1;
    Carlist[playerid][CarKey[playerid]][mod1]=-1;
    Carlist[playerid][CarKey[playerid]][mod2]=-1;
    Carlist[playerid][CarKey[playerid]][mod3]=-1;
    Carlist[playerid][CarKey[playerid]][mod4]=-1;
    Carlist[playerid][CarKey[playerid]][mod5]=-1;
    Carlist[playerid][CarKey[playerid]][mod6]=-1;
    Carlist[playerid][CarKey[playerid]][mod7]=-1;
    Carlist[playerid][CarKey[playerid]][mod8]=-1;
    Carlist[playerid][CarKey[playerid]][mod9]=-1;
    Carlist[playerid][CarKey[playerid]][mod10]=-1;
    Carlist[playerid][CarKey[playerid]][mod11]=-1;
    Carlist[playerid][CarKey[playerid]][mod12]=-1;
    Carlist[playerid][CarKey[playerid]][mod13]=-1;
    Carlist[playerid][CarKey[playerid]][mod14]=-1;
    Carlist[playerid][CarKey[playerid]][mod15]=-1;
    Carlist[playerid][CarKey[playerid]][mod16]=-1;
    Carlist[playerid][CarKey[playerid]][mod17]=-1;
    Carlist[playerid][CarKey[playerid]][Paintjob]=-1;
    Carlist[playerid][CarKey[playerid]][OwnerID] = playerid;
    Carlist[playerid][CarKey[playerid]][SpawnSaveX]=0.0;
    Carlist[playerid][CarKey[playerid]][SpawnSaveY]=0.0;
    Carlist[playerid][CarKey[playerid]][SpawnSaveZ]=0.0;
    Carlist[playerid][CarKey[playerid]][SpawnSaveRot]=0.0;
    Carlist[playerid][CarKey[playerid]][TankVolumen]=0;
    Carlist[playerid][CarKey[playerid]][StandTime] = 0;
    Carlist[playerid][CarKey[playerid]][Neon]=0;
    Carlist[playerid][CarKey[playerid]][NeonType]=1;
    format(string, sizeof(string), "Du hast erfolgreich dein Auto für %s$ verkauft!",GetPoint(preis));
    SendClientMessage(playerid, COLOR_RED, string);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "%s hat sein Auto verkauft!",sendername,preis);
    printf(string);
    }
    else
    {
    SendClientMessage(playerid, COLOR_ERRORTEXT, " Du besitzt zur Zeit kein Auto auf dem ausgewählten Schlüssel !");
    return 1;
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_ERRORTEXT, " Du besitzt kein Auto auf dem ausgewählten Schlüssel !");
    return 1;
    }
    return 1;
    }