Disable chat for player
#1

Hello guys. I have made an AFK filterscript.
It works almost perfect.
It has a /goafk command and a /back command.
I want to make the player unable to chat when he types /goafk, and the only thing he can type is /back.
If he types anything else, i want to send him a client message.

I have done the following:

At the top of the script I added:
pawn Code:
new afkmsg[500];
In the /goafk command i added:
pawn Code:
afkmsg[playerid] = 1;
And in the /back command i added:
pawn Code:
afkmsg[playerid] = 0;
And under OnPlayerText i added:
pawn Code:
if(afkmsg[playerid] != 0) return SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You can not chat while in AFK mode. Type /back to chat");
But it works almost fine. When the player chats in AFK mode, it shows the client message, but the chat text still appears.

Hope someone can help me fixing it. Thank you.
Reply
#2

Return 0 to stop the text from being sent.
Reply
#3

Quote:
Originally Posted by randomkid88
View Post
Return 0 to stop the text from being sent.
Thank you. Ill try that
Reply
#4

And don't forget that message.
Change
pawn Code:
if(afkmsg[playerid] != 0) return SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You can not chat while in AFK mode. Type /back to chat");
for
pawn Code:
if(afkmsg[playerid] != 0) return 0, SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You can not chat while in AFK mode. Type /back to chat");
Now it'll return 0 AND the message
Reply
#5

Quote:
Originally Posted by randomkid88
View Post
Return 0 to stop the text from being sent.
Yea, but now i cant chat when im not in afk mode. I want the player to be unable to chat only when in afk mode
Reply
#6

Quote:
Originally Posted by Kwarde
View Post
And don't forget that message.
Change
pawn Code:
if(afkmsg[playerid] != 0) return SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You can not chat while in AFK mode. Type /back to chat");
for
pawn Code:
if(afkmsg[playerid] != 0) return 0, SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You can not chat while in AFK mode. Type /back to chat");
Now it'll return 0 AND the message
Oh, thank you very much
Reply
#7

@sim_sima:
OMG look at my post. I'd (probably) gave the right answer !!!

This forum requires that you wait 60 seconds between posts. Please try again in 9 seconds.

EDIT: Oh you've already seen it xD
We're a bit stuck with the waiting time I guess
Reply
#8

Quote:
Originally Posted by Kwarde
View Post
And don't forget that message.
Change
pawn Code:
if(afkmsg[playerid] != 0) return SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You can not chat while in AFK mode. Type /back to chat");
for
pawn Code:
if(afkmsg[playerid] != 0) return 0, SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You can not chat while in AFK mode. Type /back to chat");
Now it'll return 0 AND the message
Yes, i tryed that, but its still the same
Reply
#9

I'm sorry for not being specific. Kwarde has provided the solution, I meant to return 0 in that section, not for the entire OnPlayerText.
Reply
#10

@sim_sima:
Not working? It should work... Try
'if(afkmsg[playerid] == 1)'
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)