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;
}
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"
![]() |
[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
-r -O0 -d3
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 ![]() |
[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
pawn Код:
|