CMD:jail(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid,0xFFFFFFFF,""); new string[512], reason[256], targetid, time; if(sscanf(params,"uis[50]", targetid , time, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, ""); if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,0xFFFFFFFF,""); if(PlayerInfo[playerid][pAdmin] < 6 && PlayerInfo[targetid][pAdmin] == 6) return SendClientMessage(playerid,0xFFFFFFFF,""); format(string, sizeof(string), "",GetName(playerid), GetName(targetid), time); SendClientMessageToAll(0xCC000022, string); format(string, sizeof(string), "", reason); SendClientMessageToAll(0xCC000022, string); SetPlayerInterior(targetid, 6); SetPlayerPos(targetid,264.1800,77.5989,1001.0391); PlayerInfo[targetid][pJailed] = 1; PlayerInfo[targetid][pJailedTime] = time*1000; UnJailTimer[targetid] = SetTimerEx("UnJailPlayer",time*1000,0,"i",targetid); JailTime[playerid] = SetTimerEx("UpdateJailTime",time*1000,0,"d",targetid); return 1; }
forward UnJailPlayer(playerid); public UnJailPlayer(playerid) { KillTimer(UnJailTimer[playerid]); SetPlayerInterior(playerid, 0); SetPlayerPos(playerid,1552.5085,-1675.7572,16.1953); GameTextForPlayer(playerid, "~w~BlahBlah~r~!", 3000, 6); PlayerInfo[playerid][pJailed] = 0; PlayerInfo[playerid][pJailedTime] = 0; return 1; }
PlayerInfo[playerid][pJailedTime]--; new UnjailTime[20]; format(UnjailTime,sizeof(UnjailTime),"~r~%d",PlayerInfo[playerid][pJailedTime]); GameTextForPlayer(playerid,UnjailTime,1000,1);
CMD:jail(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid,0xFFFFFFFF,"");
new targetid, time, reason[256];
if(sscanf(params,"uis[50]", targetid, time, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,0xFFFFFFFF,"");
if(PlayerInfo[playerid][pAdmin] < 6 && PlayerInfo[targetid][pAdmin] == 6) return SendClientMessage(playerid,0xFFFFFFFF,"");
new string[128];
format(string, sizeof(string), "",GetName(playerid), GetName(targetid), time);
SendClientMessageToAll(0xCC000022, string);
format(string, sizeof(string), "", reason);
SendClientMessageToAll(0xCC000022, string);
SetPlayerInterior(targetid, 6);
SetPlayerPos(targetid,264.1800,77.5989,1001.0391);
PlayerInfo[targetid][pJailed] = 1;
PlayerInfo[targetid][pJailedTime] = time + 1;
KillTimer(JailTime[targetid]);
JailTime[targetid] = SetTimerEx("UpdateJailTime",1000,true,"d",targetid);
return 1;
}
forward UpdateJailTime(playerid);
public UpdateJailTime(playerid)
{
if(!IsPlayerConnected(playerid))
{
KillTimer(JailTime[playerid]);
return 0;
}
if(--PlayerInfo[playerid][pJailedTime] < 1)
{
KillTimer(JailTime[playerid]);
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid,1552.5085,-1675.7572,16.1953);
GameTextForPlayer(playerid, "~w~BlahBlah~r~!", 3000, 6);
PlayerInfo[playerid][pJailed] = 0;
PlayerInfo[playerid][pJailedTime] = 0;
return 1;
}
new str[20];
format(str,sizeof(str),"~r~%d",PlayerInfo[playerid][pJailedTime]);
GameTextForPlayer(playerid,str,1200,1);
return 0;
}
if(PlayerInfo[playerid][pJailed] == 1) { KillTimer(JailTime[playerid]); JailTime[playerid] = SetTimerEx("UpdateJailTime",1000,true,"d",playerid); }
public _JailTimer(playerid)
{
// subtract jail time --
if(JailTime[playerid] == 0)
{
// release the player
KillTimer(JailTimer[playerid]);
}
return 1;
}
The only one problem is that it does not countdown by 1 sec but by 7 sec so...
If i jail me for example 666 seconds, the game text is like: 666 659 652 645 ... |
Impossible :> all time 7 sec ? something is wrong in your code somewhere also you need save jailtime into player account if he left
|
CMD:amute(playerid,params[]) { new banid, banname[MAX_PLAYER_NAME],adminName[MAX_PLAYER_NAME], string[129], reason[128], mtime; if(!pData[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED,"ERROR!"); if(sscanf(params,"dds[128]",banid, mtime, reason)) return SendClientMessage(playerid,-1,"{80BCFF}use:{FFFFFF} /mute <id> <time> <reason>"); if(!IsPlayerConnected(banid)) return SendClientMessage(playerid,COLOR_RED,"Wrong ID."); pData[banid][aMute] = gettime()+mtime*60; //write unixtime + mute time * 60 return 1; }
foreach (new i : Player) { if(pData[i][aMute]) { if(gettime() >= pData[i][aMute]) // if unixtime now > or = mute time, unmute player. pData[i][aMute] = 0; } }
public OnPlayerDisconnect(playerid, reason) { if(pData[playerid][aMute] > gettime() && pData[playerid][aMute]) // if player have mute and time mute > or = mute time pData[playerid][aMute] = pData[playerid][aMute] - gettime(); // reaming unix time - unix time else pData[playerid][aMute] = 0; // else set mute time 0 mysql_format(mysql, query, sizeof(query),"UPDATE `login` SET `murders` = '%d', `death` = '%d', `reputation` = '%d', `description` = '%s', `mute` = '%d', `warn` = '%d' WHERE id='%d'", pData[playerid][pMurders], pData[playerid][pDeath], pData[playerid][pReputation], SQL_ReturnEscaped(pData[playerid][pDescription]), pData[playerid][aMute], pData[playerid][warn], pData[playerid][pID]); mysql_tquery (mysql, query)
new temp[128]; cache_get_row(0, 11, temp, mysql, 12); pData[playerid][aMute] = gettime() + strval(temp);