How to save a mutes and kicks
#1

Hello, i've got a mute command what mutes in minutes, but it doesn't save so when a player logs off when muted it unmutes them, could you please help me out with saving the mute so when the player comes back on.
pawn Код:
ACMD:mute(playerid, params[])
{
    if (pInfo[playerid][Adminlevel] < 1) return 0;
    new giveplayerid, reason[128], string[120], minutes, pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME];
    if(sscanf(params, "uds[50]", giveplayerid, minutes, reason)) return SCM(playerid, orange, "--- /mute <ID> <Minutes> <Reason> ---");
    if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
    GetPlayerName(playerid, pname1, sizeof(pname1));
    GetPlayerName(giveplayerid, pname2, sizeof(pname2));
    format(string, sizeof(string), "%s %s has muted %s  for %d minutes: %s", AdminLevelName(playerid), pname1, pname2 , minutes, reason);
    SCMToAll(red, string);
    new calc = minutes*60;
    Mute[giveplayerid] = calc;
    return 1;
}
and I was woundering now that i have a mute command that save mutes in minutes, how would i use the founction from the mute code to make a kick command that kicks by minutes and makes them stay kicked?

pawn Код:
ACMD:kick(playerid, params[])
{
    new reason[128], string[120], pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], giveplayerid;
    if(sscanf(params, "uds[50]", reason, giveplayerid)) return SCM(playerid, orange, "--- /kick <ID> <Reason> ---");
    if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
    GetPlayerName(playerid, pname1, sizeof(pname1));
    GetPlayerName(giveplayerid, pname2, sizeof(pname2));
    format(string, sizeof(string), "%s %s has kicked %s  for %s", AdminLevelName(playerid), pname1, pname2, reason);
    SCMToAll(red, string);
    SetTimerEx("KickTimer", 1000, false, "d", playerid);
    return 1;
}
if you're able to help me that would be great! thank you!
Reply
#2

Do you want the code with Y_ini or Dini ?
Reply
#3

I bet you have an enum with PlayerInfos, if you have it, add these two:

MutedTimes,
KickedTimes,

Then replace this:

Код:
ACMD:mute(playerid, params[])
{
    if (pInfo[playerid][Adminlevel] < 1) return 0;
    new giveplayerid, reason[128], string[120], minutes, pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME];
    if(sscanf(params, "uds[50]", giveplayerid, minutes, reason)) return SCM(playerid, orange, "--- /mute <ID> <Minutes> <Reason> ---");
    if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
    GetPlayerName(playerid, pname1, sizeof(pname1));
    GetPlayerName(giveplayerid, pname2, sizeof(pname2)); 
    format(string, sizeof(string), "%s %s has muted %s  for %d minutes: %s", AdminLevelName(playerid), pname1, pname2 , minutes, reason);
    SCMToAll(red, string);
    new calc = minutes*60;
    Mute[giveplayerid] = calc;
    MutedTimes[giveplayerid] += 1;
    return 1;
}
Then Kick Command:

Код:
ACMD:kick(playerid, params[])
{
    new reason[128], string[120], pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], giveplayerid;
    if(sscanf(params, "uds[50]", reason, giveplayerid)) return SCM(playerid, orange, "--- /kick <ID> <Reason> ---");
    if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
    GetPlayerName(playerid, pname1, sizeof(pname1));
    GetPlayerName(giveplayerid, pname2, sizeof(pname2));
    format(string, sizeof(string), "%s %s has kicked %s  for %s", AdminLevelName(playerid), pname1, pname2, reason);
    SCMToAll(red, string);
    SetTimerEx("KickTimer", 1000, false, "d", playerid);
    KickedTimes[giveplayerid] +=1;
    return 1;
}
Then on public OnPlayerDisconnect add:

dini_IntSet(file, MutedTimes, MutedTimes[playerid]);

or something like that if you do not use dini.
Reply
#4

I use Y_ini, and could you explain it, i don't like copying, i like to know how to do it if i ever need to do something like this in the future
Reply
#5

ok, well, first, make sure you have a Mute variable in your player's info enum:
pawn Код:
enum INFO
{
    Muted, // example
}
new pInfo[MAX_PLAYERS][INFO];
now, let's go to the mute command:
pawn Код:
ACMD:mute(playerid, params[])
{
    if (pInfo[playerid][Adminlevel] < 1) return 0;
    new giveplayerid, reason[128], string[120], minutes, pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME];
    if(sscanf(params, "uds[50]", giveplayerid, minutes, reason)) return SCM(playerid, orange, "--- /mute <ID> <Minutes> <Reason> ---");
    if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
    GetPlayerName(playerid, pname1, sizeof(pname1));
    GetPlayerName(giveplayerid, pname2, sizeof(pname2));
    format(string, sizeof(string), "%s %s has muted %s  for %d minutes: %s", AdminLevelName(playerid), pname1, pname2 , minutes, reason);
    SCMToAll(red, string);
    new calc = minutes*60;
    Mute[giveplayerid] = calc;
    pInfo[playerid][Muted] = 1; // this variable, we'll save it's value later, at OnPlayerDisconnect, put it in the command here.
    return 1;
}
now, let's go to onplayerdisconnect callback:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
     new INI:File = INI_Open(/* Path of your save file , example: "Users/%s.ini" */);
     INI_SetTag(File, "Whatever");
     INI_WriteInt(File, "Muted", pInfo[playerid][Muted]);
     INI_Close(File);
     return 1;
}
This will save variable's value into player's INI file.
make sure you have this in your register command:
pawn Код:
INI_WriteInt(File, "Muted", 0);
and on your loading player's information callback:
pawn Код:
INI_Int("Muted", pInfo[playerid][Muted]);
and last:
pawn Код:
public OnPlayerConnect(playerid)
{
    if(pInfo[playerid][Muted] == 1)
    {
         SendClientMessage(playerid, -1, "You were muted! , you are kicked for avoiding the muted.");
         SetTimerEx("KickTimer", 1000, false, "d", playerid);
    }
    return 1;
}
Reply
#6

pawn Код:
public OnPlayerConnect(playerid)
{
    if(pInfo[playerid][Muted] == 1)
    {
         SendClientMessage(playerid, -1, "You were muted! , you are kicked for avoiding the muted.");
         SetTimerEx("KickTimer", 1000, false, "d", playerid);
    }
    return 1;
}
Are you sure about this code ?
Well if he going to put this code he can use it instead of ban command.
If the player muted and he tried to connect everytime the server will kick him.

Try to understand the code before you post it.
And i suggest to make it like
Save the mintues of the mutes and if the player evaded it the mintues of the mutes will be automatically save at the player .ini file and when the player spawn we can make it like.
pawn Код:
if(pInfo[playerid][Muted] == 1)
    {
         SendClientMessage(playerid, -1, "You're muted ask an administrator to unmute you via /ask");
        Mute[giveplayerid] = calc;
    }
Reply
#7

I will test it, but how would i put it so when he comes back on, he will get the muted time again, from where he logged off, like say he has 7 minute mute, he logs off, logs on and has 7 minute mute still, how would i do it?

EDIT: just seen the post above, i will see
Reply
#8

Damnit, i can not test, my computer doesn't save my files(Nothing about my scripts) and don't have a hoster, so can't test it! that this computer
Reply
#9

Quote:
Originally Posted by MoHaNeD14
Посмотреть сообщение
pawn Код:
public OnPlayerConnect(playerid)
{
    if(pInfo[playerid][Muted] == 1)
    {
         SendClientMessage(playerid, -1, "You were muted! , you are kicked for avoiding the muted.");
         SetTimerEx("KickTimer", 1000, false, "d", playerid);
    }
    return 1;
}
Are you sure about this code ?
Well if he going to put this code he can use it instead of ban command.
If the player muted and he tried to connect everytime the server will kick him.

Try to understand the code before you post it.
And i suggest to make it like
Save the mintues of the mutes and if the player evaded it the mintues of the mutes will be automatically save at the player .ini file and when the player spawn we can make it like.
pawn Код:
if(pInfo[playerid][Muted] == 1)
    {
         SendClientMessage(playerid, -1, "You're muted ask an administrator to unmute you via /ask");
        Mute[giveplayerid] = calc;
    }
well, I know what I am posting, actually, he didn't mention that he wanted that, He just wanted to know how to save player mute variable value, only.
Reply
#10

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
well, I know what I am posting, actually, he didn't mention that he wanted that, He just wanted to know how to save player mute variable value, only.
pawn Код:
public OnPlayerConnect(playerid)
{
    if(pInfo[playerid][Muted] == 1)
    {
         SendClientMessage(playerid, -1, "You were muted! , you are kicked for avoiding the muted.");
[B]         SetTimerEx("KickTimer", 1000, false, "d", playerid);
[/B]    }
    return 1;
}
You don't understand this code.
If the admin muted me and i evaded and i re connected i will be kicked and this will happen everytime i join the server
he said we want to save the mutes so the player will not evade and if he re connected he will be muted and created a code means if the player are muted and he connected to the server he will be kicked.
You also can use this codes to make a ban system using Y_ini
My point is instead of save the mutes by mintues you can add a small punishment like player will be muted till the admin unmute him and he can request the unmute when the admin connect to the server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)