SetTimerEx left time problem.
#1

i tried making a /mute command like this:
CMD:mute(playerid, params[])
{
new string[128];
new pname[MAX_PLAYER_NAME];
new name[MAX_PLAYER_NAME];
if(sscanf(params, "ui",muteID, mutlaikas)) return SendClientMessage(playerid, PILKA, "Teisingas Naudojimas: /mute [ZaidejoVardas/ID] [Laikas] !");
if(!IsPlayerConnected(muteID)) return SendClientMessage(playerid, PILKA, "Zaidejas Neegzistuoja !");
if(Stats[muteID][mute] == 1) return SendClientMessage(playerid,PILKA, "Asmuo Jau Yra Uztildytas");
mutetimer[muteID] = SetTimerEx("BMute", mutlaikas[muteID]*1000, false, "i", muteID);
GetPlayerName(muteID, name, sizeof(name));
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "Just Uztildete Zaideja %s %i Sekundziu !", name, mutlaikas[playerid]);
SendClientMessage(playerid, PILKA, string);
format(string, sizeof(string), "Jus Buvote Uztilditas Administratorio %s %i Sekundziu !", pname, mutlaikas[playerid]);
SendClientMessage(muteID, PILKA, string);
Stats[muteID][mute] = 1;
return 1;
}
and i made this
public OnPlayerText(playerid, text[])
{
if(Stats[playerid][mute] == 1)
{
new string[200];
format(string, sizeof(string), "Jums Liko Dar %i Sekundziu Uztildimo!", mutetimer[playerid]);
SendClientMessage(playerid, 0xFFFFFFFFF, string);
return 0;
}
return 1;
}
it all compiles great but when i mute someone and that someone types something it shows that it was muted 2 seconds instead of the value of the mute time left.
can someone help?
Reply
#2

pawn Код:
CMD:mute(playerid, params[])
{
new string[128];
new pname[MAX_PLAYER_NAME];
new name[MAX_PLAYER_NAME];
if(sscanf(params, "ui",muteID, mutlaikas)) return SendClientMessage(playerid, PILKA, "Teisingas Naudojimas: /mute [ZaidejoVardas/ID] [Laikas] !");
if(!IsPlayerConnected(muteID)) return SendClientMessage(playerid, PILKA, "Zaidejas Neegzistuoja !");
if(Stats[muteID][mute] == 1) return SendClientMessage(playerid,PILKA, "Asmuo Jau Yra Uztildytas");
mutetimer[muteID] = SetTimerEx("BMute", mutlaikas[muteID]*1000, false, "i", muteID);
GetPlayerName(muteID, name, sizeof(name));
GetPlayerName(playerid, pname, sizeof(pname));
new time = mutlaikas[playerid]*1000;
format(string, sizeof(string), "Just Uztildete Zaideja %s %i Sekundziu !", name, time);
SendClientMessage(playerid, PILKA, string);
format(string, sizeof(string), "Jus Buvote Uztilditas Administratorio %s %i Sekundziu !", pname, time);
SendClientMessage(muteID, PILKA, string);
Stats[muteID][mute] = 1;
return 1;
}
and i made this
public OnPlayerText(playerid, text[])
{
if(Stats[playerid][mute] == 1)
{
new string[200];
format(string, sizeof(string), "Jums Liko Dar %i Sekundziu Uztildimo!", mutetimer[playerid]);
SendClientMessage(playerid, 0xFFFFFFFFF, string);
return 0;
}
return 1;
}
Replace ur cmd with this
Reply
#3

pawn Код:
format(string, sizeof(string), "Jums Liko Dar %i Sekundziu Uztildimo!", mutetimer[playerid]);
It will return the timer ID, not the time has left until the player gets unmuted.

By the way, you've used mutlaikas as integer without any index in the sscanf line but later you use playerid as index: mutlaikas[playerid]
Reply
#4

how can i make it return the time left in the timer ?
Reply
#5

For the love of god, please learn to indent.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)