Unknown Command -
nezo2001 - 28.08.2015
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(playerid, params[])
{
new model, price;
if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_RED, "Command not found on the server! /help");
if(sscanf(params,"ii",model, price)) return SendClientMessage(playerid, COLOR_RED, "Create For-Sale Car: /createcar [Modelid] (Price)");
if(model < 400 || model > 611) return SendClientMessage(playerid, COLOR_RED, "Car's modelid can't be less than 400 or more than 611!");
cAutoIncrease++;
new check[128];
format(check, sizeof(check), "SELECT * FROM cars WHERE id='%i'",cAutoIncrease);
mysql_query(1, check);
new TestID = cache_get_row_count();
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);
new vehicle = CreateVehicle(modelid, x+2, y, z, a, -1, -1, -1, 0);
BSI[vehicle] = price;
PutPlayerInVehicle(playerid, vehicle, 0);
return 1;
}
Re: Unknown Command -
nezo2001 - 29.08.2015
Bump!
Re: Unknown Command -
Finn707 - 29.08.2015
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.
Re: Unknown Command -
nezo2001 - 29.08.2015
This message does when the player isn't an admin
Re: Unknown Command -
R0 - 29.08.2015
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;
}
Re: Unknown Command -
nezo2001 - 29.08.2015
I found the error:
Код:
Array Index Out Of Bound
PHP код:
BSI[vehicle] = price;
BSI defined as:
PHP код:
new BSI[MAX_VEHICLES];