Chat Lock Command
#1

Hi, how can I make a command that locks the chat but still lets users use team chat? I have the team chat down, all i need is chatlock and chatlock letting them teamchat
Reply
#2

Try this, untested, but compiles with no warnings/errors;
pawn Код:
new ChatLocked = 0; //Top of your script.

public OnPlayerCommandText(playerid, cmdtext[])
{
        new str[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(!strcmp(cmdtext, "/lockchat", true)) {
        if(ChatLocked == 1) return SendClientMessage(playerid, COLOR, "The chat is already locked!");
    ChatLocked = 1;
    format(str, sizeof(str), "%s has locked the chat.", name);
    SendClientMessageToAll(COLOR, str);
    }
    if(!strcmp(cmdtext, "/unlockchat", true)) {
        if(ChatLocked == 0) return SendClientMessage(playerid, COLOR, "The chat isn't already locked!");
    ChatLocked = 0;
    format(str, sizeof(str), "%s has unlocked the chat.", name);
    SendClientMessageToAll(COLOR, str);
    }
    return 0;
}
public OnPlayerText(playerid, text[])
{
        //Not sure it makes a difference, but put your team chat here.
    if(ChatLocked == 1) {
    SendClientMessage(playerid, COLOR, "The chat is locked.");
    return 0; //return 0, so the chat won't send.
    }
    return 1; //if the above doesn't apply, return 1, send the message.
}
Hope I helped, Aston.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)