sscanf command - confused -
AndreiWow - 02.02.2017
Code:
PHP код:
CMD:createbuilding(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4) return SCM(playerid, COLOR_GREY, "You are not allowed to use this!");
new Float:x, Float:y, Float:z, interior, vw, Float:ex, Float:ey, Float:ez, bname[120], DB_Query[256];
if (sscanf(params, "fffiis[120]", ex, ey, ez, interior, vw, bname)) SendClientMessage(playerid, COLOR_GREY, "> Type /createbuilding <exitposX> <exitposY> <exitposZ> <interior> <virtualworld> <name>");
{
GetPlayerPos(playerid, x, y, z);
mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `Buildings` ( `VirtualWorld`, `InteriorID`, `EntranceX`, `EntranceY`, `EntranceZ`, `ExitX`, `ExitY`, `ExitZ`, `Name`)\
VALUES ( %d, %d, %f, %f, %f, %f, %f, %f, '%s')", vw, interior, x, y, z, ex, ey, ez, bname);
mysql_tquery(Database, DB_Query);
SCM(playerid, COLOR_YELLOW, "Building created succesfully.");
SCM(playerid, COLOR_YELLOW, "Type /reloadbuildings when you done.");
}
return 1;
}
How can I make this trigger only if all the fields are filled?
Re: sscanf command - confused -
Runn3R - 02.02.2017
pawn Код:
CMD:createbuilding(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4) return SCM(playerid, COLOR_GREY, "You are not allowed to use this!");
new Float:x, Float:y, Float:z, interior, vw, Float:ex, Float:ey, Float:ez, bname[120], DB_Query[256];
if (!sscanf(params, "fffiis[120]", ex, ey, ez, interior, vw, bname))
{
GetPlayerPos(playerid, x, y, z);
mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `Buildings` ( `VirtualWorld`, `InteriorID`, `EntranceX`, `EntranceY`, `EntranceZ`, `ExitX`, `ExitY`, `ExitZ`, `Name`)\
VALUES ( %d, %d, %f, %f, %f, %f, %f, %f, '%s')", vw, interior, x, y, z, ex, ey, ez, bname);
mysql_tquery(Database, DB_Query);
SCM(playerid, COLOR_YELLOW, "Building created succesfully.");
SCM(playerid, COLOR_YELLOW, "Type /reloadbuildings when you done.");
}
else SendClientMessage(playerid, COLOR_GREY, "> Type /createbuilding <exitposX> <exitposY> <exitposZ> <interior> <virtualworld> <name>");
return 1;
}
Re: sscanf command - confused -
Logic_ - 02.02.2017
You weren't using
return and read the comments in the script.
PHP код:
CMD:createbuilding(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4) return SCM(playerid, COLOR_GREY, "You are not allowed to use this!"); // just like this, we did in the next if check.
new Float:x, Float:y, Float:z, interior, vw, Float:ex, Float:ey, Float:ez, bname[120], DB_Query[256];
if (sscanf(params, "fffiis[120]", ex, ey, ez, interior, vw, bname)) return SendClientMessage(playerid, COLOR_GREY, "> Type /createbuilding <exitposX> <exitposY> <exitposZ> <interior> <virtualworld> <name>"); // if fields aren't filled, send the message, return basically is used to stop a function at a point.
GetPlayerPos(playerid, x, y, z);
mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `Buildings` ( `VirtualWorld`, `InteriorID`, `EntranceX`, `EntranceY`, `EntranceZ`, `ExitX`, `ExitY`, `ExitZ`, `Name`)\
VALUES ( %d, %d, %f, %f, %f, %f, %f, %f, '%s')", vw, interior, x, y, z, ex, ey, ez, bname);
mysql_tquery(Database, DB_Query);
SCM(playerid, COLOR_YELLOW, "Building created succesfully.");
SCM(playerid, COLOR_YELLOW, "Type /reloadbuildings when you done.");
return 1;
}
Re: sscanf command - confused -
AndreiWow - 02.02.2017
Thanks guys