SA-MP Forums Archive
"Unknown Command?" - 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: "Unknown Command?" (/showthread.php?tid=120858)



"Unknown Command?" - jameskmonger - 13.01.2010

http://forum.sa-mp.com/index.php?topic=126584.0
I followed that tutorial, /register works (says "USAGE: /register password"), but /register [PASSWORD] doesn't. (Says unknown command.)


Re: "Unknown Command?" - RyDeR` - 13.01.2010

change it to dcmd. Then you can use params and that's much easier and whitout bug


Re: "Unknown Command?" - jameskmonger - 13.01.2010

Do I just change it to:
pawn Код:
if(strcmp(dcmdtext, "/register", true) == 0)
    {



Re: "Unknown Command?" - RyDeR` - 13.01.2010

like:
dcmd_register(playerid, params[])
{
return 1;
}

Under OnPlayerCommandText add:
dcmd(register, 8, cmdtext);


Re: "Unknown Command?" - Calgon - 13.01.2010

You do know zcmd is much faster?

http://forum.sa-mp.com/index.php?topic=116240.0

There are numerous examples provided too.


Re: "Unknown Command?" - jameskmonger - 13.01.2010

Calgon, if I post my /register and /login, could you convert them to zcmd?


Re: "Unknown Command?" - Grim_ - 13.01.2010

Can you actually just post the /register.

Is your OnPlayerCommandText returning 0? If not, change it to 0.


Re: "Unknown Command?" - jameskmonger - 13.01.2010

pawn Код:
if(strcmp(cmdtext, "/register", true) == 0)
    {
    new cmd[256], idx, file[128], tmp[256], tmp2[256];
    cmd = strtok(cmdtext, idx);
      new name[MAX_PLAYER_NAME];
      tmp = strtok(cmdtext, idx);
      GetPlayerName(playerid, name, sizeof(name));
      if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /register [password]");
      format(file,sizeof(file),"%s.ini",name);
      if(!fexist(file))
            {
              dini_Create(file);
              dini_IntSet(file, "Password", udb_hash(tmp));
              dini_IntSet(file,"AdminLevel", 0);
              dini_IntSet(file,"Cash", 0);
              SendClientMessage(playerid, COLOR_WHITE, "[System]: Registration successful!");
              PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
              GetPlayerName(playerid, name, sizeof(name));
              printf("%s has registered a account!", name);
            }
            else
            {
              SendClientMessage(playerid, COLOR_WHITE, "Account already registered, login or use a different name.");
                PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
            }
        return 1;
    }
pawn Код:
if(strcmp(cmdtext, "/login", true) == 0)
    {
        new cmd[256], idx, file[128], tmp[256], tmp2[256];
    cmd = strtok(cmdtext, idx);
      new PlayerName[24];
      tmp = strtok(cmdtext, idx);
      if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /login [password]");
        new name[MAX_PLAYER_NAME];
        if(IsLogged[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_WHITE, "You already are logged in!");
            return 1;
        }
        else
        {
            GetPlayerName(playerid, name, sizeof(name));
            format(file,sizeof(file),"%s.ini",name);
            if(fexist(file))
            {
            tmp2 = dini_Get(file, "Password");
                if(udb_hash(tmp) != strval(tmp2))
                {
                  SendClientMessage(playerid, COLOR_WHITE, "Login failed!");
                  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
                  printf("%s has failed to login", name);
                }
                else
                {
                    IsLogged[playerid] = 1;
                    SetPlayerMoney(playerid, dini_Int(file, "Cash"));
                    PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
                    SendClientMessage(playerid, COLOR_WHITE, "Login successful!");
                }
            }
        }
        return 1;
    }
Yes, it's returning 0.

Can you convert it to dcmd?


Re: "Unknown Command?" - Grim_ - 13.01.2010

There's no need, I've found your problem.
pawn Код:
new cmd[256], idx, file[128], tmp[256], tmp2[256];
cmd = strtok(cmdtext, idx);
This code should be under OnPlayerCommandText, not the /register command itself. (Same goes to the /login command)
Then, you'll also need to change your command lines to
pawn Код:
if(strcmp(cmd, "/register", true) == 0)
if(strcmp(cmd, "/login", true) == 0)
And it should be fixed, try it


Re: "Unknown Command?" - jameskmonger - 13.01.2010

THANKYOU!

If you ever want to come check out my server, you can feel free to ask me for a house, any car you want, etc.

Thanks, James.