CMD:vstorage(playerid, params[])
{
if(Player[playerid][IsLoggedIn] == false)
{
SendClientMessage(playerid, COLOR_WHITE, "You are not logged in.");
return 0;
}
else if(Player[playerid][IsLoggedIn] == true)
{
vstorageShow(playerid);
return 1;
}
return 1;
}
[debug] Run time error 4: "Array index out of bounds" [debug] Attempted to read/write array element at negative index -400 [debug] AMX backtrace: [debug] #0 000071d4 in ?? (522) from SRP.amx [debug] #1 000243f0 in ?? (0) from SRP.amx [debug] #2 0002cc74 in public cmd_vstorage (0, 249928) from SRP.amx [debug] #3 native CallLocalFunction () from samp-server.exe [debug] #4 000064f4 in public OnPlayerCommandText (0, 249888) from SRP.amx
new VehicleFriendlyNames[212][] = {
{"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"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"},{"Article Trailer"},
{"Previon"},{"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
{"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Article Trailer 2"},{"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 Racer A"},{"Hotring Racer B"},{"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 LA"},{"Hustler"},{"Intruder"},
{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},{"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},
{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},{"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},
{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},{"Bandito"},{"Freight Flat"},{"Streak Carriage"},
{"Kart"},{"Mower"},{"Dunerider"},{"Sweeper"},{"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},
{"Stafford"},{"BF-400"},{"Newsvan"},{"Tug"},{"Article Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Mobile Hotdog"},
{"Club"},{"Freight Carriage"},{"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},
{"Police Car (SFPD)"},{"Police Car (LVPD)"},{"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"}
};
stock GetVehicleFriendlyName(vehicleid)
{
new GVFNstring[56];
format(GVFNstring, sizeof(GVFNstring), VehicleFriendlyNames[GetVehicleModel(vehicleid)-400]);
return GVFNstring;
}
GetVehicleFriendlyName(id, bool: modelid = false)
{
new GVFNstring[56];
if ((!modelid && (400 <= (id = GetVehicleModel(id)) <= 611)) || (modelid && (400 <= id <= 611))) strcat(GVFNstring, VehicleFriendlyNames[id - 400]);
return GVFNstring;
}
GetVehicleFriendlyName(vehicleid_here);
// or
GetVehicleFriendlyName(modelid_here, true); // it's important to set to "true"
|
The problem is that the function expects a vehicle ID so it can use GetVehicleModel function but you pass a vehicle model ID instead so it returns 0 as modelid. What I used to have in my old gamemode was similar to this:
pawn Код:
pawn Код:
By the way, you don't need to wrap the name of the vehicles in braces and it'd be advised to use arrays instead of Car1 to Car10. |

if(c1 == 0)
{
c1name = "Slot 1: Empty";
}
else if(c1 > 0)
{
c1name = "Slot 1: %s (Stored)", GetVehicleFriendlyName(c1, true);
}
c1name = "Slot 1: %s (Stored)", GetVehicleFriendlyName(c1);
if(Player[i][Car1SP] == 0)
{
if(c1 == 0)
{
format(c1name, sizeof(c1name),"Slot 1: Empty");
}
else if(c1 > 0)
{
format(c1name, sizeof(c1name),"Slot 1: %s (Stored)",GetVehicleFriendlyName(c1, true));
}
}