"Unknown Command?"
#1

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.)
Reply
#2

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

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

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

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

You do know zcmd is much faster?

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

There are numerous examples provided too.
Reply
#6

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

Can you actually just post the /register.

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

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?
Reply
#9

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
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)