sscanf command - confused
#1

Code:
PHP код:
CMD:createbuilding(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 4) return SCM(playeridCOLOR_GREY"You are not allowed to use this!");
    
    new 
Float:xFloat:yFloat:zinteriorvwFloat:exFloat:eyFloat:ezbname[120], DB_Query[256];
    if (
sscanf(params"fffiis[120]"exeyezinteriorvwbname)) SendClientMessage(playeridCOLOR_GREY"> Type /createbuilding <exitposX> <exitposY> <exitposZ> <interior> <virtualworld> <name>");
    {
        
GetPlayerPos(playeridxyz);
        
mysql_format(DatabaseDB_Querysizeof(DB_Query), "INSERT INTO `Buildings` ( `VirtualWorld`, `InteriorID`, `EntranceX`, `EntranceY`, `EntranceZ`, `ExitX`, `ExitY`, `ExitZ`, `Name`)\
        VALUES ( %d, %d, %f, %f, %f, %f, %f, %f, '%s')"
vwinteriorxyzexeyezbname);
         
mysql_tquery(DatabaseDB_Query);
         
SCM(playeridCOLOR_YELLOW"Building created succesfully.");
         
SCM(playeridCOLOR_YELLOW"Type /reloadbuildings when you done.");
    }
    return 
1;

How can I make this trigger only if all the fields are filled?
Reply
#2

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;
}
Reply
#3

You weren't using return and read the comments in the script.

PHP код:
CMD:createbuilding(playeridparams[]) 

    if(
PlayerInfo[playerid][pAdmin] < 4) return SCM(playeridCOLOR_GREY"You are not allowed to use this!"); // just like this, we did in the next if check.
    
new Float:xFloat:yFloat:zinteriorvwFloat:exFloat:eyFloat:ezbname[120], DB_Query[256];
    if (
sscanf(params"fffiis[120]"exeyezinteriorvwbname)) return SendClientMessage(playeridCOLOR_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(playeridxyz);
    
mysql_format(DatabaseDB_Querysizeof(DB_Query), "INSERT INTO `Buildings` ( `VirtualWorld`, `InteriorID`, `EntranceX`, `EntranceY`, `EntranceZ`, `ExitX`, `ExitY`, `ExitZ`, `Name`)\ 
        VALUES ( %d, %d, %f, %f, %f, %f, %f, %f, '%s')"
vwinteriorxyzexeyezbname); 
    
mysql_tquery(DatabaseDB_Query); 
    
SCM(playeridCOLOR_YELLOW"Building created succesfully."); 
    
SCM(playeridCOLOR_YELLOW"Type /reloadbuildings when you done."); 
    return 
1

Reply
#4

Thanks guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)