cmd sscanf problem -
Jack_Leslie - 13.03.2014
Hi guys, I'm not sure what's wrong with this command..
pawn Код:
CMD:ahouse(playerid, params[])
{
if(PlayerData[playerid][AdminLevel] < 6) return SendUnathorizedMessage(playerid);
if(strcmp(params, "create", true) == 0)
{
new level, price, id = 0, Float:X, Float:Y, Float:Z, Float:A, string[126],zone[MAX_ZONE_NAME];
if(sscanf(params, "ii", level, price)) return SendClientMessage(playerid, C_SYNTAX, "Syntax:{FFFFFF} /ahouse create [level] [price]");
if(level < 1) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} House levels must not go below 1.");
if(price < 50000) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} The minimum value of a house is $50,000.");
for(new i = 0; i < sizeof(HouseData); i ++)
{
if(HouseData[i][Created] == 0) id = i;
}
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
HouseData[id][Entrance][0] = A;
HouseData[id][Entrance][1] = X;
HouseData[id][Entrance][2] = Y;
HouseData[id][Entrance][3] = Z;
HouseData[id][Created] = 1;
HouseData[id][SalePrice] = price;
HouseData[id][ForSale] = true;
HouseData[id][Owned] = false;
SetHouseInterior(id, level);
format(string, sizeof(string), "* You just created house %d in %s for %s, don't forget to /house sign.", id, zone, ConvertPrice(price));
SendClientMessage(playerid, C_CYAN, string);
return 1;
}
else {
SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} Invalid action.");
}
return 1;
}
Problem is, after I type /ahouse create, it keeps saying Invalid action, even if I put a level and price.
Re: cmd sscanf problem -
iThePunisher - 13.03.2014
all your problem is here, you have blocked the command in this line
pawn Код:
else {
SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} Invalid action.");
}
try this
pawn Код:
CMD:ahouse(playerid, params[])
{
if(PlayerData[playerid][AdminLevel] < 6) return SendUnathorizedMessage(playerid);
if(strcmp(params, "create", true) == 0)
{
new level, price, id = 0, Float:X, Float:Y, Float:Z, Float:A, string[126],zone[MAX_ZONE_NAME];
if(sscanf(params, "ii", level, price)) return SendClientMessage(playerid, C_SYNTAX, "Syntax:{FFFFFF} /ahouse create [level] [price]");
if(level < 1) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} House levels must not go below 1.");
if(price < 50000) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} The minimum value of a house is $50,000.");
for(new i = 0; i < sizeof(HouseData); i ++)
{
if(HouseData[i][Created] == 0) id = i;
}
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
HouseData[id][Entrance][0] = A;
HouseData[id][Entrance][1] = X;
HouseData[id][Entrance][2] = Y;
HouseData[id][Entrance][3] = Z;
HouseData[id][Created] = 1;
HouseData[id][SalePrice] = price;
HouseData[id][ForSale] = true;
HouseData[id][Owned] = false;
SetHouseInterior(id, level);
format(string, sizeof(string), "* You just created house %d in %s for %s, don't forget to /house sign.", id, zone, ConvertPrice(price));
SendClientMessage(playerid, C_CYAN, string);
return 1;
}
return 1;
}
Re: cmd sscanf problem -
Jack_Leslie - 13.03.2014
Quote:
Originally Posted by iThePunisher
all your problem is here, you have blocked the command in this line
pawn Код:
else { SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} Invalid action."); }
try this
pawn Код:
CMD:ahouse(playerid, params[]) { if(PlayerData[playerid][AdminLevel] < 6) return SendUnathorizedMessage(playerid); if(strcmp(params, "create", true) == 0) { new level, price, id = 0, Float:X, Float:Y, Float:Z, Float:A, string[126],zone[MAX_ZONE_NAME]; if(sscanf(params, "ii", level, price)) return SendClientMessage(playerid, C_SYNTAX, "Syntax:{FFFFFF} /ahouse create [level] [price]"); if(level < 1) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} House levels must not go below 1."); if(price < 50000) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} The minimum value of a house is $50,000."); for(new i = 0; i < sizeof(HouseData); i ++) { if(HouseData[i][Created] == 0) id = i; } GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid,A); GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME); HouseData[id][Entrance][0] = A; HouseData[id][Entrance][1] = X; HouseData[id][Entrance][2] = Y; HouseData[id][Entrance][3] = Z; HouseData[id][Created] = 1; HouseData[id][SalePrice] = price; HouseData[id][ForSale] = true; HouseData[id][Owned] = false; SetHouseInterior(id, level); format(string, sizeof(string), "* You just created house %d in %s for %s, don't forget to /house sign.", id, zone, ConvertPrice(price)); SendClientMessage(playerid, C_CYAN, string); return 1; } return 1; }
|
That's not it mate, the reason I have the else at the end, is so if the person doesn't enter "create" after "ahouse" then it says invalid action. (btw I did try it just to double check)
Re: cmd sscanf problem -
Jack_Leslie - 15.03.2014
Bump
Re: cmd sscanf problem -
DarkLored - 15.03.2014
Quote:
Originally Posted by iThePunisher
all your problem is here, you have blocked the command in this line
pawn Код:
else { SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} Invalid action."); }
try this
pawn Код:
CMD:ahouse(playerid, params[]) { if(PlayerData[playerid][AdminLevel] < 6) return SendUnathorizedMessage(playerid); if(strcmp(params, "create", true) == 0) { new level, price, id = 0, Float:X, Float:Y, Float:Z, Float:A, string[126],zone[MAX_ZONE_NAME]; if(sscanf(params, "ii", level, price)) return SendClientMessage(playerid, C_SYNTAX, "Syntax:{FFFFFF} /ahouse create [level] [price]"); if(level < 1) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} House levels must not go below 1."); if(price < 50000) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} The minimum value of a house is $50,000."); for(new i = 0; i < sizeof(HouseData); i ++) { if(HouseData[i][Created] == 0) id = i; } GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid,A); GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME); HouseData[id][Entrance][0] = A; HouseData[id][Entrance][1] = X; HouseData[id][Entrance][2] = Y; HouseData[id][Entrance][3] = Z; HouseData[id][Created] = 1; HouseData[id][SalePrice] = price; HouseData[id][ForSale] = true; HouseData[id][Owned] = false; SetHouseInterior(id, level); format(string, sizeof(string), "* You just created house %d in %s for %s, don't forget to /house sign.", id, zone, ConvertPrice(price)); SendClientMessage(playerid, C_CYAN, string); return 1; } return 1; }
|
He is correct my do you need to make a else message if all of the messages are in the top of the command?
try to do what he said and check if it works
Re: cmd sscanf problem -
Jack_Leslie - 15.03.2014
Quote:
Originally Posted by DarkLored
He is correct my do you need to make a else message if all of the messages are in the top of the command?
try to do what he said and check if it works
|
As I said in my response, I did try it any way, and it didn't work.
Re: cmd sscanf problem -
Matess - 15.03.2014
Try this:
pawn Код:
CMD:ahouse(playerid, params[])
{
if(PlayerData[playerid][AdminLevel] < 6) return SendUnathorizedMessage(playerid);
if(strcmp(params[0], "create", true) == 0)
{
new level, price, id = 0, Float:X, Float:Y, Float:Z, Float:A, string[126],zone[MAX_ZONE_NAME];
if(sscanf(params, "ii", level, price)) return SendClientMessage(playerid, C_SYNTAX, "Syntax:{FFFFFF} /ahouse create [level] [price]");
if(level < 1) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} House levels must not go below 1.");
if(price < 50000) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} The minimum value of a house is $50,000.");
for(new i = 0; i < sizeof(HouseData); i ++)
{
if(HouseData[i][Created] == 0) id = i;
}
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
HouseData[id][Entrance][0] = A;
HouseData[id][Entrance][1] = X;
HouseData[id][Entrance][2] = Y;
HouseData[id][Entrance][3] = Z;
HouseData[id][Created] = 1;
HouseData[id][SalePrice] = price;
HouseData[id][ForSale] = true;
HouseData[id][Owned] = false;
SetHouseInterior(id, level);
format(string, sizeof(string), "* You just created house %d in %s for %s, don't forget to /house sign.", id, zone, ConvertPrice(price));
SendClientMessage(playerid, C_CYAN, string);
return 1;
}
else {
SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} Invalid action.");
}
return 1;
}
Re: cmd sscanf problem -
Jack_Leslie - 16.03.2014
Quote:
Originally Posted by Matess
Try this:
pawn Код:
CMD:ahouse(playerid, params[]) { if(PlayerData[playerid][AdminLevel] < 6) return SendUnathorizedMessage(playerid); if(strcmp(params[0], "create", true) == 0) { new level, price, id = 0, Float:X, Float:Y, Float:Z, Float:A, string[126],zone[MAX_ZONE_NAME]; if(sscanf(params, "ii", level, price)) return SendClientMessage(playerid, C_SYNTAX, "Syntax:{FFFFFF} /ahouse create [level] [price]"); if(level < 1) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} House levels must not go below 1."); if(price < 50000) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} The minimum value of a house is $50,000."); for(new i = 0; i < sizeof(HouseData); i ++) { if(HouseData[i][Created] == 0) id = i; } GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid,A); GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME); HouseData[id][Entrance][0] = A; HouseData[id][Entrance][1] = X; HouseData[id][Entrance][2] = Y; HouseData[id][Entrance][3] = Z; HouseData[id][Created] = 1; HouseData[id][SalePrice] = price; HouseData[id][ForSale] = true; HouseData[id][Owned] = false; SetHouseInterior(id, level); format(string, sizeof(string), "* You just created house %d in %s for %s, don't forget to /house sign.", id, zone, ConvertPrice(price)); SendClientMessage(playerid, C_CYAN, string); return 1; }
else { SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} Invalid action."); } return 1; }
|
Nope, still says invalid action once I get to '/ahouse create'. So to clarify it, if I try to type '/ahouse create 1 50000' it will say invalid action. Or if I type '/ahouse create 1' it will say invalid action instead of 'Syntax:{FFFFFF} /ahouse create [level] [price]'
Re: cmd sscanf problem -
Zeppo - 16.03.2014
Here, try this:
pawn Код:
CMD:ahouse(playerid, params[])
{
if(PlayerData[playerid][AdminLevel] < 6) return SendUnathorizedMessage(playerid);
if(!strcmp("create", cmdtext))
{
new level, price, id = 0, Float:X, Float:Y, Float:Z, Float:A, string[126],zone[MAX_ZONE_NAME];
if(sscanf(params, "ii", level, price)) return SendClientMessage(playerid, C_SYNTAX, "Syntax:{FFFFFF} /ahouse create [level] [price]");
if(level < 1) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} House levels must not go below 1.");
if(price < 50000) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} The minimum value of a house is $50,000.");
for(new i = 0; i < sizeof(HouseData); i ++)
{
if(HouseData[i][Created] == 0) id = i;
}
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
HouseData[id][Entrance][0] = A;
HouseData[id][Entrance][1] = X;
HouseData[id][Entrance][2] = Y;
HouseData[id][Entrance][3] = Z;
HouseData[id][Created] = 1;
HouseData[id][SalePrice] = price;
HouseData[id][ForSale] = true;
HouseData[id][Owned] = false;
SetHouseInterior(id, level);
format(string, sizeof(string), "* You just created house %d in %s for %s, don't forget to /house sign.", id, zone, ConvertPrice(price));
SendClientMessage(playerid, C_CYAN, string);
return 1;
}
else {
SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} Invalid action.");
}
return 1;
}
Re: cmd sscanf problem -
Jack_Leslie - 16.03.2014
Quote:
Originally Posted by Zeppo
Here, try this:
pawn Код:
CMD:ahouse(playerid, params[]) { if(PlayerData[playerid][AdminLevel] < 6) return SendUnathorizedMessage(playerid);
if(!strcmp("create", cmdtext)) { new level, price, id = 0, Float:X, Float:Y, Float:Z, Float:A, string[126],zone[MAX_ZONE_NAME]; if(sscanf(params, "ii", level, price)) return SendClientMessage(playerid, C_SYNTAX, "Syntax:{FFFFFF} /ahouse create [level] [price]"); if(level < 1) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} House levels must not go below 1."); if(price < 50000) return SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} The minimum value of a house is $50,000.");
for(new i = 0; i < sizeof(HouseData); i ++) { if(HouseData[i][Created] == 0) id = i; } GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid,A); GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
HouseData[id][Entrance][0] = A; HouseData[id][Entrance][1] = X; HouseData[id][Entrance][2] = Y; HouseData[id][Entrance][3] = Z; HouseData[id][Created] = 1; HouseData[id][SalePrice] = price; HouseData[id][ForSale] = true; HouseData[id][Owned] = false; SetHouseInterior(id, level);
format(string, sizeof(string), "* You just created house %d in %s for %s, don't forget to /house sign.", id, zone, ConvertPrice(price)); SendClientMessage(playerid, C_CYAN, string); return 1; }
else { SendClientMessage(playerid, C_SYNTAX, "Error:{FFFFFF} Invalid action."); } return 1; }
|
Nope. Still has the invalid action problem