Help with timer
#1

Okay, another question How do I get it so my timer unmutes the target id? because when I mute a player, the timer starts but keeps them muted because when the timer ends, it unmutes me. thanks.
Reply
#2

Use SetTimerEx to pass the targetid.

This forum requires that you wait ... blah blah blah.
Reply
#3

Could you give me an example of how to use it? I'v never used SetTimerEx
Reply
#4

https://sampwiki.blast.hk/wiki/SetTimerEx

There you go.
Reply
#5

Ugh, i'v seen the wiki, plenty of times, I just don't know how I would use it to unmute the targetid instead of playerid.
Reply
#6

Change playerid to targetid..? Show your code.
Reply
#7

PHP код:
public unmutetimer(playerid)
{
    
GetPvarInt(targetid,"Muted");
    
PlayerInfo[targetid][pMuted] = 0;
    
SendClientMessage(playerid,COLOR_GREEN,"You've been unmuted.");
    return 
1;

- Public
PHP код:
CMD:mute(playerid,params[])
{
    new 
time,targetid,str1[128],pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME];
    if(
PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid,COLOR_GRAY,"Error: You're not authorized to use this command!");
    else if(
sscanf(params,"ud",targetid,time)) return SendClientMessage(playerid,COLOR_WHITE,"Format: /mute [PartOfName/ID] [Time(milliseconds)]");
    else if(
targetid==INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_GRAY,"Error: Player is not connected.");
    else
    {
        
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
        
GetPlayerName(targetid,tName,MAX_PLAYER_NAME);
        
format(str1,sizeof(str1),"[Mute] Admin %s has muted %s for %d minutes.",pName,tName,time);
        
SendClientMessageToAll(COLOR_CARROT,str1);
        
SendClientMessage(targetid,COLOR_RED,"You've been muted.");
        
PlayerInfo[targetid][pMuted] = 1;
        
SetTimer("unmutetimer",time*60000,false);
    }
    return 
1;

Reply
#8

pawn Код:
SetTimer("unmutetimer",time*60000,false); // Change this to:
                  SetTimerEx("unmutetimer",time*6000, false, "i", targetid); // It is 6000 not 60000, okay ?

//Also:
forward unmutetimer(targetid);
public unmutetimer(targetid) // Your code below.
Reply
#9

Thanks for the code berlovan, will test it, but it is 60000 because 60000=1 minute, and they get muted for the minutes, so /mute id 1(1 minute)
Reply
#10

Oh, okay. Sorry. I thought something else.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)