05.06.2017, 06:14
I can show similar code with chat mute system. I hope this helps you.
// Add to Secondary Timer
; // here write reaming mute time on base or file
When player connect
Код:
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; }
// Add to Secondary Timer
Код:
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)
When player connect
Код:
new temp[128]; cache_get_row(0, 11, temp, mysql, 12); pData[playerid][aMute] = gettime() + strval(temp);