Jump to content

Problema debug in consola


Andronache

Recommended Posts

Salutare, am si eu un gamemode, l-am luat de pe net, el merge foarte bine si e foarte clean pentru edituri si toate cele, dar am facut factiunea taxi cu comanda /fare si gen dupa ce am facut-o am vazut ca apare asta in consola:
 

 

 [debug]  Accessing element at negative index -1


[debug] AMX backtrace:
[debug] #0 000a5c78 in ?? (... ❤️ arguments>) at C:\Users\Andro\Desktop\scripting\Gamemode Playes RPG\gamemodes\rg3.pwn:7609
[debug] #1 00009a80 in public OnPlayerStateChange (playerid=0, newstate=1, oldstate=2) at C:\Users\Andro\Desktop\scripting\Gamemode Playes RPG\pawno\include\YSI\y_hooks/impl.inc:1101

 

 

Daca m-ati putea ajuta, va pot da codul de la fiecare linie.

Primul cod: 

 

     while(start++ != end)


    {
        #emit PUSH.S oldstate
        #emit PUSH.S newstate
        #emit PUSH.S playerid
        #emit PUSH.C     12
        #emit CONST.alt  YSI_g_sCallbackAddresses
        #emit LOAD.S.pri start
        //#emit INC.pri
        //#emit STOR.S.pri start
        #emit LIDX
        #emit MOVE.alt
        #emit LCTRL      6
        #emit ADD.C      24
        #emit PUSH.pri
        #emit MOVE.pri
        #emit SCTRL      6
        #emit MOVE.alt
        #emit CONST.pri  0xFFFFFFFE
        #emit AND
        #emit PUSH.pri
        #emit LOAD.S.pri ret
        #emit AND
        #emit POP.alt
        #emit OR
        #emit STOR.S.pri ret
        if (ret < 0) return ret + 1;
    }
    return ret;

Asta e a doua eroare, imi da eroare fix pe linia cu while. Nu stiu sa o rezolv

 

 

Edited by Andronache
Link to comment
Share on other sites

Asta este al doilea cod:

 

        if(PlayerData[playerid][OnDuty] != -1)
        {
            new money = floatround(TaxiDist[playerid])/100*FarePrice[TaxiDriver[playerid]];
            format(gString, sizeof(gString), "~w~The ride cost~n~~r~$%s",FormatNumber(money));
            GameTextForPlayer(playerid, gString, 5000, 1);
            format(gString, sizeof(gString), "~w~Passenger left the taxi~n~~g~Earned $%s",FormatNumber(money));
            GameTextForPlayer(TaxiDriver[playerid], gString, 5000, 1);
            GivePlayerCash(playerid, -money);
            DriverMoney[TaxiDriver[playerid]] += money;
            TaxiDriver[playerid] = -1;
            TaxiDist[playerid] = 0.0;
            for(new i = 0; i <= 3; i++) PlayerTextDrawHide(playerid, TaxiTD[playerid]);

            format(gString, sizeof(gString), "Jucatorul %s transportat la destinatie pentru %s$", GetName(playerid),FormatNumber(money));
        }
    }

Nu inteleg de la ce vin erorile astea.. :)) Putin ajutor m-ar ajuta enorm, multumesc <em>❤️</em> 

 
Imi da eroare la linia cu new money = ...
 

Link to comment
Share on other sites

In cazul acesta va trebui sa te gandesti la propriu algoritm si logica de cum poti plati taximetristu. Poti pastra distanta ca float si sa convertesti restu la float daca vrei sa calculezi cu intreaga suma doar ca tot va trebui sa faci suma totala int ca sa o poti da

Link to comment
Share on other sites

Daca ai zis ca vrei distanta ca float intreg si vrei totusi sa ramai cu ce ai copiat poti face asa

new money = floatround(TaxiDist[playerid]/100.0*float(FarePrice[TaxiDriver[playerid]]), floatround_round);

Asa pastrezi distanta cu virgula si toate numerele ei si calculezi folosind floaturi

Nu ma intreba de ce se imparte la 100 ca habar nu am, probabil cel care a facut-o probabil a avut un motiv desi ai uitat sa il mentioneze

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.