SA-MP Forums Archive
Disable chat for player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Disable chat for player (/showthread.php?tid=231454)



Disable chat for player - sim_sima - 25.02.2011

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.


Re: Disable chat for player - randomkid88 - 25.02.2011

Return 0 to stop the text from being sent.


Re: Disable chat for player - sim_sima - 25.02.2011

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


Re: Disable chat for player - Kwarde - 25.02.2011

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


Re: Disable chat for player - sim_sima - 25.02.2011

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


Re: Disable chat for player - sim_sima - 25.02.2011

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


Re: Disable chat for player - Kwarde - 25.02.2011

@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


Re: Disable chat for player - sim_sima - 25.02.2011

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


Re: Disable chat for player - randomkid88 - 25.02.2011

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.


Re: Disable chat for player - Kwarde - 25.02.2011

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