how to ?
#1

How i can make a command that have 2 things to do

if i type /chatoff it will give chat off i mean nobody can't write in chat... and if i type /chatoff it will put the chat ON again...

i know i can make 2 commands /chatoff and /chaton or something like this but i just need informations how to this what i ask for =)

ty for any help
Reply
#2


pawn Код:
//Above Ongamemodeinit:
new ChatDisabled;


public OnGameModeInit()
{
ChatDisabled = 0; //Chat enabled
return 1;
}

            else if(strcmp(cmd, "/chat", true) == 0) {
        if (ChatDisabled == 0) {
        ChatDisabled = 1; //Chat off
        return 1;
        }
        if (ChatDisabled == 1) {
        ChatDisabled = 0; //Chat on
        return 1;
        }
        return 1;
        }

public OnPlayerText(playerid, text[])
{
    if(ChatDisabled == 1)
{
   SendClientMessage(playerid, COLOR_YOURCOLOR, "The chat is currently disabled by an admin.");
   return 0;
}
return 1;
}
Try this
Reply
#3

Quote:
Originally Posted by Jakku
pawn Код:
//Above Ongamemodeinit:
new ChatDisabled;


public OnGameModeInit()
{
ChatDisabled = 0; //Chat enabled
return 1;
}

            else if(strcmp(cmd, "/chat", true) == 0) {
        if (ChatDisabled == 0) {
        ChatDisabled = 1; //Chat off
        return 1;
        }
        if (ChatDisabled == 1) {
        ChatDisabled = 0; //Chat on
        return 1;
        }
        return 1;
        }

public OnPlayerText(playerid, text[])
{
    if(ChatDisabled == 1)
{
   SendClientMessage(playerid, COLOR_YOURCOLOR, "The chat is currently disabled by an admin.");
   return 0;
}
return 1;
}
Try this
You forgot a few things there

Here's my take:

You will need a placeholder for a boolean assignment for each player, in an array:

Код:
new bool:ChatToggle
Now when the player types say for example: /tchat

Under public OnPlayerCommandText(playerid, cmdtext[])
Код:
if(strcmp(cmdtext, /tchat, true) == 0)
{
  if(ChatToggle == false)
  {
    ChatToggle = true;
  {
  if(ChatToggle == true)
  {
    ChatToggle = false;
  {
}
Under OnPlayerText(playerid, text[])
Код:
{
  if(ChatToggle == true)
  {
    return 0;
  }
  if(ChatToggle == false)
  {
    return 1;
  }
}
Don't forget to remove the return 1; under OnPlayerText first, or this won't work
Reply
#4

ok i will try
Reply
#5

Quote:
Originally Posted by Zinglish
Quote:
Originally Posted by Jakku
pawn Код:
//Above Ongamemodeinit:
new ChatDisabled;


public OnGameModeInit()
{
ChatDisabled = 0; //Chat enabled
return 1;
}

            else if(strcmp(cmd, "/chat", true) == 0) {
        if (ChatDisabled == 0) {
        ChatDisabled = 1; //Chat off
        return 1;
        }
        if (ChatDisabled == 1) {
        ChatDisabled = 0; //Chat on
        return 1;
        }
        return 1;
        }

public OnPlayerText(playerid, text[])
{
    if(ChatDisabled == 1)
{
   SendClientMessage(playerid, COLOR_YOURCOLOR, "The chat is currently disabled by an admin.");
   return 0;
}
return 1;
}
Try this
You forgot a few things there

Here's my take:

You will need a placeholder for a boolean assignment for each player, in an array:

Код:
new bool:ChatToggle
Now when the player types say for example: /tchat

Under public OnPlayerCommandText(playerid, cmdtext[])
Код:
if(strcmp(cmdtext, /tchat, true) == 0)
{
  if(ChatToggle == false)
  {
    ChatToggle = true;
  {
  if(ChatToggle == true)
  {
    ChatToggle = false;
  {
}
Under OnPlayerText(playerid, text[])
Код:
{
  if(ChatToggle == true)
  {
    return 0;
  }
  if(ChatToggle == false)
  {
    return 1;
  }
}
Don't forget to remove the return 1; under OnPlayerText first, or this won't work
You won't need. My version works perfectly
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)