SA-MP Forums Archive
Issue with sscanf2 and subcommands - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Issue with sscanf2 and subcommands (/showthread.php?tid=147021)



Issue with sscanf2 and subcommands - dcmd_crash - 10.05.2010

Hi, I have a command that handles most of a players stuff. This particular command handles an Administrators "hidden" status, makes him/her invisible. However, when used it doesn't do anything? Is there something I'm doing wrong? I have tried a few variations on the sscanf format, none are working!

params = the command | mCommand = main command (hide) | sCommand = the sub command (on/off)

pawn Код:
if(strcmp(mCommand, "hide", true) == 0)
    {
      if(PlayerInfo[playerid][Level] >= 3)
      {
        new sCommand[3];
        if(sscanf(params, mCommand, "s[3]", sCommand))
                {
                     SendClientMessage(playerid, Red, "USAGE: /my hide [on/off]");
                }
        if(strcmp(sCommand, "on", true) == 0)
        {
                    if(PlayerInfo[playerid][Hidden]) return SendClientMessage(playerid, Red, "You are alreading invisible!");
                    for(new i; i < MAX_PLAYERS; i++)
                    {
                    if(IsPlayerConnected(i) && PlayerInfo[i][Level] < 3)
                        {
                          ShowPlayerNameTagForPlayer(i, playerid, false);
                          SetPlayerMarkerForPlayer(i, playerid, (GetPlayerColor(playerid) & 0xFFFFFF00));
                        }
                    }
                    format(string, sizeof(string), "%s[%d] is now hidden for players", pName(playerid), playerid);
                MessageToAdminsEx(playerid, MAD_WHITE, string);
                PlayerInfo[playerid][Hidden] = 1;
                SendClientMessage(playerid, MANAGEMENT, "* You are now invisible to players.");
                    return 1;
                }
                if(strcmp(sCommand, "off", true) == 0)
                {
                    if(PlayerInfo[playerid][Hidden] == 0) return SendClientMessage(playerid, Red, "You're hide is already off!");
                    for(new i; i < MAX_PLAYERS; i++)
                    {
                    if(IsPlayerConnected(i) && PlayerInfo[i][Level] < 3)
                        {
                          ShowPlayerNameTagForPlayer(i, playerid, false);
                          SetPlayerMarkerForPlayer(i, playerid, (GetPlayerColor(playerid)));
                        }
                    }
                    format(string, sizeof(string), "%s[%d] is not invisible anymore.", pName(playerid), playerid);
                MessageToAdminsEx(playerid, MAD_WHITE, string);
                PlayerInfo[playerid][Hidden] = 0;
                SendClientMessage(playerid, MANAGEMENT, "* You are now invisible to players.");
          return 1;
                }
            } else return 0;
        }
Any help is much appreciated.


Re: Issue with sscanf2 and subcommands - dcmd_crash - 13.05.2010

BUMPERLICIOUS!!