Server Unknown Command
#1

Hello,
I stopped coding 5days ago, and today I returned, and I'm facing a problem with my gamemode...
Any command I type it returns "Server Unknown Command".
I've removed every filterscripts to make sure it wasn't any conflit with it, and I've also removed all commands lefting just one to test, and the result is the same...
Any suggestions about what could be this strange bug?

Here's my code:

PHP код:
stock split(const strsrc[], strdest[][], delimiter){
    new 
piliaNumlen;
    while(
pi<=strlen(strsrc)){
        if(
strsrc[pi]==delimiter || pi==strlen(strsrc)){
            
len=strmid(strdest[aNum], strsrclipi128);
            
strdest[aNum][len]=0;
            
li=pi+1;
            
aNum++;
        }
        
pi++;
    }
    return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[]){
   new 
cmd[100][128];
   
split(cmdtextcmd' ');
   if(
strcmp(cmd[0], "/test"true)==0){
      return 
SendClientMessage(playerid0xFBFF00FF"test");
   }
   return 
SendClientMessage(playerid0xFBFF00FF"invalid command");

Reply
#2

Are you sure you have the correct GameMode in your server.cfg? check the rest of the lines on that file if there's anything strange?
If not, I think this could be a bug....since when did it start to happen? did you add a new CMD lately before this problem?
Reply
#3

No, that's why it seems really weird for me... I didn't add anything since 5days ago, and now that I returned to code I saw that problem, I'm not sure if it was already there 5 days ago, but everything else is working fine.
I have the correct gamemode. It was correctly compiled with pawno. I have no other filterscripts installed.

I hope that someone already faced similar issue and can help me, it should probably be a silly misunderstood, but I'm not seeing it..
Reply
#4

May have defined <ZCMD> and you use another command ...
Reply
#5

Quote:
Originally Posted by SkL_MD
Посмотреть сообщение
May have defined <ZCMD> and you use another command ...
I don't use ZCMD, the online includes that I have:
#include <a_samp>
#include <a_mysql>
#include <sscanf2>
#include <strlib>
#include <removebuilding>
#include <streamer>
Reply
#6

Try to use ZCMD.
Reply
#7

The issue would appear to be that you're splitting the string by spaces, but if there are no spaces then nothing is going to be sent to the 2 dimensional array you've named "cmd". Which means it's just going to be blank and therefore the if statement won't be true.

You can confirm this by typing "/test test", without the quotes.

To fix it, you could simply do this:

pawn Код:
new cmd[100][128];
strcat(cmd[0], cmdtext);
split(cmdtext, cmd, ' ');
Then the first cell in the array will contain the command regardless. The size of that array is quite large too, are you really ever going to need 100 parameters? Might want to rethink that.

You should also consider moving onto a command processing system like ZCMD with sscanf to split the commands parameters up, it's a lot easier and there is less stuff you have to deal with, not to mention more efficient.
Reply
#8

Thank you for the suggestion, but I don't like ZCMD, so I'll just keep it like this.
I've already fixed the bug, it was because of the cmd[100][128], thank you for the tip, I defined that so long ago that I don't remember why I put so many params xD

Anyways, I give you +REP, thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)