"Complicated" Server: Unknown command error.
#1

So, i've got a /myvehicles command which works properly:

pawn Code:
CMD:myvehicles(playerid, params[])
{
    new
        p_Name[MAX_PLAYER_NAME],
        vehStr[128],
        vcount = 0
    ;
   
    GetPlayerName(playerid, p_Name, 24);
   
    SendClientMessage(playerid, -1, ""#CYAN"[Your Owned Vehicles]");
   
    LoadVehicles();
   
    for( new v = 1; v < MAXIMUM_VEHICLES; v++ ) //Loop through all the vehicles
    {
   
        if(vehInfo[v][Owner] == p_Name[playerid])
        {
            format(vehStr, sizeof(vehStr), ""#LIME"» "#WHITE"%s (ID: %d)", VehiclesName[GetVehicleModel(v)-400], v);
            SendClientMessage(playerid, -1, vehStr);
            vcount++;
        }

    }
    format(vehStr, sizeof(vehStr), "* Total owned vehicles: "#LIME"%d", vcount);
    SendClientMessage(playerid, -1, vehStr);
    return true;
}
To go along with it, I've got a function that loads all of my vehicles (also works properly)
pawn Code:
stock LoadVehicles()
{
    new
        vehStr[32];
       
    for( new v = 1; v < MAXIMUM_VEHICLES; v++ ) //Reload vehicles!
    {
        format(vehStr, sizeof(vehStr), "RPMod/Vehicles/%d.ini", v);
           
        if(fexist(vehStr))
        {
            INI_ParseFile(vehStr, "LoadVehicle_%s", .bExtra = true, .extra = v);
        }
    }
    return true;
}
The problem arrises when I deleted a vehicle using this command:
pawn Code:
CMD:deletevehicle(playerid, params[])
{
    new
        vID,
        vehStr[128]
    ;
       
    if(accInfo[playerid][Authorization] < 3)
        return NOAUTH;
       
    if(sscanf(params, "i", vID))
        return SendClientMessage(playerid, -1, ""#LIME"<CMD USAGE> "#WHITE"/deletevehicle <vehicle id>");
       
    format(vehStr, sizeof(vehStr), "RPMod/Vehicles/%d.ini", vID);
   
    if(fexist(vehStr))
    {
        fremove(vehStr);
       
        format(vehStr, sizeof(vehStr), ""#CYAN"» "#WHITE"Vehicle ID "#LIME"%d "#WHITE"removed.", vID);
        SendClientMessage(playerid, -1, vehStr);
       
        DestroyVehicle(VehiclePID[vID]);
       
        LoadVehicles();
    }
    else return SendClientMessage(playerid, c_RED, "« "#WHITE"That vehicle does not exist!");
    return true;
}
It causes a Server:Unknown command to print at the end of /myvehicles. How do I fix this?
Reply
#2

At the end of your commands, use return 1 and not return true.
Reply
#3

Quote:
Originally Posted by RealCop228
View Post
At the end of your commands, use return 1 and not return true.
What's the difference?

EDIT: Problem still persists.
Reply
#4

Quote:
Originally Posted by 2KY
View Post
What's the difference?

EDIT: Problem still persists.
Well "true" and "false" are what a bool can return. I wasn't sure if it mattered, but I figured we could try. I'm not really sure what it could be really. Perhaps something in the stock function, but nothing is standing out to me.
Reply
#5

pawn Code:
if(accInfo[playerid][Authorization] < 3) return NOAUTH;
       
    if(sscanf(params, "i", vID))  return SendClientMessage(playerid, -1, ""#LIME"<CMD USAGE> "#WHITE"/deletevehicle <vehicle id>");
Wild guess.
Reply
#6

Quote:
Originally Posted by RealCop228
View Post
Well "true" and "false" are what a bool can return. I wasn't sure if it mattered, but I figured we could try. I'm not really sure what it could be really. Perhaps something in the stock function, but nothing is standing out to me.
Me neither, and that's a big problem considering everything APPEARS to be fine to me.

Quote:
Originally Posted by JhnzRep
View Post
pawn Code:
if(accInfo[playerid][Authorization] < 3) return NOAUTH;
       
    if(sscanf(params, "i", vID))  return SendClientMessage(playerid, -1, ""#LIME"<CMD USAGE> "#WHITE"/deletevehicle <vehicle id>");
Wild guess.
That would do the same thing, the only difference is a new line and a tab.
Reply
#7

pawn Code:
if(vehInfo[v][Owner] == p_Name[playerid])
WTF?!?!?!
Try this:
pawn Code:
if(!strcmp(vehInfo[v][Owner],p_Name[playerid]))
Reply
#8

Quote:
Originally Posted by FireCat
View Post
pawn Code:
if(vehInfo[v][Owner] == p_Name[playerid])
WTF?!?!?!
Try this:
pawn Code:
if(!strcmp(vehInfo[v][Owner],p_Name[playerid]))
That code automatically yields the "Server: Unknown command".

The bit of code you said "WTF?!?!?!" to, it works; Other than this problem, it works flawlessly.
Reply
#9

Bump. Really need this fixed.
Reply
#10

Hm, replace all the return true or whatever to return 0; .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)