Stock fehler ?

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
  • Warum returnt der stock immer auf 0 ?


    stock GetNearestTanke(playerid)
    {
    new Float: xx,
    Float: xy,
    Float: xz,
    nearst,
    Float:bx,
    Float:by,
    Float:bz;
    GetPlayerPos(playerid,xx,xy,xz);
    new Float:distance = 9999999.999999999,
    Float:olddistance;
    for(new x = 0;x < sizeof(SBizzInfo);x++)
    {
    bx = SBizzInfo[x][sbEntranceX];
    by = SBizzInfo[x][sbEntranceY];
    bz = SBizzInfo[x][sbEntranceZ];
    floatsqroot(floatpower(floatabs(floatsub(xx,bx)),2)+floatpower(floatabs(floatsub(xy,by)),2)+floatpower(floatabs(floatsub(xz,bz)),2));
    if(distance < olddistance)
    {
    olddistance = distance;
    nearst = x;
    }
    }
    return nearst;
    }

    • du weist olddistance keinen wert zu, sprich er ist 0 -> die abfrage ist dann ist etwas kleiner 0 - macht keinen Sinn :D
    • Du hast olddistance und distance in der Abfrage vertauscht. deine Aktuelle Abfrage wäre - ist 999999.9999999 kleiner als 0

    "Bevor ich mir Informationen aus der "Bild" hole,
    werde ich anfangen, Wahlergebnisse danach vorauszusagen,
    neben welchen Busch unsere Katze gepinkelt hat."

    Margarete Stokowski

  • ich habs jetzt so probiert geht aber iwie immernoch nicht :/


    stock GetNearestTanke(playerid)
    {
    new Float: xx,
    Float: xy,
    Float: xz,
    nearst,
    Float:bx,
    Float:by,
    Float:bz;
    GetPlayerPos(playerid,xx,xy,xz);
    new Float:distance = 9999999.999999999,
    Float:olddistance;
    for(new x = 0;x < sizeof(SBizzInfo);x++)
    {
    bx = SBizzInfo[x][sbEntranceX];
    by = SBizzInfo[x][sbEntranceY];
    bz = SBizzInfo[x][sbEntranceZ];
    olddistance = floatsqroot(floatpower(floatabs(floatsub(xx,bx)),2)+floatpower(floatabs(floatsub(xy,by)),2)+floatpower(floatabs(floatsub(xz,bz)),2));
    if(distance > olddistance)
    {
    //olddistance = distance;
    nearst = x;
    }
    return nearst;
    }
    return 1;
    }

  • if(olddistance < distance)
    {
    olddistance = distance;
    nearst = x;
    }
    }
    return nearst;


    Das ist der letzte Absatz und zwar korrigiert

    "Bevor ich mir Informationen aus der "Bild" hole,
    werde ich anfangen, Wahlergebnisse danach vorauszusagen,
    neben welchen Busch unsere Katze gepinkelt hat."

    Margarete Stokowski

  • Danke das du probierst mir zu helfen :D und hier der scriptteil wo es benutzt wird


    stock GetNearestTanke(playerid)
    {
    new Float: xx,
    Float: xy,
    Float: xz,
    nearst,
    Float:bx,
    Float:by,
    Float:bz;
    GetPlayerPos(playerid,xx,xy,xz);
    new Float:distance = 9999999.999999999,
    Float:olddistance;
    for(new x = 0;x < sizeof(SBizzInfo);x++)
    {
    bx = SBizzInfo[x][sbEntranceX];
    by = SBizzInfo[x][sbEntranceY];
    bz = SBizzInfo[x][sbEntranceZ];
    olddistance = floatsqroot(floatpower(floatabs(floatsub(xx,bx)),2)+floatpower(floatabs(floatsub(xy,by)),2)+floatpower(floatabs(floatsub(xz,bz)),2));
    if(olddistance < distance)
    {
    olddistance = distance;
    nearst = x;
    }
    }
    return nearst;
    }
    Function Fillup()
    {
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
    {
    new VID;
    new FillUp;
    new string[256];
    VID = GetPlayerVehicleID(i);
    FillUp = GetGasMax(GetVehicleModel(VID)) - Gas[VID];
    if(Refueling[i] == 1)
    {
    if(GetPlayerMoney(i) >= SBizzInfo[GetNearestTanke(i)][sbEntranceCost])
    {
    Gas[VID] += FillUp;
    FillUp = SBizzInfo[GetNearestTanke(i)][sbEntranceCost] * FillUp;
    format(string,sizeof(string),"* Fahrzeug für $%d aufgetankt. (Preis pro Liter: $%d)",FillUp,SBizzInfo[GetNearestTanke(i)][sbEntranceCost]);
    SendClientMessage(i,COLOR_LIGHTBLUE,string);
    GivePlayerMoney(i, - SBizzInfo[GetNearestTanke(i)][sbEntranceCost]);
    SBizzInfo[GetNearestTanke(i)][sbTill] += SBizzInfo[GetNearestTanke(i)][sbEntranceCost]-SBizzInfo[GetNearestTanke(i)][sbEntranceCost]/100*20;
    FraktionsKasse[6] += SBizzInfo[GetNearestTanke(i)][sbEntranceCost]/100*20;
    ExtortionSBiz(GetNearestTanke(i), SBizzInfo[GetNearestTanke(i)][sbEntranceCost]/100*50);
    Refueling[i] = 0;
    UnFreezePlayer(i);
    printf("Stock returnt zu %d",GetNearestTanke(i));
    }
    else
    {
    format(string,sizeof(string),"* Du hast nicht genug Geld zum Tanken, Kosten: $%d / Liter.",SBizzInfo[GetNearestTanke(i)][sbEntranceCost]);
    SendClientMessage(i,COLOR_LIGHTBLUE,string);
    UnFreezePlayer(i);
    }
    }
    }
    }
    return 1;
    }