14.04.2018, 14:59
I want to mute a player for some minutes, which is working fine. But I want him to unmute automatically after that time. That time should be the player game time so I used a timer. But it is not working.
PHP код:
new mutetimer;
PHP код:
public OnGameModeInit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(Player[i][pIsMuted] == 1)
mutetimer = SetTimerEx("DecMuteTime", 1000, 1, "i", i);
}
return 1;
}
PHP код:
public DecMuteTime(playerid)
{
Player[playerid][pMuteTime] -= 1;
if(Player[playerid][pMuteTime] == 0)
{
Player[playerid][pIsMuted] = 0;
SaveAccount(playerid);
}
return 1;
}
PHP код:
CMD:mute(playerid, params[])
{
new targetid, reason[128], time, string[128];
if(Player[playerid][pAdminLevel] >= 1 || IsPlayerAdmin(playerid))
{
if(sscanf(params, "us[128]i", targetid, reason, time))
return SendClientMessage(playerid, COLOR_LIGHTCYAN, "Syntax: /mute [playerid/PartOfName] [reason] [time]");
if(IsPlayerConnected(targetid))
{
if(Player[playerid][pIsMuted] == 1)
return SendClientMessage(playerid, COLOR_NEUTRAL, "The player is already muted!");
Player[targetid][pIsMuted] = 1;
Player[targetid][pMuteTime] = time * 60;
SaveAccount(targetid);
format(string, sizeof(string), "You have muted %s for %d minutes. Reason: %s", GetName(targetid), time, reason);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}