Disable chat for player
#1

Hello guys. I have made an AFK system filterscript.
It has a /goafk and a /back command.
When the player types /goafk, i want to disable the chat for him, so the only thing he can type is /back. If he types anything esle, it sends him a client message.

Hope someone can tell me how to do that. Thank you.
Reply
#2

Add in top of script:

Code:
new afkmsg[MAX_PLAYERS]
In /goafk command add:

Code:
afkmsg[playerid] = 1;
In /back command add:

Code:
afkmsg[playerid] = 0;
In OnPlayerText add:

Code:
if(afkmsg[playerid != 0) return SendClientMessage(playerid,0xFF0000FF,"You must to type /back before talking!");
Not sure, not tested.
Reply
#3

Thank you very much, guys!
Reply
#4

Quote:
Originally Posted by Libra_PL
View Post
Add in top of script:

Code:
new afkmsg[MAX_PLAYERS]
In /goafk command add:

Code:
afkmsg[playerid] = 1;
In /back command add:

Code:
afkmsg[playerid] = 0;
In OnPlayerText add:

Code:
if(afkmsg[playerid != 0) return SendClientMessage(playerid,0xFF0000FF,"You must to type /back before talking!");
Not sure, not tested.
Thank you, but it says "Undefined symbol: MAX_PLAYERS"
Reply
#5

Quote:
Originally Posted by Libra_PL
View Post
Add in top of script:

Code:
new afkmsg[MAX_PLAYERS]
In /goafk command add:

Code:
afkmsg[playerid] = 1;
In /back command add:

Code:
afkmsg[playerid] = 0;
In OnPlayerText add:

Code:
if(afkmsg[playerid != 0) return SendClientMessage(playerid,0xFF0000FF,"You must to type /back before talking!");
Not sure, not tested.
Here is the exact error message:
Quote:

C:\Users\Simon\Desktop\min gamle dm server\filterscripts\afkmode.pwn(12) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Simon\Desktop\samp server\pawno\include\core.inc(12) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\Simon\Desktop\min gamle dm server\filterscripts\afkmode.pwn(111) : error 001: expected token: "]", but found ")"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.

Line 12 is the
pawn Code:
new afkmsg[MAX_PLAYERS]
And line 111 is the
pawn Code:
if(afkmsg[playerid != 0) return SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You can not chat while in AFK mode");
Thank you.

*UPDATE*

I fixed line 111, now the error msg is like this:
Quote:

C:\Users\Simon\Desktop\min gamle dm server\filterscripts\afkmode.pwn(12) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Simon\Desktop\samp server\pawno\include\core.inc(12) : error 009: invalid array size (negative, zero or out of bounds)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

Reply
#6

Sorry, my fail. Not "new afkmsg[MAX_PLAYERS]", but "new afkmsg[MAX_PLAYERS];" - I forgot the ";".
Reply
#7

Quote:
Originally Posted by [HLF]Southclaw
View Post
Well 'undefined symbol' what do you think you should do?
Define it!

#define MAX_PLAYERS x

where x is the number of player slots on your server

Or just put 'x' in the '[cell]'

for the second error, have you been editing the default includes? because core shouldn't give that error
Thank you very much!
I defined it, and there are no errors anymore.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)