#1
Отправлено 08 декабря 2012 — 16:07
-
- ДЭЭМ, БООЙ
-
Здравствуйте форумчане
У меня проблема не с командой а с SERVER:Unknown command. Я лазил по форуму искал, искал и нашел, но не то, что мне нужно. Везде было только чтобы поменять эту надпись и «Команда работает но пишет SERVER:Unknown command.»
Проблема в том, что команда даже не работает. Просто напримерр ввожу /test и вылезает этот «паразит» Server: unknown command
. Как это исправить? вот код>
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmd, "/test", true)) { SetPlayerPos(playerid, 1412.0902,-1699.6783,13.5395); return 1; } return SendClientMessage(playerid,0xFFFFFFFF,"Команды не существует"); }
Помогите ув.Пользователи
1
#2
Отправлено 08 декабря 2012 — 17:58
-
- Пользователь
-
p.s. если что я новичек
зачем «команды не существует»? может быть там надо вставить else?
и почему там ретурн так рано стоит?
0
#3
Отправлено 08 декабря 2012 — 18:04
-
- Banned
-
SERVER:Unknown command. — ТАКОЙ КОМАНДЫ НЕСУЩЕСТВУЕТ !
1) Найди у себя в моде public OnPlayerCommandText
2) И туда в самый низ паблика, поставить вместо return 0; вот это:
return SendClientMessage(playerid,COLOR_WHITE,»Свой текст»);
Чтобы ничего непрописывалось , убери надпись в кавычках «Свой текст»
Если помог ставь +
#4
Отправлено 08 декабря 2012 — 18:07
-
- ДЭЭМ, БООЙ
-
0
#5
Отправлено 08 декабря 2012 — 18:08
-
- Banned
-
BiGGY (08 декабря 2012 — 17:58) писал:
p.s. если что я новичек
зачем «команды не существует»? может быть там надо вставить else?
и почему там ретурн так рано стоит?
Он написал «У меня проблема не с командой а с SERVER:Unknown command. «
#6
Отправлено 08 декабря 2012 — 18:10
-
- ДЭЭМ, БООЙ
-
BiGGY, братан, return возвращает функцию. Этот return стоит как раз для public’a там не имеет разницы поставить 1 или SendClient… Функция все равно вернется.
Lev_Popov, Ну… Если бы была проблема с командой, я бы написал что с командой. А у меня ни одна команда не работает, и еще пишет эту херню.
0
#7
Отправлено 08 декабря 2012 — 19:42
-
- ДЭЭМ, БООЙ
-
0
#8
Отправлено 08 декабря 2012 — 23:45
-
- Знаток
-
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/test", true)) // cmdtext { SetPlayerPos(playerid, 1412.0902,-1699.6783,13.5395); return 1; } return SendClientMessage(playerid,0xFFFFFFFF,"Команды не существует"); }
1
#9
Отправлено 08 декабря 2012 — 23:51
-
- ДЭЭМ, БООЙ
-
Little (08 декабря 2012 — 23:45) писал:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/test", true)) // cmdtext { SetPlayerPos(playerid, 1412.0902,-1699.6783,13.5395); return 1; } return SendClientMessage(playerid,0xFFFFFFFF,"Команды не существует"); }
ок, после проверю
0
#10
Отправлено 09 декабря 2012 — 09:20
-
- Эксперт
-
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp("/text", cmdtext, true) == 0) { // Тело команды return 1; } return SendClientMessage(playerid, COLOR_RED, "x {FFFFFF}Команды не существует."); }
1
- ← Предыдущая тема
- Вопросы по скриптингу
- Следующая тема →
- Вы не можете создать новую тему
-
Тема закрыта
1 человек читают эту тему
0 пользователей, 1 гостей, 0 скрытых пользователей
-
#1
Многие знают что если пишешь неправильную команду в чат то пишет «SERVER:Unknown command». Сейчас я покажу как её убрать или заменить на свою
Идем в public OnPlayerCommandText, и он закрывается:
return 0;
}
И вместо этого ставим это:
return 1;
}
Вписали? Компилируем. И если нет ошибок то всё правильно.
Ах да, а вот если заменить на свою надпись
return SendClientMessage(playerid, 0xC3C3C3FF, «* Команды не существует, введите /help для просмотра доступных команд.»);
}
Всё очень просто…
Автор: **_**
Последнее редактирование модератором: 21.11.2014
LHTTD
Темная сторона Форума
-
#3
Лучше давно уже перейти на ZCMD,он более проще и быстрее работает чем strtok!!!
Mirex
Руководитель проекта
-
#4
Лучше давно уже перейти на ZCMD,он более проще и быстрее работает чем strtok!!!
Если переходить с одного командного процессора на другой, так лучше уж нынче использовать dc_cmd.
LHTTD
Темная сторона Форума
-
#5
Если переходить с одного командного процессора на другой, так лучше уж нынче использовать dc_cmd.
dc_cmd слабоват тем более еще плагин нужен…
Mirex
Руководитель проекта
-
#6
dc_cmd слабоват тем более еще плагин нужен…
Слабоват? Вы тесты скорости смотрели? DC_CMD у ZCMD во много выигрывает.
-
#7
Слушай, у меня если вводишь не верную команду, он просто ничего не делает, а как сделать чтобы он писал, что неверная команда?
-
#9
@SHOROOP, OnPlayerCommandPerformed, если быть точнее.
-
#10
OnPlayerCommandRecieved()
Нет такого
-
#11
@JoKeR2020, OnPlayerCommandPerformed() вызывается сразу после выполнения команды. OnPlayerCommandRecieved() — до выполнения. Зачем лишний раз гонять командный процессор проверять наличие несуществующей команды, особенно если здесь же можно вернуть 0 и запретить выполнение?
@Дима Рок, доки по DC_CMD почитайте. Это нативная функция плагина.
Последнее редактирование модератором: 03.02.2016
-
#12
@SHOROOP, ты хочешь что ли проверять наличие команды в Recieved? Ну тогда ещё нормально.
- Регистрация
- 26 Янв 2012
- Сообщения
- 243
- Лучшие ответы
- 0
- Репутация
- 46
- Адрес
-
СБГ
-
#1
Всем привет! Долго искал решение проблемы связанной с SERVER: Unknown Command, пока не нашел решение на wiki.sa-mp.com (Не реклама)Вот решил выложить его сюда, так-ка много было вопросов связанных именно с этой темой
Начнем пожалуй
Параметры:
PHP:
(playerid,cmdtext[])
playerid ID игрока, набравшего команду.
cmdtext[] Набранная команда(включая '/').
PHP:
Возвращает Возвращает 0 когда набранная команда не была найдена; В случае если команда не была найдена ни в моде ни в скрипте, игроку будет выслано сообщение белым цветом 'SERVER: Unknown command'
Пример:
PHP:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/help", true))
{
SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: This is the /help command!");
return 1;
/* Возврат '1' использован чтобы дать серверу понять что команда найдена
и работает исправно. Если вы не поставите эту строчку, то игроку будет
выслано сообщение 'SERVER: Unknown Command.' после выполнения команды.
*/
}
return 0;
/* Возврат '0' использован чтобы дать серверу понять что команда не найдена
и не работает, и указывает серверу что этой команды нет ни в моде ни в скрипте.
*/
}
Вот и все, мб кому-нибудь пригодится. Похожих тем на портале не обнаружил, ну а если такие темы и существую, то простите(
Posts: 61
Threads: 8
Joined: Jan 2013
Reputation:
0
04.07.2014, 01:26
(
Last edited by Timeless; 04/07/2014 at 09:48 AM.
)
I’m gonna show you guys a tutorial on how to turn off or change the «Server Unknown Command» text when using ZCMD
First of all if you’re not sure on which command processor is ZCMD then this is ZCMD https://sampforum.blast.hk/showthread.php?tid=91354 thats the processor i’m going to explain
some usage of ZCMD and this feature can work for all of them
Example of some usage:
PHP Code:
COMMAND:mycommand(playerid, params[]) // or CMD:mycommand(playerid, params[])
{
// Do something
return 1;
}
or
PHP Code:
command(mycommand, playerid, params[]) // or cmd(mycommand, playerid, params[])
{
// Do something
return 1;
}
or
PHP Code:
CMD:mycommand(playerid, params[])
{
//Do something
return 1;
}
normally to change the «Server:Unknown Command» text is using
PHP Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
however thats not needed when using ZCMD this is much faster and easier.
To change the message we have to use a callback called
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
we will add these lines to our callback
PHP Code:
if (!success)
{
//----- your invalid command text to show would go here
}
so now it would look like this
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if (!success)
{
/<---- your invalid command text to show would go here
}
return 0;
}
now we add our invalid command text to the callback
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if (!success)
{
SendClientMessage(playerid,COLOR_RED,"Hey you enterred a wrong command");
}
return 0;
}
now if you don’t to have «Server:Unknown Command» being spammed everytime you succesfully did a command? we simple locate the return value in the callback and instead of having 0 we change it to 1 and voila!
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if (!success)
{
SendClientMessage(playerid,COLOR_RED,"Hey you enterred a wrong command");
}
return 1;
}
and thats it your «Server:Unknown Command» is changed
COMMON ERRORS:
i’ve seen a few statements like this
1.
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return SendClientMessage(playerid,COLOR_RED,"Hey you typed a wrong command"); // you can change the text to whatever you want to suit your server
However this would work but the invalid command text would be spammed everytime you do a command.
2.
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
return SendClientMessage( playerid, COLOR, "Your new unknown command text" );
}
that won’t work as the pawno compiler will give you a warning like this
PHP Code:
warning 209: function "OnPlayerCommandPerformed" should return a value
and if you try correcting this warning by creating a return value like this it would give you an unreachable code warning
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
{
}
return
SendClientMessage( playerid, COLOR, "Your new unknown command text" );
return 0;
}
and if you have something like this it won’t work either
3.
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
{
}
return
SendClientMessage( playerid, COLOR, "Your new unknown command text" );
}
cause your just basically telling the server to spam «your new unknown command text» every time a command is performed
now if you want to get rid of this text completely without displaying any message? we simply go back to the return value and instead of displaying a message we simply change the «0» to a «1»
like this
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return 1;//If player writes command wrong this will still return it as a true and the message will not be displayed
}
so now the no text will be displayed if a player types an invalid command
I hoped you understood the tutorial and i hoped it helped someone out there cause i haven’t found any tutorials with this so i just thought i should create one
Posts: 678
Threads: 16
Joined: Apr 2014
Reputation:
0
Nice
Posts: 61
Threads: 8
Joined: Jan 2013
Reputation:
0
Quote:
Originally Posted by SturtIndia
Nice
Thank you hope it helped
Posts: 584
Threads: 51
Joined: Jan 2014
Reputation:
0
I like to use the cmdtext[] parameter. Format the message in a string, for example:
pawn Code:
format(string, sizeof(string), "Hey! %s isn't a valid command!", cmdtext);
But nice for people who don’t know how to do this
Posts: 605
Threads: 83
Joined: Apr 2014
Reputation:
0
Posts: 168
Threads: 9
Joined: Feb 2013
Reputation:
0
You can do this, too (untested, but compiles):
pawn Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
return ( !success ) ? ( SendClientMessage( playerid, -1, ">> That command doesn't exist! (/cmds)" ), 1 ) : ( 1 );
Anyways, my suggestion is, rename the topic (ask a moderator) to OnPlayerCommandPerformed tutorial, and add everything you know, like:
>> Player must spawn before using any commands
>> Player must be logged in before using any commands
>> etcetera.
Posts: 864
Threads: 57
Joined: Jan 2013
Reputation:
0
@Greentarch : This one looks clearer :
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
return success ? 1 : SendClientMessage(playerid, -1, ">> That command doesn't exist! (/cmds)");
}
The wiki says that «SendClientMessage» returns 1 if the function executes successful. This way, returning 1 just after that would be a bit useless.
@Author : Some parts of your «COMMON ERRORS» are very bad coded.
I take this code as an example :
pawn Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
{}
return SendClientMessage( playerid, COLOR, "Your new unknown command text" );
return 0;
}
It won’t work as a solution ! You’ll even get an error during the compilation !
This one would work :
pawn Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if(!success) return SendClientMessage( playerid, COLOR, "Your new unknown command text" );
return 1;
}
Because as Zeex said :
Quote:
Originally Posted by Zeex
pawn Code:
OnPlayerCommandPerformed(playerid, cmdtext[], success)
And this one gets called after command execution,
here if you do «return 0» the player will see standard «Unknown command» message
. The «success» parameter is equal to value returned by command function returns (if it doesn’t exist success will be 0).
Correct your whole tutorial please.
Posts: 61
Threads: 8
Joined: Jan 2013
Reputation:
0
Quote:
Originally Posted by S4t3K
@Author : Some parts of your «COMMON ERRORS» are very bad coded.
I take this code as an example :
pawn Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
{}
return SendClientMessage( playerid, COLOR, "Your new unknown command text" );
return 0;
}
It won’t work as a solution ! You’ll even get an error during the compilation !
This one would work :
pawn Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if(!success) return SendClientMessage( playerid, COLOR, "Your new unknown command text" );
return 1;
}
Correct your whole tutorial please.
FYI the errors i have there are common mistakes i picked up from other help request threads not my codes. meaning people make common mistakes duh every code i placed there was tested before placing, its my method of coding that works, i share my work.if u test it the way i said it wud turn out exactly as i said in conclusion everything is placed the way it should be.
Posts: 864
Threads: 57
Joined: Jan 2013
Reputation:
0
Well, tell me how this is supposed to work and translate it step-to-step for a newbie like me.
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
{
}
return
SendClientMessage( playerid, COLOR, "Your new unknown command text" );
return 0;
}
Because the way I have understood it is :
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success ) // Entering the callback
{
if( success == 0 ) // If the command doesn't exist
{
// Do...nothing ?
}
return SendClientMessage( playerid, COLOR, "Your new unknown command text" ); // In any case, we have to return a message and to get a "warning : unrecheable code" for the return 0 placed just below.
return 0;
}
Posts: 61
Threads: 8
Joined: Jan 2013
Reputation:
0
Quote:
Originally Posted by S4t3K
Well, tell me how this is supposed to work and translate it step-to-step for a newbie like me.
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
{
}
return
SendClientMessage( playerid, COLOR, "Your new unknown command text" );
return 0;
}
Because the way I have understood it is :
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success ) // Entering the callback
{
if( success == 0 ) // If the command doesn't exist
{
// Do...nothing ?
}
return SendClientMessage( playerid, COLOR, "Your new unknown command text" ); // In any case, we have to return a message and to get a "warning : unrecheable code" for the return 0 placed just below.
return 0;
}
lol thats one the common erors btw not the working code thats if the person try to correct the warning «onplayercommandperformed should have a return vale» i said so in the tutorial because it wud be expected however wrong..»COMMON ERROS», are you trying to say i didn’t explain it good enough?
[Урок] Решение Мод «Unknown» |
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
|
|