SA-MP Forums Archive
Something wrong? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Something wrong? (/showthread.php?tid=620261)



Something wrong? - NealPeteros - 28.10.2016

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.


Re: Something wrong? - henkas - 28.10.2016

sscanf is used with zcmd. You may not use strcmp.


Re: Something wrong? - NealPeteros - 28.10.2016

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


Re: Something wrong? - Maheerali - 28.10.2016

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


Re: Something wrong? - AndySedeyn - 28.10.2016

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.


Re: Something wrong? - NealPeteros - 28.10.2016

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?


Re: Something wrong? - AndySedeyn - 28.10.2016

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:



Re: Something wrong? - Dignity - 28.10.2016

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

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