SA-MP Forums Archive
Returning unknown command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Returning unknown command (/showthread.php?tid=588232)



Returning unknown command - conor565 - 06.09.2015

Went over this a few times, need a second set of eyes. This keeps returning an unknown command when executed IG

pawn Код:
CMD:refuel(playerid, params[]) {
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
        new
            vehicleID = GetPlayerVehicleID(playerid);

        if(playerData[playerid][pRefill] != INVALID_VEHICLE_ID) {
            businessData[playerData[playerid][pGasStation]][businessMoney] += playerData[playerid][pRefillPrice];
            saveBusiness(playerData[playerid][pGasStation]);

            givePlayerCash(playerid, -playerData[playerid][pRefillPrice]);

            sendServerMessage(playerid, "You have refueled your vehicle for $%s.", number_format(playerData[playerid][pRefillPrice]));
            stopRefilling(playerid);

            return 1;
        }
       
        if(!vehicleID)
            return sendErrorMessage(playerid, "You are not inside any vehicle!");

        if(GetEngineStatus(vehicleID))
            return sendErrorMessage(playerid, "You must turn the engine off first.");

        new
            localpumpID = nearestPump(playerid);

        if(localpumpID != -1) {
            if(floatround(vehicleData[vehicleID][v_fFuel], floatround_round) > 95)
                return sendErrorMessage(playerid, "This vehicle doesn't need any fuel.");

            if(isPumpOccupied(localpumpID))
                return sendErrorMessage(playerid, "This fuel pump is already occupied.");

            if(pumpData[localpumpID][pumpFuel] < 1)
                return sendErrorMessage(playerid, "This pump doesn't have enough fuel.");

            playerData[playerid][pGasPump] = localpumpID;
            playerData[playerid][pGasStation] = pumpData[localpumpID][pumpBusinessID];

            playerData[playerid][pRefill] = vehicleID;
           
            SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s has started refilling their vehicle.", getPlayerName(playerid, 0));

            SetTimerEx("OtherTimerEx", 500, false, "ii", playerid, TYPE_REFUEL_VEHICLE);
        }
        else sendErrorMessage(playerid, "You are not in range of a unused gas pump.");
    }
    else sendErrorMessage(playerid, "You are not inside any vehicle.");
    return 1;
}



Re: Returning unknown command - Nixtren - 06.09.2015

Use the plugin CrashDetect to troubleshoot this problem. Get back to us once you have it running and issued the command that is giving "Unknown command"


Re: Returning unknown command - conor565 - 06.09.2015

Quote:
Originally Posted by Nixtren
Посмотреть сообщение
Use the plugin CrashDetect to troubleshoot this problem. Get back to us once you have it running and issued the command that is giving "Unknown command"
pawn Код:
[20:55:10] [debug] Run time error 4: "Array index out of bounds"
[20:55:10] [debug]  Accessing element at negative index -1
[20:55:10] [debug] AMX backtrace:
[20:55:10] [debug] #0 002d6adc in public cmd_refuel (0x00000000, 0x0a0f87a4) from LGRP.amx
[20:55:10] [debug] #1 native CallLocalFunction () [00474110] from samp-server.exe
[20:55:10] [debug] #2 0000c8b8 in ?? (0x00000000, 0x0a0f8784) from LGRP.amx
[20:55:10] [debug] #3 00007708 in public OnPlayerCommandText (0x00000000, 0x0a0f8784) from LGRP.amx



Re: Returning unknown command - Nixtren - 06.09.2015

Hi,

Great! Now you should compile your GameMode in debug mode so CrashDetect can output more useful information (like the exact line on which the error occurs). To do so you need to pass the flag "-d3" to the Pawn compiler, you can easily do this by creating a "pawn.cfg" file inside the Pawno folder with the following contents:
Код:
-r -O0 -d3
After doing that, compile the GameMode, run the server and post the server log here again


Re: Returning unknown command - conor565 - 06.09.2015

Quote:
Originally Posted by Nixtren
Посмотреть сообщение
Hi,

Great! Now you should compile your GameMode in debug mode so CrashDetect can output more useful information (like the exact line on which the error occurs). To do so you need to pass the flag "-d3" to the Pawn compiler, you can easily do this by creating a "pawn.cfg" file inside the Pawno folder with the following contents:
Код:
-r -O0 -d3
After doing that, compile the GameMode, run the server and post the server log here again
pawn Код:
[21:23:08] [debug] Run time error 4: "Array index out of bounds"
[21:23:08] [debug]  Accessing element at negative index -1
[21:23:08] [debug] AMX backtrace:
[21:23:08] [debug] #0 003a3bb8 in public cmd_refuel (playerid=0, params[]=@0x0a0f87a4 "") at C:\Users\Conor\Desktop\restore\LGRP\gamemodes\LGRP.pwn:59885
[21:23:08] [debug] #1 native CallLocalFunction () [00474110] from samp-server.exe
[21:23:08] [debug] #2 0000edc0 in ?? (... <2 arguments>) at C:\Users\Conor\Desktop\restore\LGRP\pawno\include\zcmd.inc:102
[21:23:08] [debug] #3 00008f88 in public OnPlayerCommandText (playerid=0, cmdtext[]=@0x0a0f8784 "/refuel") at C:\Users\Conor\Desktop\restore\LGRP\pawno\include\YSI\y_hooks/impl.inc:918
That what your looking for?


Re: Returning unknown command - Nixtren - 06.09.2015

Quote:
Originally Posted by conor565
Посмотреть сообщение
pawn Код:
[21:23:08] [debug] Run time error 4: "Array index out of bounds"
[21:23:08] [debug]  Accessing element at negative index -1
[21:23:08] [debug] AMX backtrace:
[21:23:08] [debug] #0 003a3bb8 in public cmd_refuel (playerid=0, params[]=@0x0a0f87a4 "") at C:\Users\Conor\Desktop\restore\LGRP\gamemodes\LGRP.pwn:59885
[21:23:08] [debug] #1 native CallLocalFunction () [00474110] from samp-server.exe
[21:23:08] [debug] #2 0000edc0 in ?? (... <2 arguments>) at C:\Users\Conor\Desktop\restore\LGRP\pawno\include\zcmd.inc:102
[21:23:08] [debug] #3 00008f88 in public OnPlayerCommandText (playerid=0, cmdtext[]=@0x0a0f8784 "/refuel") at C:\Users\Conor\Desktop\restore\LGRP\pawno\include\YSI\y_hooks/impl.inc:918
That what your looking for?
Yes, exactly! What's the line 59885? That's the line where the error occurs.


Re: Returning unknown command - Threshold - 07.09.2015

Basically, playerData[playerid][pGasStation] = -1

You need to either check to make sure playerData[playerid][pGasStation] is not below 0 or above the limit.