Commands arent working -
Tropicali - 08.06.2015
I have an old SAMP script that uses strcmp to work with commands. I recently included zcmd and rewrote a few commands to work with zcmd.
I cant show you an entire public because it'd be way too long, but heres some basic pseudo-code.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new variables;
if(strcmp(cmdtext, "/hello", true) == 0)
{
SendClientMessage(playerid, -1, "Hello.");
return 1;
}
return 1;
}
CMD:hellothere(playerid, params[])
{
SendClientMessage(playerid, -1, "Hello there.");
return 1;
}
That's the basic structure. Commands aren't working at all. They just return SERVER: UNKNOWN COMMAND, both strcmp commands and zcmd commands are broken.
Any suggestions? I've been coding for hours and I'm having a brainfart, this is simple stuff but I just need your guys' help with this one. Thanks.
Re: Commands arent working -
DarkLored - 08.06.2015
You can't use both of them in the same time after you finish converting all of your commands remove the callback OnPlayerCommandText, and your zcmd commands will work.
Re: Commands arent working -
Tropicali - 09.06.2015
There's over 100 commands there, I believe. I'm sure you can use strcmp and zcmd at the same time, isn't there some way of utilizing OnPlayerCommandPerformed or something?
Re: Commands arent working -
DarkLored - 09.06.2015
It will work if you use OnPlayerCommandPerformed callback but it won't work when you are using strcmp on OnPlayerCommandText callback
Re: Commands arent working -
Tropicali - 09.06.2015
Could you show me how to do this? I'm finding it a bit hard to concentrate, like when you've been reading/coding for hours and think "these don't even look like letters anymore," lol.
Use my code how to do it please. I appreciate your help, man.
Re: Commands arent working -
DarkLored - 09.06.2015
I believe that's how you make strcmp and zcmd work together, try it out and see if it works.
Do not convert your commands to OnPlayerCommandPerformed leave it as it is.
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success)
{
return SendClientMessage(playerid, -1, "Unknown Command.");
}
return 1;
}
Re: Commands arent working -
Threshold - 09.06.2015
Use OnPlayerCommandReceived instead of OnPlayerCommandText.