SA-MP Forums Archive
Is that timer for the player only? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Is that timer for the player only? (/showthread.php?tid=409203)



Is that timer for the player only? - Saw® - 20.01.2013

Resolved.


Re: Is that timer for the player only? - Saw® - 20.01.2013

I forgot this is the timer Stuffs :
pawn Код:
forward Silencer();
public Silencer()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        SecondesMute[i] ++;
        if(SecondesMute[i] == 600)
        {
            SendClientMessage(i,COLOR_WHITE,"10min of mute is done , you can speak.");
            Mute[i]=0;
            SecondesMute[i]=0;
            KillTimer(TuerSilencer);
        }

    }
    return 1;
}



Re: Is that timer for the player only? - LarzI - 20.01.2013

pawn Код:
if(!params[0]||!(pos=chrfind(' ',params))||!params[pos])
Look up sscanf. That will make that line much tidier.

Quote:

I want it only for the ID i wrote.

Use SetTimerEx, and make the TuerSilencer variable an array for each player (new TuerSilencer[ MAX_PLAYERS ]:
pawn Код:
TuerSilencer[ playerid ] = SetTimerEx( "Silencer", "1000", true, "i", playerid);
Then change the timer function from
pawn Код:
forward Silencer();
public Silencer()
To:
pawn Код:
forward Silencer(playerid);
public Silencer(playerid)
Then remember to remove the loop and use playerid instead of 'i' in your timer function.


Re: Is that timer for the player only? - Saw® - 20.01.2013

So , the first code I gave , the timer will start for everyone ?

well I did what you said and get that:
Код:
C:\Documents and Settings\PC\Bureau\DATABASE DE ALAE\SND\Votre Destin Role Play\gamemodes\VDRP.pwn(424) : warning 217: loose indentation
C:\Documents and Settings\PC\Bureau\DATABASE DE ALAE\SND\Votre Destin Role Play\gamemodes\VDRP.pwn(557) : warning 217: loose indentation
C:\Documents and Settings\PC\Bureau\DATABASE DE ALAE\SND\Votre Destin Role Play\gamemodes\VDRP.pwn(753) : warning 217: loose indentation
C:\Documents and Settings\PC\Bureau\DATABASE DE ALAE\SND\Votre Destin Role Play\gamemodes\VDRP.pwn(875) : warning 217: loose indentation
C:\Documents and Settings\PC\Bureau\DATABASE DE ALAE\SND\Votre Destin Role Play\gamemodes\VDRP.pwn(1248) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
lines:
1248: TuerSilencer[ playerid ] = SetTimerEx( "Silencer", "1000", "true", "i", playerid);


Re: Is that timer for the player only? - DaRk_RaiN - 20.01.2013

The SetTimerEx will only start for the player.
For the error replace the
pawn Код:
new TuerSilencer;
With
pawn Код:
new TuerSilencer[MAX_PLAYERS];



Re: Is that timer for the player only? - Saw® - 20.01.2013

I have done that , I edited the code look again I have only one error in the line 1248


Re: Is that timer for the player only? - DaRk_RaiN - 20.01.2013

Replace this
pawn Код:
TuerSilencer[ playerid ] = SetTimerEx( "Silencer", "1000", "true", "i", playerid);
With this
pawn Код:
TuerSilencer[ playerid ] = SetTimerEx( "Silencer", 1000, true, "i", playerid);



Re: Is that timer for the player only? - LarzI - 20.01.2013

Quote:
Originally Posted by DaRk_RaiN
Посмотреть сообщение
Replace this
pawn Код:
TuerSilencer[ playerid ] = SetTimerEx( "Silencer", "1000", "true", "i", playerid);
With this
pawn Код:
TuerSilencer[ playerid ] = SetTimerEx( Silencer, "1000", true, "i", playerid);
Ah yes, my bad.


Re: Is that timer for the player only? - Saw® - 20.01.2013

Thank you for trying, but I get this error :
Код:
C:\Documents and Settings\PC\Bureau\DATABASE DE ALAE\SND\Votre Destin Role Play\gamemodes\VDRP.pwn(1248) : error 076: syntax error in the expression, or invalid function call



Re: Is that timer for the player only? - DaRk_RaiN - 20.01.2013

Silly me, i fixed it check it out.