"SERVER: Unknown command." Problem
#1

Hey guys, I have a problem with my Vstorage command that I have been scripting today.
it returns "SERVER: Unknown command." with usage ingame.

I have the latest of all plugins / includes, I am doing something wrong here somehow.

here is my code http://pastebin.com/NeWUnKzG


also the CMD:
Код:
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;
}
Reply
#2

It's normal when you return 0 in a command (if you are not logged in). If that's not the case, load crashdetect plugin (run time errors also display the message).
Reply
#3

Код:
[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
?? I am clueless lol
Reply
#4

Can you post GetVehicleFriendlyName function? It is passed a valid model ID (522) but it takes 0 as model ID which subtracting from the array to retrieve the name results in index -400.
Reply
#5

Код:
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;
}
Reply
#6

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 Код:
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;
}
You can now simply use:
pawn Код:
GetVehicleFriendlyName(vehicleid_here);
// or
GetVehicleFriendlyName(modelid_here, true); // it's important to set to "true"
which in your case is the second.

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.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
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 Код:
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;
}
You can now simply use:
pawn Код:
GetVehicleFriendlyName(vehicleid_here);
// or
GetVehicleFriendlyName(modelid_here, true); // it's important to set to "true"
which in your case is the second.

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.
Tested, atleast the dialog shows now... its showing that its stored, but the vehicle model still isnt showing hmm


Код:
if(c1 == 0)
		{
		    c1name = "Slot 1: Empty";
		}
		else if(c1 > 0)
		{
		    c1name = "Slot 1: %s (Stored)", GetVehicleFriendlyName(c1, true);
		}
I guess this is wrong
Reply
#8

I didn't notice it before:
pawn Код:
c1name = "Slot 1: %s (Stored)", GetVehicleFriendlyName(c1);
What your code does is set c1name to "Slot 1: %s (Stored)" and then call GetVehicleFriendlyName without storing the output returned anywhere. You need to format the text for it to work.
Reply
#9

pawn Код:
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));
        }
    }
Like so?
Update: +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)