Samp or scripting bug?
#1

When I type in game /std it shows me 'SERVER: Unknown command.' message, even though it should print 'Server: That command doesn't exist. For list of commands /commands.'

But, once I rename the command in the script as '/abc' it works fine.
I have also a command that does all same as /std( /selecttextdraw) and it works fine.
pawn Код:
if(!strcmp(cmdtext,"/std",true,4) && !cmdtext[4])
    {
        CancelSelectTextDraw(playerid);
        SelectTextDraw(playerid, COLOR_YELLOW);
        return 1;
    }
    if(!strcmp(cmdtext,"/selecttextdraw",true,15) && !cmdtext[15] )
    {
        CancelSelectTextDraw(playerid);
        SelectTextDraw(playerid, COLOR_YELLOW);
        return 1;
    }
    //...
    SendClientMessage(playerid,COLOR_GREEN2,"Server: That command doesn't exist. For list of commands /commands.");
    return 1;
Maybe usefull notes:
- this command worked fine for me before 3 weeks. Since then I didn't use it and now found it doesn't work.
- there is not any other command that starts with /std..
- there is no 'return 0' in OnCommandText
- when I putted printf("Hi"); inside /std it didn't show.
- if I type any other commands that doesn't exist it will show "Server: That command doesn't exist. For list of commands /commands.", but if I type /std it shows SERVER: Unknown command".
- Tried, not work:
pawn Код:
if( (!strcmp(cmdtext,"/selecttextdraw",true,15) && !cmdtext[15] ) || (!strcmp(cmdtext,"/std",true,4) && !cmdtext[4]) )
    {
        CancelSelectTextDraw(playerid);
        SelectTextDraw(playerid, COLOR_YELLOW);
        return 1;
    }
    //...
    SendClientMessage(playerid,COLOR_GREEN2,"Server: That command doesn't exist. For list of commands /commands.");
    return 1;
Reply
#2

Quote:
Originally Posted by Roko_foko
Посмотреть сообщение
When I type in game /std it shows me 'SERVER: Unknown command.' message, even though it should print 'Server: That command doesn't exist. For list of commands /commands.'

But, once I rename the command in the script as '/abc' it works fine.
I have also a command that does all same as /std( /selecttextdraw) and it works fine.
pawn Код:
if(!strcmp(cmdtext,"/std",true,4) && !cmdtext[4])
    {
        CancelSelectTextDraw(playerid);
        SelectTextDraw(playerid, COLOR_YELLOW);
        return 1;
    }
    if(!strcmp(cmdtext,"/selecttextdraw",true,15) && !cmdtext[15] )
    {
        CancelSelectTextDraw(playerid);
        SelectTextDraw(playerid, COLOR_YELLOW);
        return 1;
    }
    //...
    SendClientMessage(playerid,COLOR_GREEN2,"Server: That command doesn't exist. For list of commands /commands.");
    return 1;
Maybe usefull notes:
- this command worked fine for me before 3 weeks. Since then I didn't use it and now found it doesn't work.
- there is not any other command that starts with /std..
- there is no 'return 0' in OnCommandText
- when I putted printf("Hi"); inside /std it didn't show.
I think I don't understand your problem completely. So you have this /std command and if you delete it temporally, then the stuff with the commands works?
Reply
#3

So if you want to show "Server: That command doesn't exist. For list of commands /commands"
Код:
if(!strcmp(cmdtext,"/std",true,4) && !cmdtext[4])
    {
        CancelSelectTextDraw(playerid);
        SelectTextDraw(playerid, COLOR_YELLOW);
        return 1;
    }
    if(!strcmp(cmdtext,"/selecttextdraw",true,15) && !cmdtext[15] )
    {
        CancelSelectTextDraw(playerid);
        SelectTextDraw(playerid, COLOR_YELLOW);
        return 1;
    }
    return SendClientMessage(playerid,COLOR_GREEN2,"Server: That command doesn't exist. For list of commands /commands.");;
I think this might work
Reply
#4

Quote:
Originally Posted by DeathOnaStick
Посмотреть сообщение
I think I don't understand your problem completely. So you have this /std command and if you delete it temporally, then the stuff with the commands works?
No, only that command doesn't work. All other commands do.
I can't use that command in game, but other commands I can.
Also, if I rename /std to /abc, I am able to use command /abc.


Quote:
Originally Posted by TheDeath
Посмотреть сообщение
So if you want to show "Server: That command doesn't exist. For list of commands /commands"
Код:
if(!strcmp(cmdtext,"/std",true,4) && !cmdtext[4])
    {
        CancelSelectTextDraw(playerid);
        SelectTextDraw(playerid, COLOR_YELLOW);
        return 1;
    }
    if(!strcmp(cmdtext,"/selecttextdraw",true,15) && !cmdtext[15] )
    {
        CancelSelectTextDraw(playerid);
        SelectTextDraw(playerid, COLOR_YELLOW);
        return 1;
    }
    return SendClientMessage(playerid,COLOR_GREEN2,"Server: That command doesn't exist. For list of commands /commands.");;
I think this might work
This is completly same as I put. If I type any other commands that doesn't exist it will show "Server: That command doesn't exist. For list of commands /commands.", but if I type /std it shows SERVER: Unknown command".
Reply
#5

Hmm. What is this cmdtext[4] actually for? For me it kinda seems useless but I don't think the problem is going to be fixed by that. But who knows?

Well in my opinion your script should work fine, if it's not that cmdtext-part.
Reply
#6

Quote:
Originally Posted by DeathOnaStick
Посмотреть сообщение
Hmm. What is this cmdtext[4] actually for? For me it kinda seems useless but I don't think the problem is going to be fixed by that. But who knows?

Well in my opinion your script should work fine, if it's not that cmdtext-part.
Yea it worked fine before, but now? what the hell.
!cmdtext[4] is same as cmdtext[4]==0 and that is same as cmdtext[4]='\0' ( or cmdtext[4]=EOS, EndOfString).
In this case:
pawn Код:
if(!cmdtext[4]) /*is same as */ if(strlen(cmdtext)==strlen("/std"))
Reply
#7

Quote:
Originally Posted by Roko_foko
Посмотреть сообщение
Yea it worked fine before, but now? what the hell.
!cmdtext[4] is same as cmdtext[4]==0 and that is same as cmdtext[4]='\0' ( or cmdtext[4]=EOS, EndOfString).
In this case:
pawn Код:
if(!cmdtext[4]) /*is same as */ if(strlen(cmdtext)==strlen("/std"))
Alright I see, shouldn't be a prob here. Possible it has a problem with the name "std", due to the fact that this a namespace in C++. Probably this is why it does not want to see "std" in your strings. Although this is just an idea.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)