Mute CMD
#1

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.
Reply
#2

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

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

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;

}
Reply
#4

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;

}
Reply
#5

Edit that line under OnPlayerText too.
Reply
#6

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?
Reply
#7

Bump
Reply
#8

Please help!
Reply
#9

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.
Reply
#10

Its not working =/

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)