is there something like TogglePlayerChat?
#1

Hey, i'm working on an AFK system. It works great but now i am looking for a function that disables the player chat. If there is any how is it called? thanks!
Reply
#2

https://sampwiki.blast.hk/wiki/OnPlayerText
f.e:
pawn Код:
new bool:Muted[MAX_PLAYERS];

public OnPlayerText(playerid,text[])
{
    if(Muted[playerid])
    {
        SendClientMessage(playerid,color,"You're muted.");
        //..................
Reply
#3

oh lol so its just Muted. Thanks anyways
Reply
#4

Aw.. sorry for double post but.. is there like another way? that works just like GetPlayerPos or GetPlayerHealth. i mean like ToggePlayerChat or something
Reply
#5

pawn Код:
new bool:Muted[MAX_PLAYERS];

public OnPlayerText(playerid,text[])
{
    if(Muted[playerid])
    {
        SendClientMessage(playerid,color,"You're muted.");
        return 0; // This will stop the the gamemode from sending your message to everyone
    }
    return 1;
}
Its just like this, no other function
Reply
#6

Alright but, i don't really understand new bool i never used it :P
Reply
#7

How about describing what the function should do?
Reply
#8

pawn Код:
new bool:Muted[MAX_PLAYERS];

stock TogglePlayerChat(playerid,bool:toggle)
{
    if(0 > toggle || toggle > 1) return 1;
    Muted[playerid] = toggle;
    return 1;
}
Reply
#9

Well, i got this now:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/afk", true))
    {
        new pName[MAX_PLAYER_NAME];
        new string[128];
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
        format(string, sizeof(string), "--) %s Has entered AFK mode.", pName);
        SendClientMessage(playerid,COLOR_YELLOW, "You are now in AFK mode. Use /back to go back!");
        SendClientMessageToAll(COLOR_YELLOW, string);
        TogglePlayerControllable(playerid, 0);
        GetPlayerHealth(playerid, naty[playerid]);
        GetPlayerPos(playerid, x,y,z);
        SetPlayerPos(playerid, 2879.5769,2523.5569,10.8203);
        SetPlayerHealth(playerid, 999999999999999.99);
        return 1;
    }
    if(strcmp(cmdtext, "/back", true) == 0)
    {
        new pName[MAX_PLAYER_NAME];
        new string[128];
        GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
        format(string, sizeof(string), "--) %s Is now back.", pName);
        SendClientMessageToAll(COLOR_YELLOW, string);
        TogglePlayerControllable(playerid, 1);
        SetPlayerHealth(playerid, naty[playerid]);
        SetPlayerPos(playerid, x,y,z);
       
        return 1;
    }
    return 0;
}
it teles the player to an abandoned place, while being invulnerable. It's far away to prevent the player for using it as godmode. it also toggles the movement off. Now i want to add a Function to make the player unable to talk.
Reply
#10

If you use 'boolean(bool)', you create a variable which can be only true, or false. So it cant be like, 2, 3, 4, 5 etc. (true = 1, false = 0). It uses less memory then a normal variable, and since its just needed to switch between 0 & 1, you can make it a bool.
pawn Код:
new bool:Muted[MAX_PLAYERS]; // this will create a boolean, player-bounded(because of the [MAX_PLAYERS])-variable.

public OnPlayerText(playerid,text[])
{
    if(Muted[playerid]) // this will check if you are muted, if you are muted it will do the things down
    {
        SendClientMessage(playerid,color,"You're muted."); // sends the message and says youre muted
        return 0; // This will stop the the gamemode from sending your message to everyone
    }
    return 1; // if youre not muted, it will continue and show what you wanted to send
}
I hope you understand it like this, if you need any further help, just post again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)