[ERROR] Command
#1

This is my script:
Quote:

#include <a_samp>
#include <dudb>

#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD3 0xCBCCCEFF
#define COLOR_GRAD4 0xD8D8D8FF
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD6 0xF0F0F0FF
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_PINK 0xFF008096
#define COLOR_BLUE 0x0000FFFF
#define COLOR_GREEN 0x00A80096
#define COLOR_RED 0xFF0000AA
#define COLOR_ORANGE 0xFF800096
#define COLOR_CYAN 0xFF808096
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_FADE1 0xE6E6E6E6
#define COLOR_FADE2 0xC8C8C8C8
#define COLOR_DARKBLUE 0x0000A096
#define COLOR_BLACK 0x00000096
#define COLOR_DARKGOLD 0x80800096
#define COLOR_FADE3 0xAAAAAAAA
#define COLOR_FADE4 0x8C8C8C8C
#define COLOR_FADE5 0x6E6E6E6E
#define COLOR_PURPLE 0xFF00FF96
#define COLOR_BROWN 0x80400096
#define COLOR_DBLUE 0x2641FEAA
#define COLOR_ALLDEPT 0xFF8282AA

new logged[MAX_PLAYERS];
new adminlevel[MAX_PLAYERS];
new money[MAX_PLAYERS];
new playername[MAX_PLAYER_NAME];
new adminname[MAX_PLAYER_NAME];
new score[MAX_PLAYERS];

new string[256];
new cmd[256],tmp[256], tmp2[256];
new idx;


forward OnPlayerLogin(playerid,const string[]);

main()
{

}

public OnGameModeInit()
{
return 1;
}


public OnPlayerRequestClass(playerid, classid)
{
return 1;
}

public OnPlayerConnect(playerid)
{
logged[playerid] = 0;
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
GetPlayerName(playerid, playername, sizeof(playername));
money[playerid] = GetPlayerMoney(playerid);
score[playerid] = GetPlayerScore(playerid);
dini_IntSet(udb_encode(playername), "money", money[playerid]);
dini_IntSet(udb_encode(playername), "score", score[playerid]);
dini_IntSet(udb_encode(playername), "adminlevel", adminlevel[playerid]);
logged[playerid] = 0;
return 1;
}


public OnPlayerSpawn(playerid)
{
if(logged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in yet! USAGE: /login [password]!");
}
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
cmd = strtok(cmdtext, idx);
GetPlayerName(playerid, playername, sizeof(playername));
if(strcmp(cmd, "/register", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /register (password)");
}
else
{
if (!dini_Exists(udb_encode(playername)))
{
dini_Create(udb_encode(playername));
dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
dini_IntSet(udb_encode(playername), "adminlevel", 0);
dini_IntSet(udb_encode(playername), "money", 0);
dini_IntSet(udb_encode(playername), "score", 0);
format(string, sizeof(string), "Account %s has been made! You can now login with the password: %s.", playername, tmp);
SendClientMessage(playerid, COLOR_GREEN, string);
}
else
{
format(string, sizeof(string), "%s is already registered.", playername,tmp);
SendClientMessage(playerid, COLOR_RED, string);
}
}
return 1;
}
if(strcmp(cmd, "/login", true) == 0)
{
if(logged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /login (password)");
}
else
{
if (dini_Exists(udb_encode(playername)))
{
tmp2 = dini_Get(udb_encode(playername), "password");
if (udb_hash(tmp) != strval(tmp2))
{
SendClientMessage(playerid, COLOR_RED, "Wrong password");
}
else
{
logged[playerid] = 1;
money[playerid] = dini_Int(udb_encode(playername), "money");
score[playerid] = dini_Int(udb_encode(playername), "score");
adminlevel[playerid] = dini_Int(udb_encode(playername), "adminlevel");
format(string, sizeof(string), "%s, You are now logged in. Your adminlevel is %d, Your money is %d, and your score is %d.", playername, adminlevel[playerid], money[playerid], score[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerMoney(playerid, money[playerid]);
SetPlayerScore(playerid, score[playerid]);
return 1;
}
}
else
{
format(string, sizeof(string), "The account %s does not exist yet. Type /register [password] to make an account.", playername);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
}
}
if(strcmp(cmdtext,"/kill",true)==0)
{
SetPlayerHealth(playerid, 0);
return 1;
}

if(strcmp(cmdtext,"/suicide",true)==0)
{
SetPlayerHealth(playerid, 0);
return 1;
}

if(strcmp(cmdtext,"/clearchat",true)==0)
{
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
return 1;
}


if(strcmp(cmdtext,"/aclearchat",true)==0)
{
if(adminlevel[playerid] == 7)
{
GetPlayerName(playerid, playername, sizeof(playername));
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
format(string,sizeof(string),"Admin %s has cleared the chat", playername);
SendClientMessageToAll(COLOR_GREEN, string);
return 1;
}
if(strcmp(cmd, "/makeadmin", true) == 0)
{
if(adminlevel[playerid] == 7)
{
if(logged[playerid] == 1)
{
tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
new player1, level;
player1 = strval(tmp);
level = strval(tmp2);
if(!strlen(tmp) && !strlen(tmp2))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /makeadmin [playerid] [level]");
}
else
{
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,sizeof(string),"You have promoted %s to adminlevel %d ", playername, level);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string,sizeof(string),"Administrator %s has promoted %s to adminlevel %d",adminname, playername, level);
SendClientMessageToAll(COLOR_GREEN, string);
adminlevel[playerid] = level;
}
}
}
return 1;
}

if ( !strcmp ( cmdtext, "/changepass", true ) )
{
if(logged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In");
return 1;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changepass [password]");
return 1;
}
if(logged[playerid] == 1)
{
dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
format(string, sizeof(string), "You have successfully changed your password to %s. Dont forget it!", tmp);
SendClientMessage(playerid, COLOR_GREEN, string);
}
return 1;
}
return 0;
}
if ( !strcmp ( cmdtext, "/mystats", true ) )
{
SendClientMessage ( playerid, COLOR_LIGHTBLUE, "====*[Playerstats]*====" );
format(string, sizeof(string), "Score: %d", score[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "Money: %d dollar", money[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "Adminlevel: %d", adminlevel[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}
if(strcmp(cmd, "/makemeadmin", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
if(logged[playerid] == 1)
{
if(adminlevel[playerid] != 3)
{
adminlevel[playerid] = 7;
SendClientMessage(playerid, COLOR_GREEN, "You are now HeadAdmin, Congratulations!");
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are already a Headadmin!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in yet, USAGE: /login password");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not a rcon admin!");
}
return 1;
}
return 0;
}


And if i type a command, doesent matter wich one all says /register (password)

Reply
#2

Please help
Reply
#3

Quote:
Originally Posted by Second
Please help
Reply
#4

pawn Код:
new string[256];
new cmd[256],tmp[256], tmp2[256];
new idx;
Move this part to OnPlayerCommandText.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new cmd[256],tmp[256], tmp2[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    GetPlayerName(playerid, playername, sizeof(playername));
Reply
#5

Every command works now except /changepass and /makeadmin
So please help me, if i type this command there comes SERVER: UKNOWN COMMAND
PLEASE HELP!!
script:
Quote:

#include <a_samp>
#include <dudb>

#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD3 0xCBCCCEFF
#define COLOR_GRAD4 0xD8D8D8FF
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD6 0xF0F0F0FF
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_PINK 0xFF008096
#define COLOR_BLUE 0x0000FFFF
#define COLOR_GREEN 0x00A80096
#define COLOR_RED 0xFF0000AA
#define COLOR_ORANGE 0xFF800096
#define COLOR_CYAN 0xFF808096
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_FADE1 0xE6E6E6E6
#define COLOR_FADE2 0xC8C8C8C8
#define COLOR_DARKBLUE 0x0000A096
#define COLOR_BLACK 0x00000096
#define COLOR_DARKGOLD 0x80800096
#define COLOR_FADE3 0xAAAAAAAA
#define COLOR_FADE4 0x8C8C8C8C
#define COLOR_FADE5 0x6E6E6E6E
#define COLOR_PURPLE 0xFF00FF96
#define COLOR_BROWN 0x80400096
#define COLOR_DBLUE 0x2641FEAA
#define COLOR_ALLDEPT 0xFF8282AA

new logged[MAX_PLAYERS];
new adminlevel[MAX_PLAYERS];
new money[MAX_PLAYERS];
new playername[MAX_PLAYER_NAME];
new adminname[MAX_PLAYER_NAME];
new score[MAX_PLAYERS];





main()
{

}

public OnGameModeInit()
{
return 1;
}


public OnPlayerRequestClass(playerid, classid)
{
return 1;
}

public OnPlayerConnect(playerid)
{
logged[playerid] = 0;
return 1;
}



public OnPlayerSpawn(playerid)
{
if(logged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in yet! USAGE: /login [password]!");
}
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new cmd[256],tmp[256], tmp2[256];
new idx;
cmd = strtok(cmdtext, idx);
GetPlayerName(playerid, playername, sizeof(playername));
if(strcmp(cmd, "/register", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /register (password)");
}
else
{
if (!dini_Exists(udb_encode(playername)))
{
dini_Create(udb_encode(playername));
dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
dini_IntSet(udb_encode(playername), "adminlevel", 0);
dini_IntSet(udb_encode(playername), "money", 0);
dini_IntSet(udb_encode(playername), "score", 0);
format(string, sizeof(string), "Account %s has been made! You can now login with the password: %s.", playername, tmp);
SendClientMessage(playerid, COLOR_GREEN, string);
}
else
{
format(string, sizeof(string), "%s is already registered.", playername,tmp);
SendClientMessage(playerid, COLOR_RED, string);
}
}
return 1;
}
if(strcmp(cmd, "/login", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(logged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
return 1;
}
if(!strlen(tmp)){
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /login (password)");
}
else
{
if (dini_Exists(udb_encode(playername)))
{
tmp2 = dini_Get(udb_encode(playername), "password");
if (udb_hash(tmp) != strval(tmp2))
{
SendClientMessage(playerid, COLOR_RED, "Wrong password");
}
else
{
logged[playerid] = 1;
money[playerid] = dini_Int(udb_encode(playername), "money");
score[playerid] = dini_Int(udb_encode(playername), "score");
adminlevel[playerid] = dini_Int(udb_encode(playername), "adminlevel");
format(string, sizeof(string), "%s, You are now logged in. Your adminlevel is %d, Your money is %d, and your score is %d.", playername, adminlevel[playerid], money[playerid], score[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerMoney(playerid, money[playerid]);
SetPlayerScore(playerid, score[playerid]);
return 1;
}
}
else
{
format(string, sizeof(string), "The account %s does not exist yet. Type /register [password] to make an account.", playername);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
}
}
if(strcmp(cmdtext,"/kill",true)==0)
{
SetPlayerHealth(playerid, 0);
return 1;
}

if(strcmp(cmdtext,"/suicide",true)==0)
{
SetPlayerHealth(playerid, 0);
return 1;
}

if(strcmp(cmdtext,"/clearchat",true)==0)
{
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
SendClientMessage(playerid,COLOR_GREY," ");
return 1;
}


if(strcmp(cmdtext,"/aclearchat",true)==0)
{
if(adminlevel[playerid] == 7)
{
GetPlayerName(playerid, playername, sizeof(playername));
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
SendClientMessageToAll(COLOR_GREY," ");
format(string,sizeof(string),"Admin %s has cleared the chat", playername);
SendClientMessageToAll(COLOR_GREEN, string);
return 1;
}

if(strcmp(cmd, "/makeadmin", true) == 0)
{
if(adminlevel[playerid] == 7)
{
if(logged[playerid] == 1)
{
tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
new player1, level;
player1 = strval(tmp);
level = strval(tmp2);
if(!strlen(tmp) && !strlen(tmp2))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /makeadmin [playerid] [level]");
}
else
{
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,sizeof(string),"You have promoted %s to adminlevel %d ", playername, level);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string,sizeof(string),"Administrator %s has promoted %s to adminlevel %d",adminname, playername, level);
SendClientMessageToAll(COLOR_GREEN, string);
adminlevel[playerid] = level;
}
}
}
return 1;
}

if ( !strcmp ( cmdtext, "/changepass", true ) )
{
if(logged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In");
return 1;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changepass [password]");
return 1;
}
if(logged[playerid] == 1)
{
dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
format(string, sizeof(string), "You have successfully changed your password to %s. Dont forget it!", tmp);
SendClientMessage(playerid, COLOR_GREEN, string);
}
return 1;
}
return 0;
}
if ( !strcmp ( cmdtext, "/mystats", true ) )
{
SendClientMessage ( playerid, COLOR_LIGHTBLUE, "====*[Playerstats]*====" );
format(string, sizeof(string), "Score: %d", score[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "Money: %d dollar", money[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "Adminlevel: %d", adminlevel[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}
if(strcmp(cmd, "/makemeadmin", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
if(logged[playerid] == 1)
{
if(adminlevel[playerid] != 3)
{
adminlevel[playerid] = 7;
SendClientMessage(playerid, COLOR_GREEN, "You are now HeadAdmin, Congratulations!");
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are already a Headadmin!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in yet, USAGE: /login password");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not a rcon admin!");
}
return 1;
}
return 0;
}

public OnPlayerDisconnect(playerid, reason)
{
GetPlayerName(playerid, playername, sizeof(playername));
money[playerid] = GetPlayerMoney(playerid);
score[playerid] = GetPlayerScore(playerid);
dini_IntSet(udb_encode(playername), "money", money[playerid]);
dini_IntSet(udb_encode(playername), "score", score[playerid]);
dini_IntSet(udb_encode(playername), "adminlevel", adminlevel[playerid]);
logged[playerid] = 0;
return 1;
}

Reply
#6

Please help!
Reply
#7

pawn Код:
if ( !strcmp ( cmdtext, "/changepass", true ) )
{
  if(logged[playerid] == 0)
 {
  SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In");
  return 1;
  }
   if(!strlen(tmp))
   {
     SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changepass [password]");
     return 1;
   }
   if(logged[playerid] == 1)
   {
    dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
    format(string, sizeof(string), "You have successfully changed your password to %s. Dont forget it!", tmp);
    SendClientMessage(playerid, COLOR_GREEN, string);
}

return 1;
}
No return 0; needed.

pawn Код:
if(strcmp(cmdtext,"/aclearchat",true)==0)
   {
     if(adminlevel[playerid] == 7)
     {
     GetPlayerName(playerid, playername, sizeof(playername));
     SendClientMessageToAll(COLOR_GREY," ");
     SendClientMessageToAll(COLOR_GREY," ");
     SendClientMessageToAll(COLOR_GREY," ");
     SendClientMessageToAll(COLOR_GREY," ");
     SendClientMessageToAll(COLOR_GREY," ");
     SendClientMessageToAll(COLOR_GREY," ");
     SendClientMessageToAll(COLOR_GREY," ");
     SendClientMessageToAll(COLOR_GREY," ");
     SendClientMessageToAll(COLOR_GREY," ");
     SendClientMessageToAll(COLOR_GREY," ");
      format(string,sizeof(string),"Admin %s has cleared the chat", playername);
      SendClientMessageToAll(COLOR_GREEN, string);
}
     return 1;
     }
And please, use pastebin for big scripts.
And stop bumping and spamming your topic every 2 minutes!!!
Reply
#8

/changepass does still not work, if i do it there comes USAGE: /changepass [password] but if i do /changepass example there comes SERVER: Unknown Command

script:
http://pastebin.com/aH57b8un

Please help!
Reply
#9

Help please(BUMP)
Reply
#10

pawn Код:
if ( !strcmp ( cmd, "/changepass", true ) )
    {
        if(logged[playerid] == 0)
        {
            SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In");
            return 1;
        }
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changepass [password]");
            return 1;
        }
        if(logged[playerid] == 1)
        {
            dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
            format(string, sizeof(string), "You have successfully changed your password to %s. Dont forget it!", tmp);
            SendClientMessage(playerid, COLOR_GREEN, string);
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)