Server Unknown command
#1

Hey. I was scripting on a inc file. Which is my first time so im just alittle lost.

So i made this
pawn Код:
public xpc(playerid)
{
    new xpcheck = xp[playerid]-60;
    if(xpcheck >= 0)
    {
      new oldlevel = level[playerid];
      level[playerid]++;
      OnPlayerLevelChange(playerid,level[playerid],oldlevel);
      return 1;
      }
    else if(xpcheck <= -60)
    {
        new oldlevel = level[playerid];
      level[playerid]--;
      OnPlayerLevelChange(playerid,level[playerid],oldlevel);
      return 1;
      }
}
Then i made some commands to test it

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        ShowStatusForPlayer(playerid);
        return 1;
        }
  if (strcmp("/givemelevel", cmdtext, true, 10) == 0)
  {
    GivePlayerXP(playerid,60);
    return 1;
    }
  if (strcmp("/givemexp", cmdtext, true, 10) == 0)
  {
    GivePlayerXP(playerid,10);
    return 1;
    }
    return 0;
}
Now there should also be this thing sending me a message every time level changes

pawn Код:
public OnPlayerLevelChange(playerid,newlevel,oldlevel)
{
    SendClientMessage(playerid,0xFFFFFF,"Level changed!");
    return 1;
}
Now all this gives no errors. But i recieve "SERVER: Unknown command" each time it is supposed to change level. Plus that GivePlayerXP(playerid,10);
6 times sets hes XP to 60 where it is supposed to be 0 and level should be 1. And when i get this unknown command thing just 1 more XP levels up


Hope you get my point
Reply
#2

Bump
Reply
#3

change:
Код:
public xpc(playerid)
{
new xpcheck = xp[playerid]-60;
if(xpcheck >= 0)
{
  new oldlevel = level[playerid];
  level[playerid]++;
  OnPlayerLevelChange(playerid,level[playerid],oldlevel);
  return 1;
  }
else if(xpcheck <= -60)
{
new oldlevel = level[playerid];
  level[playerid]--;
  OnPlayerLevelChange(playerid,level[playerid],oldlevel);
  return 1;
  }
}
to

Код:
public xpc(playerid)
{
new xpcheck = xp[playerid]-60;
new oldlevel = level[playerid];
if(xpcheck >= 0)
{
  level[playerid]++;
  OnPlayerLevelChange(playerid,level[playerid],oldlevel);
  return 1;
  }
else if(xpcheck <= -60)
{
  level[playerid]--;
  OnPlayerLevelChange(playerid,level[playerid],oldlevel);
  return 1;
  }
}
your not calling this:
Код:
xpc(playerid)
in any script that you have shown us. This is the thing to check levels right? so you need to call it to check them
Reply
#4

I have called xpc every time the xp changes.

Will try the code when i get home later today
Reply
#5

Quote:
Originally Posted by adsy
in any script that you have shown us.
Well where is it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)