Attempted to read/write array element at negative index -400
#1

Hi I still have this strange bug sometimes


Код:
[14/08/2018 14:50:53] [connection] incoming connection: 80.95.8.29:64355 id: 0
[14/08/2018 14:50:54] [join] SIRUSTHEVIRUS17 has joined the server (0:80.95.8.29)
[14/08/2018 14:50:54] [JOINED] SIRUSTHEVIRUS17 (ID: 0) [Country: South Africa] [City: Swartruggens]
[14/08/2018 14:51:11] [connection] incoming connection: 80.95.8.29:63143 id: 1
[14/08/2018 14:51:12] [join] $..BL4Z3R..$ has joined the server (1:80.95.8.29)
[14/08/2018 14:51:12] [JOINED] $..BL4Z3R..$ (ID: 1) [Country: South Africa] [City: Swartruggens]
[14/08/2018 14:51:12] [part] $..BL4Z3R..$ has left the server (1:2)
[14/08/2018 14:52:40] [connection] incoming connection: 80.95.8.29:58174 id: 1
[14/08/2018 14:52:41] [join] $..BL4Z3R..$ has joined the server (1:80.95.8.29)
[14/08/2018 14:52:42] [JOINED] $..BL4Z3R..$ (ID: 1) [Country: South Africa] [City: Swartruggens]
[14/08/2018 14:52:42] [part] $..BL4Z3R..$ has left the server (1:2)
[14/08/2018 14:52:54] [connection] incoming connection: 80.95.8.29:60648 id: 1
[14/08/2018 14:53:04] [part] SIRUSTHEVIRUS17 has left the server (0:0)
[14/08/2018 14:53:05] [connection] incoming connection: 80.95.8.29:64356 id: 0
[14/08/2018 14:53:06] [join] SIRUSTHEVIRUS17 has joined the server (0:80.95.8.29)
[14/08/2018 14:53:06] [JOINED] SIRUSTHEVIRUS17 (ID: 0) [Country: South Africa] [City: Swartruggens]
[14/08/2018 14:53:46] [connection] incoming connection: 80.95.8.29:49235 id: 1
[14/08/2018 14:53:47] [join] $..BL4Z3R..$ has joined the server (1:80.95.8.29)
[14/08/2018 14:53:48] [JOINED] $..BL4Z3R..$ (ID: 1) [Country: South Africa] [City: Swartruggens]
[14/08/2018 14:53:48] [part] $..BL4Z3R..$ has left the server (1:2)
[14/08/2018 14:54:48] [connection] incoming connection: 80.95.8.29:54851 id: 1
[14/08/2018 14:54:49] [join] $..BL4Z3R..$ has joined the server (1:80.95.8.29)
[14/08/2018 14:54:49] [JOINED] $..BL4Z3R..$ (ID: 1) [Country: South Africa] [City: Swartruggens]
[14/08/2018 14:54:49] [part] $..BL4Z3R..$ has left the server (1:2)
[14/08/2018 14:55:15] Number of vehicle models: 0
[14/08/2018 14:55:52] [connection] incoming connection: 80.95.8.29:62054 id: 1
[14/08/2018 14:55:56] [join] .BL4Z3R.. has joined the server (1:80.95.8.29)
[14/08/2018 14:55:56] [JOINED] .BL4Z3R.. (ID: 1) [Country: South Africa] [City: Swartruggens]
[14/08/2018 14:55:56] [part] .BL4Z3R.. has left the server (1:2)
[14/08/2018 14:56:17] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:17] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:17] [debug] AMX backtrace:
[14/08/2018 14:56:17] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:17] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:17] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:17] [debug] AMX backtrace:
[14/08/2018 14:56:17] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:17] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:17] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:17] [debug] AMX backtrace:
[14/08/2018 14:56:17] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:17] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:17] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:17] [debug] AMX backtrace:
[14/08/2018 14:56:17] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:17] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:17] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:17] [debug] AMX backtrace:
[14/08/2018 14:56:17] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:18] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:18] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:18] [debug] AMX backtrace:
[14/08/2018 14:56:18] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:19] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:19] [debug] AMX backtrace:
[14/08/2018 14:56:19] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:19] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:19] [debug] AMX backtrace:
[14/08/2018 14:56:19] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:19] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:19] [debug] AMX backtrace:
[14/08/2018 14:56:19] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:19] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:19] [debug] AMX backtrace:
[14/08/2018 14:56:19] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:19] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:19] [debug] AMX backtrace:
[14/08/2018 14:56:19] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:19] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:19] [debug] AMX backtrace:
[14/08/2018 14:56:19] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:19] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:19] [debug] AMX backtrace:
[14/08/2018 14:56:19] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:19] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:19] [debug] AMX backtrace:
[14/08/2018 14:56:19] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [debug] Run time error 4: "Array index out of bounds"
[14/08/2018 14:56:19] [debug]  Attempted to read/write array element at negative index -400
[14/08/2018 14:56:19] [debug] AMX backtrace:
[14/08/2018 14:56:19] [debug] #0 00030740 in public UpdateInfo () at C:\Games\SAMP GameModes\Sumo GameModes\gamemodes\sumo1.pwn:1882
[14/08/2018 14:56:19] [part] SIRUSTHEVIRUS17 has left the server (0:1)
Codes:

Код:
new Float:health;
GetVehicleHealth(GetPlayerVehicleID(i), health);
new Float:percentage = (health - 250) / 750 * 100;
/* Line 1882 */ format(msc,sizeof msc,"\n\n%s\nAlive: %d seconds | Speed: %d MPH\nHealth: %d%%\nPosition: %d%s",VehicleNames[GetVehicleModel(playerVehicle[i])-400],playerTime[i],final_speed,floatround(percentage, floatround_ceil),GetPlayerPlace(i), GetSuffix(GetPlayerPlace(i)));
UpdateDynamic3DTextLabelText(SumoCar[i], 0x00ff00bb,msc);
This is how I create playerVehicle[i]

Код:
playerVehicle[playerid] = CreateVehicle(car, pos4[0], pos4[1], pos4[2]+3, pos4[3], random(150), random(150),9999);
VehicleNames:

Код:
new VehicleNames[212][]={
"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster","Stretch","Manana","Infernus",
"Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto","Taxi","Washington","Bobcat","Mr Whoopee","BF Injection",
"Hunter","Premier","Enforcer","Securicar","Banshee","Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie",
"Stallion","Rumpo","RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer","Turismo","Speeder",
"Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer","PCJ-600","Faggio","Freeway","RC Baron","RC Raider",
"Glendale","Oceanic","Sanchez","Sparrow","Patriot","Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR 350","Walton","Regina",
"Comet","BMX","Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo","Greenwood",
"Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson","Mesa","RC Goblin","Hotring","Hotring",
"Bloodring Banger","Rancher","Super GT","Elegant","Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain",
"Nebula","Majestic","Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona","FBI Truck",
"Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight","Streak","Vortex","Vincent","Bullet","Clover",
"Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob","Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster",
"Monsterb","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer",
"Kart","Mower","Dune","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Trailer A","Emperor",
"Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","Andromada","Dodo","RC Cam","Launch","Police Car","Police Car",
"Police Car","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
"Stair Trailer","Boxville","Farm Plow","Utility Trailer"};
I will provide anything else if need

Is there another way to get the vehicle name from vehicleid besides VehicleNames[GetVehicleModel(playerVehicle[i])-400] ?
Reply
#2

GetVehicleModel returns 0 if the player doesn't have a car
Reply
#3

Quote:
Originally Posted by OneDay
Посмотреть сообщение
GetVehicleModel returns 0 if the player doesn't have a car
Quote:
Originally Posted by ******
Посмотреть сообщение
Use y_vehicledata, it has protection against oob.
What if I ignore this ? will it crash my server?
Reply
#4

You should not ignore any programming error
Reply
#5

Simply add a check before doing the 3dtext label update process.
PHP код:
if(GetVehicleModel(playerVehicle[i]) > 0)
{
    new 
Float:health;
    
GetVehicleHealth(GetPlayerVehicleID(i), health);
    new 
Float:percentage = (health 250) / 750 100;
    
/* Line 1882 */ format(msc,sizeof msc,"\n\n%s\nAlive: %d seconds | Speed: %d MPH\nHealth: %d%%\nPosition: %d%s",VehicleNames[GetVehicleModel(playerVehicle[i])-400],playerTime[i],final_speed,floatround(percentagefloatround_ceil),GetPlayerPlace(i), GetSuffix(GetPlayerPlace(i)));
    
UpdateDynamic3DTextLabelText(SumoCar[i], 0x00ff00bb,msc);

Reply
#6

Quote:
Originally Posted by jlalt
Посмотреть сообщение
Simply add a check before doing the 3dtext label update process.
PHP код:
if(GetVehicleModel(playerVehicle[i]) > 0)
{
    new 
Float:health;
    
GetVehicleHealth(GetPlayerVehicleID(i), health);
    new 
Float:percentage = (health 250) / 750 100;
    
/* Line 1882 */ format(msc,sizeof msc,"\n\n%s\nAlive: %d seconds | Speed: %d MPH\nHealth: %d%%\nPosition: %d%s",VehicleNames[GetVehicleModel(playerVehicle[i])-400],playerTime[i],final_speed,floatround(percentagefloatround_ceil),GetPlayerPlace(i), GetSuffix(GetPlayerPlace(i)));
    
UpdateDynamic3DTextLabelText(SumoCar[i], 0x00ff00bb,msc);

Thanks, I will update asap
Reply
#7

Quote:
Originally Posted by jlalt
Посмотреть сообщение
Simply add a check before doing the 3dtext label update process.
PHP код:
if(GetVehicleModel(playerVehicle[i]) > 0)
{
    new 
Float:health;
    
GetVehicleHealth(GetPlayerVehicleID(i), health);
    new 
Float:percentage = (health 250) / 750 100;
    
/* Line 1882 */ format(msc,sizeof msc,"\n\n%s\nAlive: %d seconds | Speed: %d MPH\nHealth: %d%%\nPosition: %d%s",VehicleNames[GetVehicleModel(playerVehicle[i])-400],playerTime[i],final_speed,floatround(percentagefloatround_ceil),GetPlayerPlace(i), GetSuffix(GetPlayerPlace(i)));
    
UpdateDynamic3DTextLabelText(SumoCar[i], 0x00ff00bb,msc);

It worked! +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)