OnPlayerCommandText don't returned.
#1

Hey, guys.
Look, this is my OnPlayerCommandText:
Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
	return SendClientMessage(playerid,COLOR,"Maybe u will help [ /commands ] ?");
}
I'm using zcmd + sscanf, so i didn't need this.
But then i type something wrong, like
Код:
/askdjojasd
It says
Код:
SERVER:Unknow command
But it should say:
Код:
Maybe u will help [ /commands ] ?
Where's the problem? Thanks for help.
Reply
#2

You need to put the command int there like.

public OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmdtext,"/hello",true)==0)
{
SendClientMessage(playerid, COLOR_YELLOW, "Hello");
return 1;
}
return 0;
}
The "COLOR_YELLOW" is only for my script, you need to add a color named COLOR_YELLOW to get it to work.
Reply
#3

Quote:
Originally Posted by Martin_M
Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
	return SendClientMessage(playerid,COLOR,"Maybe u will help [ /commands ] ?");
}
Are you doing this in a filterscript or in a gamemode? Make sure it will be called after everything else.
Reply
#4

Quote:
Originally Posted by MaVe;
Quote:
Originally Posted by Martin_M
Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
	return SendClientMessage(playerid,COLOR,"Maybe u will help [ /commands ] ?");
}
Are you doing this in a filterscript or in a gamemode? Make sure it will be called after everything else.
Gamemode. Everything goods, just this one bug.
Reply
#5

Quote:
Originally Posted by Mystique
You need to put the command int there like.

public OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmdtext,"/hello",true)==0)
{
SendClientMessage(playerid, COLOR_YELLOW, "Hello");
return 1;
}
return 0;
}
The "COLOR_YELLOW" is only for my script, you need to add a color named COLOR_YELLOW to get it to work.
Don't think that i'am noob.
Reply
#6

I think on the top of the script you could make an array, like this:

Код:
new Commands[2][20] = {
{/command} // You have to add all of the commands, which are used in the server... By adding the new command, you must add +1 in the top "new Commands[HERE][20]"...
};
Now on the callback OnPlayerCommandText, you can do like that:

Код:
for(new a=0; a < 2; a++) // Again, the 2 is number how many commands you got in that array, add +1 at each new command...
{
if(!strcmp(cmdtext,Commands[a],false)){
return SendClientMessage(playerid,0xFFFFFFFF,"Wrong command, use /help");
}
}
And i think that would help... (i did not test that, i did just created it). But i think, commands like /ban id reason or something like that, with "space" used in command, will be counted as a bad command and will be told tu use /help.
Reply
#7

Quote:
Originally Posted by Universal
I think on the top of the script you could make an array, like this:

Код:
new Commands[2][20] = {
{/command} // You have to add all of the commands, which are used in the server... By adding the new command, you must add +1 in the top "new Commands[HERE][20]"...
};
Now on the callback OnPlayerCommandText, you can do like that:

Код:
for(new a=0; a < 2; a++) // Again, the 2 is number how many commands you got in that array, add +1 at each new command...
{
if(!strcmp(cmdtext,Commands[a],false)){
return SendClientMessage(playerid,0xFFFFFFFF,"Wrong command, use /help");
}
}
And i think that would help... (i did not test that, i did just created it). But i think, commands like /ban id reason or something like that, with "space" used in command, will be counted as a bad command and will be told tu use /help.
Well.. Thanks. But i don't like that. I'm have zcmd + sscanf, so if you leave space in command, it will send message with exactly command format.
Reply
#8

I think, this thing like, typing any command that doesnt exits and shown messages like "type /help blah,blah..." is useless... You can simply add message when player connects: "All our commands /help", or just with sscanf at any command, if wrongly typed it wil show " * Usage: /asd asd asd" ...
Reply
#9

Post your server's structure (what filterscripts, do they have OnPlayerCommandText, what do they return, etc)
Reply
#10

Not sure, but I think zcmd doesn't use the normal OnPlayerCommandText callback.
Reply


Forum Jump:


Users browsing this thread: