Something wrong?
#1

PHP код:
    if(strcmp(cmd"/gotoco"true) == 0)
    {
        if(
PlayerInfo[playerid][pAdmin] >= 3)
        {
            new 
Floatpos[3], int;
            if(
sscanf(params"fffd"pos[0], pos[1], pos[2], int)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /gotoco [x coordinate] [y coordinate] [z coordinate] [interior]");
            
SendClientMessage(playeridCOLOR_GREY"You have been teleported to the coordinates specified.");
            
SetPlayerPos(playeridpos[0], pos[1], pos[2]);
            
SetPlayerInterior(playeridint);
        }
         return 
1;

Is there something wrong here? Says that params is an undefined symbol. If I'll create a variable, it only makes it a string.
Reply
#2

sscanf is used with zcmd. You may not use strcmp.
Reply
#3

Alright, so, how do I convert the sscanf line to strcmp?
Reply
#4

Quote:
Originally Posted by NealPeteros
Посмотреть сообщение
Alright, so, how do I convert the sscanf line to strcmp?
Use zcmd its much better.
Reply
#5

You can use sscanf anywhere you like. Having your command processed by strcmp or any other command processor is irrelevant.

The problem here is that you are using it as if it were used in the ZCMD processor. params is not declared in OnPlayerText and so you would have to do it yourself. This is why I recommend using ZCMD or any other processor that provides you with a params parameter.
Reply
#6

So, I tried using ZCMD. The reason why I avoid the use zcmd is that when I add a command using zcmd, the other commands that used strcmp (Actually, all of the commands in the script use strcmp) won't work. It'll say that it's an unknown command. I think it's on the return that's making the problem. Should I add return 0 on the end of OnPlayerCommandText or on the end of the zcmd command?
Reply
#7

Quote:
Originally Posted by NealPeteros
Посмотреть сообщение
So, I tried using ZCMD. The reason why I avoid the use zcmd is that when I add a command using zcmd, the other commands that used strcmp (Actually, all of the commands in the script use strcmp) won't work. It'll say that it's an unknown command. I think it's on the return that's making the problem. Should I add return 0 on the end of OnPlayerCommandText or on the end of the zcmd command?
You have to convert all of them to ZCMD.

Quote:
Originally Posted by ZCMD topic
Important: Since v0.3 OnPlayerCommandText cannot be used anymore (also ZCMD_NO_CALLBACK option has been removed), but there are two new callbacks instead:
Reply
#8

Also, using arrays that way is inefficient. Using single variables is much faster.

https://sampforum.blast.hk/showthread.php?tid=580289
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)