PDA

Просмотр полной версии : [Вопрос] Attempted to read/write array element at negative index -400



ALIT13
09.09.2018, 15:30
[18:21:55] [debug] Run time error 4: "Array index out of bounds"
[18:21:55] [debug] Attempted to read/write array element at negative index -400
[18:21:55] [debug] AMX backtrace:


format(string,sizeof(string),"%s",VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid)-400)]);
PlayerTextDrawSetString(playerid,vehicle_speed[playerid][2],string);

В чем проблема ?

Sp1ke
09.09.2018, 16:10
[18:21:55] [debug] Run time error 4: "Array index out of bounds"
[18:21:55] [debug] Attempted to read/write array element at negative index -400
[18:21:55] [debug] AMX backtrace:


format(string,sizeof(string),"%s",VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid)-400)]);
PlayerTextDrawSetString(playerid,vehicle_speed[playerid][2],string);

В чем проблема ?


format(string,sizeof(string),"%s",VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
PlayerTextDrawSetString(playerid,vehicle_speed[playerid][2],string);

ALIT13
09.09.2018, 18:57
Не помогает всё так же в логах пишет

[21:54:06] [debug] Run time error 4: "Array index out of bounds"
[21:54:06] [debug] Attempted to read/write array element at negative index -400
[21:54:06] [debug] AMX backtrace:
[21:54:06] [debug] #0 000625bc in public @__updeit_speed (playerid=0) at C:\Users\User\Desktop\gta\gamemodes\samp.pwn:4963

DeimoS
09.09.2018, 19:03
Ну так проверяй, сидит ли игрок в каком-либо авто, прежде чем выполнять этот код =\ Раз ругается на отрицательный индекс "-400", значит GetVehicleModel и GetPlayerVehicleID вернули 0, что случается только когда игрок не сидит в авто.