SA-MP Forums Archive
Mute CMD - 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: Mute CMD (/showthread.php?tid=247600)



Mute CMD - Alex_Obando - 10.04.2011

When I mute someone he can talks :/


pawn Код:
CMD:mute(playerid, params[])
{

    new string[256];
    if(!IsAdmin(playerid)) return NotAdmin(playerid);
    new muteid, mutetime, reason[256];
    new nameid[20];
    if(sscanf(params, "s[20]I(2)S(No reason)[80]", nameid, mutetime, reason)){
        return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /mute [id] [minutes] [reason]");

    }
    if(ReturnUser(nameid,playerid) == -1)
    {

        return 1;
    } else {

        muteid = ReturnUser(nameid, playerid);
    }
    if(!IsPlayerConnected(muteid)){
        return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected !");
    }
    new file[256];
    file = GetUserPath(muteid,1);


    if(dini_Int(file,"muted")){

        return SendClientMessage(playerid, COLOR_YELLOW, "Player is already muted !");

    }

    mutetime = mutetime * 60;



    format(string, sizeof string, "%s has been muted %i seconds by %s for %s", GetName(muteid), mutetime, GetName(playerid), reason);
    SendClientMessageToAll(COLOR_RED_SHINY, string);

    format(string, sizeof string, "You have been muted %i seconds !", mutetime);
    SendClientMessage(muteid,COLOR_RED_SHINY, string);



    dini_IntSet(file, "mute_t", GetTickCount() + mutetime * 1000);
    dini_IntSet(file, "muted", 1);
    dini_IntSet(file, "mute_s", mutetime * 1000);


    return 1;

}

pawn Код:
public OnPlayerText(playerid, text[])
{
    new file[256];
    file = GetUserPath(playerid);
    LogChat(playerid, text);
    if(dini_Int(file, "muted")) {
        SendClientMessage(playerid, COLOR_YELLOW, "You are muted PM an administrator if you think you were muted incorrectly");
        return 0;
    }
    return 1;

}
*Edit: This is an include.


Re: Mute CMD - willsuckformoney - 10.04.2011

Edit this:
pawn Код:
if(dini_Int(file, "muted"))
With this:

pawn Код:
if(dini_Int(file, "muted") == 1)



Re: Mute CMD - [DJ]Boki - 10.04.2011

pawn Код:
if(dini_Int(file, "muted") == 1)
pawn Код:
CMD:mute(playerid, params[])
{

    new string[256];
    if(!IsAdmin(playerid)) return NotAdmin(playerid);
    new muteid, mutetime, reason[256];
    new nameid[20];
    if(sscanf(params, "s[20]I(2)S(No reason)[80]", nameid, mutetime, reason)){
        return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /mute [id] [minutes] [reason]");

    }
    if(ReturnUser(nameid,playerid) == -1)
    {

        return 1;
    } else {

        muteid = ReturnUser(nameid, playerid);
    }
    if(!IsPlayerConnected(muteid)){
        return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected !");
    }
    new file[256];
    file = GetUserPath(muteid,1);


    if(dini_Int(file,"muted")){

        return SendClientMessage(playerid, COLOR_YELLOW, "Player is already muted !");

    }

    mutetime = mutetime * 60;



    format(string, sizeof string, "%s has been muted %i seconds by %s for %s", GetName(muteid), mutetime, GetName(playerid), reason);
    SendClientMessageToAll(COLOR_RED_SHINY, string);

    format(string, sizeof string, "You have been muted %i seconds !", mutetime);
    SendClientMessage(muteid,COLOR_RED_SHINY, string);



    dini_IntSet(file, "mute_t", GetTickCount() + mutetime * 1000);
    dini_IntSet(file, "muted", 1);
    dini_IntSet(file, "mute_s", mutetime * 1000);


    return 1;

}
pawn Код:
public OnPlayerText(playerid, text[])
{
    new file[256];
    file = GetUserPath(playerid);
    LogChat(playerid, text);
    if(dini_Int(file, "muted")) {
        SendClientMessage(playerid, COLOR_YELLOW, "You are muted PM an administrator if you think you were muted incorrectly");
        return 0;
    }
    return 1;

}



Respuesta: Mute CMD - Alex_Obando - 10.04.2011

Still Not working

pawn Код:
CMD:mute(playerid, params[])
{

    new string[256];
    if(!IsAdmin(playerid)) return NotAdmin(playerid);
    new muteid, mutetime, reason[256];
    new nameid[20];
    if(sscanf(params, "s[20]I(2)S(No reason)[80]", nameid, mutetime, reason)){
        return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /mute [id] [minutes] [reason]");

    }
    if(ReturnUser(nameid,playerid) == -1)
    {

        return 1;
    } else {

        muteid = ReturnUser(nameid, playerid);
    }
    if(!IsPlayerConnected(muteid)){
        return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected !");
    }
    new file[256];
    file = GetUserPath(muteid,1);

    if(dini_Int(file, "muted") == 1){

        return SendClientMessage(playerid, COLOR_YELLOW, "Player is already muted !");

    }

    mutetime = mutetime * 60;



    format(string, sizeof string, "%s has been muted %i seconds by %s for %s", GetName(muteid), mutetime, GetName(playerid), reason);
    SendClientMessageToAll(COLOR_RED_SHINY, string);

    format(string, sizeof string, "You have been muted %i seconds !", mutetime);
    SendClientMessage(muteid,COLOR_RED_SHINY, string);



    dini_IntSet(file, "mute_t", GetTickCount() + mutetime * 1000);
    dini_IntSet(file, "muted", 1);
    dini_IntSet(file, "mute_s", mutetime * 1000);


    return 1;

}


CMD:unmute(playerid, params[])
{


    new string[256];
    if(!IsAdmin(playerid)) return NotAdmin(playerid);
    new muteid;
    new nameid[20];
    if(sscanf(params, "s", nameid)){
        return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /unmute [id] ");

    }
    if(ReturnUser(nameid,playerid) == -1)
    {
        return 1;
    } else {

        muteid = ReturnUser(nameid, playerid);
    }
    if(!IsPlayerConnected(muteid)){
        return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected !");
    }
    new file[256];
    file = GetUserPath(muteid,1);




    if(dini_Int(file, "muted") == 0){

        return SendClientMessage(playerid, COLOR_YELLOW, "Player is not muted !");

    }





    dini_IntSet(file, "mute_t", -1);
    dini_IntSet(file, "muted", 0);
    format(string, sizeof string, "%s has been unmuted by %s.",GetName(muteid),  GetName(playerid) );
    SendClientMessageToAll(COLOR_RED_SHINY, string);

    return 1;

    #pragma unused params


}

forward muteTimer();
public muteTimer()
{



 for(new i; i < MAX_PLAYERS; i++)
 {

    if(!IsPlayerConnected(i)) continue;
    new file[256];
    file = GetUserPath(i,1);
    if(dini_Int(file,"muted") && GetTickCount() > dini_Int(file, "mute_t")) {


        dini_IntSet(file, "mute_t", -1);
        dini_IntSet(file, "muted", 0);

        SendClientMessage(i,0x006600ff, "You have been automatically unmuted.");

    }




 }
}

mute__connect(playerid)
{
    new file[256];
    file = GetUserPath(playerid,1);
 if(dini_Int(file, "muted") == 1)
    {

        dini_IntSet(file, "mute_t", GetTickCount() + dini_Int(file, "mute_s"));
    }

    return 1;


}
pawn Код:
public OnPlayerText(playerid, text[])
{
    new file[256];
    file = GetUserPath(playerid);
    LogChat(playerid, text);
    if(dini_Int(file, "muted")) {
        SendClientMessage(playerid, COLOR_YELLOW, "You are muted PM an administrator if you think you were muted incorrectly");
        return 0;
    }
    return 1;

}



Re: Mute CMD - willsuckformoney - 10.04.2011

Edit that line under OnPlayerText too.


Respuesta: Mute CMD - Alex_Obando - 12.04.2011

Still now working.

pawn Код:
CMD:mute(playerid, params[])
{

    new string[256];
    if(!IsAdmin(playerid)) return NotAdmin(playerid);
    new muteid, mutetime, reason[256];
    new nameid[20];
    if(sscanf(params, "s[20]I(2)S(No reason)[80]", nameid, mutetime, reason)){
        return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /mute [id] [minutes] [reason]");

    }
    if(ReturnUser(nameid,playerid) == -1)
    {

        return 1;
    } else {

        muteid = ReturnUser(nameid, playerid);
    }
    if(!IsPlayerConnected(muteid)){
        return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected !");
    }
    new file[256];
    file = GetUserPath(muteid,1);

    if(dini_Int(file, "muted") == 1){

        return SendClientMessage(playerid, COLOR_YELLOW, "Player is already muted !");

    }

    mutetime = mutetime * 60;



    format(string, sizeof string, "%s has been muted %i seconds by %s for %s", GetName(muteid), mutetime, GetName(playerid), reason);
    SendClientMessageToAll(COLOR_RED_SHINY, string);

    format(string, sizeof string, "You have been muted %i seconds !", mutetime);
    SendClientMessage(muteid,COLOR_RED_SHINY, string);



    dini_IntSet(file, "mute_t", GetTickCount() + mutetime * 1000);
    dini_IntSet(file, "muted", 1);
    dini_IntSet(file, "mute_s", mutetime * 1000);


    return 1;

}


CMD:unmute(playerid, params[])
{


    new string[256];
    if(!IsAdmin(playerid)) return NotAdmin(playerid);
    new muteid;
    new nameid[20];
    if(sscanf(params, "s", nameid)){
        return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /unmute [id] ");

    }
    if(ReturnUser(nameid,playerid) == -1)
    {
        return 1;
    } else {

        muteid = ReturnUser(nameid, playerid);
    }
    if(!IsPlayerConnected(muteid)){
        return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected !");
    }
    new file[256];
    file = GetUserPath(muteid,1);




    if(dini_Int(file, "muted") == 0){

        return SendClientMessage(playerid, COLOR_YELLOW, "Player is not muted !");

    }





    dini_IntSet(file, "mute_t", -1);
    dini_IntSet(file, "muted", 0);
    format(string, sizeof string, "%s has been unmuted by %s.",GetName(muteid),  GetName(playerid) );
    SendClientMessageToAll(COLOR_RED_SHINY, string);

    return 1;

    #pragma unused params


}

forward muteTimer();
public muteTimer()
{



 for(new i; i < MAX_PLAYERS; i++)
 {

    if(!IsPlayerConnected(i)) continue;
    new file[256];
    file = GetUserPath(i,1);
    if(dini_Int(file,"muted") && GetTickCount() > dini_Int(file, "mute_t")) {


        dini_IntSet(file, "mute_t", -1);
        dini_IntSet(file, "muted", 0);

        SendClientMessage(i,0x006600ff, "You have been automatically unmuted.");

    }




 }
}

mute__connect(playerid)
{
    new file[256];
    file = GetUserPath(playerid,1);
 if(dini_Int(file, "muted") == 1)
    {

        dini_IntSet(file, "mute_t", GetTickCount() + dini_Int(file, "mute_s"));
    }

    return 1;


}
pawn Код:
public OnPlayerText(playerid, text[])
{
    new file[256];
    file = GetUserPath(playerid);
    LogChat(playerid, text);
    if(dini_Int(file, "muted") == 1) {
        SendClientMessage(playerid, COLOR_YELLOW, "You are muted PM an administrator if you think you were muted incorrectly");
        return 0;
    }
    return 1;

}
What can I do?


Respuesta: Mute CMD - Alex_Obando - 13.04.2011

Bump


Respuesta: Mute CMD - Alex_Obando - 14.04.2011

Please help!


Re: Mute CMD - Scenario - 14.04.2011

I didn't look much at the code- its unorganized and hard to read; your methods need some work as well. See if the system below works. If it does, we will continue to incorporate extra features into the system until it is working like it should. You will need to show some effort though; I am not going to waste my time helping you if you aren't willing to try and get things to work if they end up not working.

pawn Код:
native sscanf(const data[], const format[], {Float,_}:...);

public OnPlayerText(playerid, text[])
{
    if(GetPVarInt(playerid, "Muted") == 1)
        return 0, SendClientMessage(playerid, 0xFFFFFFAA, "ATTENTION: You have been muted and cannot use the chat!");

    return 1;
}

CMD:mute(playerid, params[])
{
    new id;
    if(!IsPlayerAdmin(playerid)) return false;
    if(sscanf(params, "u", id))
        return SendClientMessage(playerid, 0xFFFFFFAA, "SYNTAX: /mute [playerid]");

    if(GetPVarInt(id, "Muted") == 1)
    {
        SetPVarInt(id, "Muted", 0);
        SendClientMessage(id, 0xFFFFFFAA, "ATTENTION: You have been unmuted by an administrator.");
        SendClientMessage(playerid, 0xFFFFFFAA, "Player unmuted.");
    }
    else if(GetPVarInt(id, "Muted") == 0)
    {
        SetPVarInt(id, "Muted", 1);
        SendClientMessage(id, 0xFFFFFFAA, "ATTENTION: You have been muted by an administrator.");
        SendClientMessage(playerid, 0xFFFFFFAA, "Player muted.");
    }
    else SendClientMessage(playerid, 0xFFFFFFAA, "SYSTEM ERROR, PLEASE CONTACT SCRIPT DEVELOPER.");
    return 1;
}
WARNING: This code has not been tested.


Respuesta: Mute CMD - Alex_Obando - 14.04.2011

Its not working =/