Unknown Command
#1

Sscanf works probably and it sends the message with the correct usage but when I write the correct usage it gives me server unknown command?!
PHP код:
CMD:createcar(playeridparams[])
{
    new 
modelprice;
    if(
PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playeridCOLOR_RED"Command not found on the server! /help");
    if(
sscanf(params,"ii",modelprice)) return SendClientMessage(playeridCOLOR_RED"Create For-Sale Car: /createcar [Modelid] (Price)");
    if(
model 400 || model 611) return SendClientMessage(playeridCOLOR_RED"Car's modelid can't be less than 400 or more than 611!");
    
cAutoIncrease++;
    new 
check[128];
    
format(checksizeof(check), "SELECT * FROM cars WHERE id='%i'",cAutoIncrease);
    
mysql_query(1check);
    new 
TestID cache_get_row_count();
    if(
TestID 0) return SendClientMessage(playeridCOLOR_RED"ID is already exist!");
    new 
Float:xFloat:yFloat:zFloat:a;
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playerida);
    new 
vehicle CreateVehicle(modelidx+2yza, -1, -1, -10);
    
BSI[vehicle] = price;
    
PutPlayerInVehicle(playeridvehicle0);
    return 
1;

Reply
#2

Bump!
Reply
#3

Instead of using this in every command or function you write:
pawn Код:
return SendClientMessage(playerid, COLOR_RED, "Command not found on the server! /help");
Just simply use this:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
    {
        SendClientMessage(playerid, COLOR_RED, "Command not found on the server! /help");
    }
    return 1;
}
Then whenever a command returns 0, it will send that message.

So simply switch your createcar command around a bit so that you only return 1 when the command is successful.
Reply
#4

This message does when the player isn't an admin
Reply
#5

Listen i dont wanna check the code,but here is what to do, put this code in your script and type the command,and then show me the log.
pawn Код:
CMD:createcar(playerid, params[])
{
    new model, price;
    print("one");
    if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_RED, "Command not found on the server! /help");
    print("two");
    if(sscanf(params,"ii",model, price)) return SendClientMessage(playerid, COLOR_RED, "Create For-Sale Car: /createcar [Modelid] (Price)");
    print("three");
    if(model < 400 || model > 611) return SendClientMessage(playerid, COLOR_RED, "Car's modelid can't be less than 400 or more than 611!");
    print("four");
    cAutoIncrease++;
    new check[128];
    print("five");
    format(check, sizeof(check), "SELECT * FROM cars WHERE id='%i'",cAutoIncrease);
    mysql_query(1, check);
    new TestID = cache_get_row_count();
    print("six");
    if(TestID > 0) return SendClientMessage(playerid, COLOR_RED, "ID is already exist!");
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    print("seven");
    new vehicle = CreateVehicle(modelid, x+2, y, z, a, -1, -1, -1, 0);
    BSI[vehicle] = price;
    PutPlayerInVehicle(playerid, vehicle, 0);
    return 1;
}
Reply
#6

I found the error:
Код:
Array Index Out Of Bound
PHP код:
BSI[vehicle] = price
BSI defined as:
PHP код:
new BSI[MAX_VEHICLES]; 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)