SERVER: Unknown command
#1

Hello.
Yesterday I started making my own SA-MP server. I added command to buy levels, but there's something wrong.
When I type /levelup it says: SERVER: Unknown command.
Can anyone help me?

Here's my script. I know it's a bit messy, but it's just the beginning.
Pastebin
Reply
#2

Hey, try using this:

Код:
if(strcmp("/levelup", cmdtext, true) == 0)
{
  	if(gPlayerLogged[playerid] == 1)
	{
		if(PlayerInfo[playerid][pLevel] == 0)
		{
			if(nauda >= 1)
			{
  				SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tu nopirki 1 limeni");
  				SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tagad tu vari izmantot komandu /count");
  				PlayerInfo[playerid][pLevel] = 1;
  				return 1;
			}
		}
	}
	else return SendClientMessage(playerid, COLOR_WHITE, "[Kluda:] Tev vispirms ir jaielogojas");
}
Reply
#3

Nop, that doesn't work. :: SERVER: Unknown command
It only works, when i'm not logged in.
Reply
#4

Try removing the else, so there will only be the return
Reply
#5

Try it:

pawn Код:
if(strcmp("/levelup", cmdtext, true) == 0)
{
    if(gPlayerLogged[playerid] == 1)
    {
        if(PlayerInfo[playerid][pLevel] == 0)
        {
            if(nauda >= 1)
            {
                SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tu nopirki 1 limeni");
                SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tagad tu vari izmantot komandu /count");
                PlayerInfo[playerid][pLevel] = 1;
            }
        }
    }
    else SendClientMessage(playerid, COLOR_WHITE, "[Kluda:] Tev vispirms ir jaielogojas");
    return 1;
}
Reply
#6

Quote:
Originally Posted by dice7
Try removing the else, so there will only be the return
You mean like this?:
Код:
if(strcmp("/levelup", cmdtext, true, 10) == 0)
	{
  		if(gPlayerLogged[playerid] == 1)
		{
			if(PlayerInfo[playerid][pLevel] == 0)
			{
				if(nauda >= 1)
				{
  					SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tu nopirki 1 limeni");
  					SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tagad tu vari izmantot komandu /count");
  					PlayerInfo[playerid][pLevel] = 1;
  					return 1;
				}
			}
		}
		return SendClientMessage(playerid, COLOR_GREY, "[Kluda:] Tev vispirms ir jaielogojas");
	}
Now it says "[Kluda:] Tev vispirms ir jaielogojas" even if I'm logged in.
Reply
#7

Quote:
Originally Posted by rumbiic
Quote:
Originally Posted by dice7
Try removing the else, so there will only be the return
You mean like this?:
Код:
if(strcmp("/levelup", cmdtext, true, 10) == 0)
	{
  		if(gPlayerLogged[playerid] == 1)
		{
			if(PlayerInfo[playerid][pLevel] == 0)
			{
				if(nauda >= 1)
				{
  					SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tu nopirki 1 limeni");
  					SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tagad tu vari izmantot komandu /count");
  					PlayerInfo[playerid][pLevel] = 1;
  					return 1;
				}
			}
		}
		return SendClientMessage(playerid, COLOR_GREY, "[Kluda:] Tev vispirms ir jaielogojas");
	}
Now it says "[Kluda:] Tev vispirms ir jaielogojas" even if I'm logged in.
pawn Код:
if(strcmp("/levelup", cmdtext, true, 10) == 0)
{
    if(gPlayerLogged[playerid] == 1)
    {
        if(PlayerInfo[playerid][pLevel] == 0)
        {
            if(nauda >= 1)
            {
                SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tu nopirki 1 limeni");
                SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tagad tu vari izmantot komandu /count");
                PlayerInfo[playerid][pLevel] = 1;
                return 1;
            }
            //SendClientMessage(playerid, color, "you need to be level 0"):
            return 1;
        }
        //SendClientMessage(playerid, color, "you need to be logged"):
        return 1;
    }
    return SendClientMessage(playerid, COLOR_GREY, "[Kluda:] Tev vispirms ir jaielogojas");
}
Reply
#8

Quote:
Originally Posted by dice7
pawn Код:
if(strcmp("/levelup", cmdtext, true, 10) == 0)
{
    if(gPlayerLogged[playerid] == 1)
    {
        if(PlayerInfo[playerid][pLevel] == 0)
        {
            if(nauda >= 1)
            {
                SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tu nopirki 1 limeni");
                SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tagad tu vari izmantot komandu /count");
                PlayerInfo[playerid][pLevel] = 1;
                return 1;
            }
            //SendClientMessage(playerid, color, "you need to be level 0"):
            return 1;
        }
        //SendClientMessage(playerid, color, "you need to be logged"):
        return 1;
    }
    return SendClientMessage(playerid, COLOR_GREY, "[Kluda:] Tev vispirms ir jaielogojas");
}
Now it doesn't say anything when I'm logged in.
Reply
#9

Omg, remove the comments and put an actual SendClientMessage there
Reply
#10

Try what I said before:

Quote:
Originally Posted by Merlо
Try it:

pawn Код:
if(strcmp("/levelup", cmdtext, true) == 0)
{
    if(gPlayerLogged[playerid] == 1)
    {
        if(PlayerInfo[playerid][pLevel] == 0)
        {
            if(nauda >= 1)
            {
                SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tu nopirki 1 limeni");
                SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tagad tu vari izmantot komandu /count");
                PlayerInfo[playerid][pLevel] = 1;
            }
        }
    }
    else SendClientMessage(playerid, COLOR_WHITE, "[Kluda:] Tev vispirms ir jaielogojas");
    return 1;
}
If it don't resolve, replace all your public OnPlayerCommandText with it:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new idx;
    new string[256];
    new cmd[256];
    new tmp[256];
    cmd = strtok(cmdtext, idx);
    nauda = GetPlayerMoney(playerid);
    if (strcmp(cmd, "/login", true) ==0 )
    {
      if(IsPlayerConnected(playerid))
      {
        new tmppass[64];
            if(gPlayerLogged[playerid] == 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "[Kluda:] Tu jau esi ielogojies.");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "[***:] /login [parole]");
                return 1;
            }
            strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
            Encrypt(tmppass);
            OnPlayerLogin(playerid,tmppass);
        }
        return 1;
    }
    if (strcmp(cmd, "/register", true) ==0 )
    {
      if(IsPlayerConnected(playerid))
      {
        if(gPlayerLogged[playerid] == 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "[Kluda:] Tu jau esi ielogojies.");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "Speletaji/%s.ini", sendername);
            new File: hFile = fopen(string, io_read);
            if (hFile)
            {
                SendClientMessage(playerid, COLOR_GREY, "[Kluda:] Sis niks jau ir aiznemts, izvelies citu.");
                fclose(hFile);
                return 1;
            }
        new tmppass[64];
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "[***:] /register [parole]");
                return 1;
            }
            strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
            Encrypt(tmppass);
            OnPlayerRegister(playerid,tmppass);
        }
        return 1;
    }
    if(strcmp("/levelup", cmdtext, true) == 0)
    {
        if(gPlayerLogged[playerid] == 1)
        {
            if(PlayerInfo[playerid][pLevel] == 0)
            {
                if(nauda >= 1)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tu nopirki 1 limeni");
                    SendClientMessage(playerid, COLOR_WHITE, "[Info:] Tagad tu vari izmantot komandu /count");
                    PlayerInfo[playerid][pLevel] = 1;
                }
            }
        }
        else SendClientMessage(playerid, COLOR_WHITE, "[Kluda:] Tev vispirms ir jaielogojas");
        return 1;
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)