SA-MP Forums Archive
is there something like TogglePlayerChat? - 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)
+--- Thread: is there something like TogglePlayerChat? (/showthread.php?tid=280826)



is there something like TogglePlayerChat? - dahley5 - 03.09.2011

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!


Re: is there something like TogglePlayerChat? - =WoR=Varth - 03.09.2011

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.");
        //..................



Re: is there something like TogglePlayerChat? - dahley5 - 03.09.2011

oh lol so its just Muted. Thanks anyways


Re: is there something like TogglePlayerChat? - dahley5 - 03.09.2011

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


Re: is there something like TogglePlayerChat? - Wesley221 - 03.09.2011

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


Re: is there something like TogglePlayerChat? - dahley5 - 03.09.2011

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


Re: is there something like TogglePlayerChat? - Macluawn - 03.09.2011

How about describing what the function should do?


Re: is there something like TogglePlayerChat? - =WoR=Varth - 03.09.2011

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

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



Re: is there something like TogglePlayerChat? - dahley5 - 03.09.2011

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.


Re: is there something like TogglePlayerChat? - Wesley221 - 03.09.2011

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