First time, second time, third time, etc -
knackworst - 24.09.2011
Hi, it's me again
I know that I post alot of threads here in the weekend, its cuz I only play SAMP in the weekend...
ok basically I have a question if something is possible, I think it easy, but I think it's very hard too!
ok, so what I need is something wich gets called every 5 seconds, and then in the public there are 5 things, wich should be done once per time the public gets called...
E.x:
pawn Код:
public fivesectimer(stuff here)
{
SendClientMessage(playerid,COLOR_RED,"blahblah");
SetPlayerHealth(playerid, 0);
GameText(stuff here);
Kick(playerid);
ban(playerid);
}
ok, this stuff makes no sence, but its just to give a clear exampl
so what it should do is the following:
after 5 seconds you get the clientmessage
after another 5 seconds the playerhealth thing
after another 5 secs the Gametext
after anhother 5 secs, kick
after another 5 secs, ban
then, it should go to the clientmessage again...
I know it can be scripted by creating 5 different timers, but it is extremely stuid i guess since it's possible with another way, but I don't know how...
rep++ for helper
AW: First time, second time, third time, etc -
Drebin - 24.09.2011
Create an integer inside the function that adds +5 ( integer = integer + 5; ) every time the function is called (every 5 seconds)
Then, make an if query inside the function:
pawn Код:
if(integer == 5)
{
SendClientMessage(playerid,COLOR_RED,"blahblah");
}
else if(integer == 10)
{
SetPlayerHealth(playerid, 0);
}
[...]
Re: First time, second time, third time, etc -
sleepysnowflake - 24.09.2011
For a particular player or for all of them ? Answer me this and I will make it :3
Re: First time, second time, third time, etc -
knackworst - 24.09.2011
For one player, I need it for making a conversation look alike in td
but I think that the other guy's method will work too, it's a bit like a timer, now I see it
Re: First time, second time, third time, etc -
sleepysnowflake - 24.09.2011
pawn Код:
// Top :3
forward SumTimer(playerid);
new TimeValue = 0;
// Sumwhere.
SetTimerEx("SumTimer",5000,1,"i",playerid);
//Sumwhere else :3
public SumTimer(playerid)
{
switch(TimeValue)
{
case 0: SendClientMessage(playerid,16,"blahblah");
case 1: SetPlayerHealth(playerid, 0);
case 2: GameTextForPlayer(playerid,"b",5000,3);
case 3: Kick(playerid);
case 4: Ban(playerid);
}
TimeValue++;
return 1;
}
Not tested. Test it, report bugs.
Re: First time, second time, third time, etc -
knackworst - 24.09.2011
yay, it works, thanks both!
rep++
Re: First time, second time, third time, etc -
sleepysnowflake - 24.09.2011
Yay!
This forum requires that you wait 120 seconds between posts. Please try again in 74 seconds. Oh noe!
Re: First time, second time, third time, etc -
IstuntmanI - 24.09.2011
Ban after a kick ? Doesn't work, the player is disconnected after kick.
If you use /command ( with this timer ) on 2+ players, this thing will be bugged, You must to add [playerid] thing to TimeValue.
Re: First time, second time, third time, etc -
SiJ - 24.09.2011
Quote:
Originally Posted by Berlovan
pawn Код:
// Top :3 forward SumTimer(playerid); new TimeValue = 0;
// Sumwhere.
SetTimerEx("SumTimer",5000,1,"i",playerid);
//Sumwhere else :3
public SumTimer(playerid) { switch(TimeValue) { case 0: SendClientMessage(playerid,16,"blahblah"); case 1: SetPlayerHealth(playerid, 0); case 2: GameTextForPlayer(playerid,"b",5000,3); case 3: Kick(playerid); case 4: Ban(playerid); } TimeValue++; return 1; }
Not tested. Test it, report bugs.
|
You forgot to use KillTimer somewhere.. Like this:
pawn Код:
// Top :3
forward SumTimer(playerid);
new TimeValue[MAX_PLAYERS] = 0;
new sTimer[MAX_PLAYERS];
// Sumwhere.
sTimer[playerid] = SetTimerEx("SumTimer",5000,1,"i",playerid);
//Sumwhere else :3
public SumTimer(playerid)
{
if(!IsPlayerConnected(playerid))
{
KillTimer(sTimer[playerid]);
TimeValue[playerid] = 0;
return 1;
}
switch(TimeValue[playerid])
{
case 0: SendClientMessage(playerid,16,"blahblah");
case 1: SetPlayerHealth(playerid, 0);
case 2: GameTextForPlayer(playerid,"b",5000,3);
case 3: Kick(playerid);
case 4: Ban(playerid);
case 5: KillTimer(sTimer[playerid]); TimeValue[playerid] = 0;
}
TimeValue[playerid]++;
return 1;
}
Re: First time, second time, third time, etc -
sleepysnowflake - 24.09.2011
Ya right .... AHH!!, I kinda need sleep.