I need help again... -
sekol - 06.09.2010
So, for example if someone enters "Admin restricted area" he have 15 seconds to get out. I need to know how to make my script check if player left the place after warning or not
Код:
public warning()
{
for (new i=0; i<=MAX_PLAYERS; i++)
if(IsPlayerInArea(i, 210.2018, 1786.715, 432.0814, 2090.34))
{
SendClientMessage(i, COLOR_RED, "You'll get punished, dude :D");
Kick(playerid);
}
else if(!IsPlayerInArea(i, 210.2018, 1786.715, 432.0814, 2090.34))
{
SendClientMessage(i, COLOR_GREEN, "Good Boy :D");
}
}
What's wrong with it? Because when i leave the place 5 secs after warning it still kicks me out
Re: I need help again... -
Mauzen - 06.09.2010
How do you include this? Do you have a check, if the player enters the area, and if yes start a timer for "warning" or how is it called?
Re: I need help again... -
sekol - 06.09.2010
I didn't used any Checks, because i don't know how to use them

Can you explain Checks?
Re: I need help again... -
Ironboy500[TW] - 06.09.2010
You need to set a timer.
Try setting this under OnGameModeInit();
Код:
SetTimer("warning", 1000, true);
Re: I need help again... -
[XST]O_x - 06.09.2010
pawn Код:
for (new i=0; i<=MAX_PLAYERS; i++)
You just killed your script with that line,literally.
pawn Код:
for (new i=0; i < MAX_PLAYERS; i++)
Is a correct usage of a loop.
Re: I need help again... -
sekol - 06.09.2010
Hmmm... I'll try to learn it other way...
Код:
if(strcmp("/punishguy", cmdtext, true) == 0)
{
SetTimer("warning", 7000, false);
}
So what should i do here:
Код:
public warning();
{
return 1;
}
?
Re: I need help again... -
Mauzen - 06.09.2010
With checks I mean for example this: On your gamemode start, you start a repeating timer with e.g. 2 seconds delay. This timer loops through all players and checks if a player is in that area (so almost like your warning, but this would be the first check). The difference is, instead of kicking the player directly if he is in the area, you call another function (best via SetTimerEx, you can add the playerid to the parameters then) and can send a warning that he has to leave.
The other function would have 15 seconds delay in your case. It then checks again if the given player is still in the area. If he is, you can kick him now, because he is still in the area after 15 seconds.
Re: I need help again... -
Ironboy500[TW] - 06.09.2010
Function you posted.
Re: I need help again... -
sekol - 06.09.2010
Quote:
Originally Posted by Mauzen
With checks I mean for example this: On your gamemode start, you start a repeating timer with e.g. 2 seconds delay. This timer loops through all players and checks if a player is in that area (so almost like your warning, but this would be the first check). The difference is, instead of kicking the player directly if he is in the area, you call another function (best via SetTimerEx, you can add the playerid to the parameters then) and can send a warning that he has to leave.
The other function would have 15 seconds delay in your case. It then checks again if the given player is still in the area. If he is, you can kick him now, because he is still in the area after 15 seconds.
|
Yeah, now i understand
Re: I need help again... -
[XST]O_x - 06.09.2010
D:
Timer is basically a function called by some time you've set in the SetTimer.
Means,you need to do:
pawn Код:
SetTimer("warning", 7000, true);
And then:
pawn Код:
public warning()
{
for (new i=0; i < MAX_PLAYERS; i++)
if(IsPlayerInArea(i, 210.2018, 1786.715, 432.0814, 2090.34))
{
SendClientMessage(i, COLOR_RED, "You'll get punished, dude :D");
Kick(playerid);
}
else if(!IsPlayerInArea(i, 210.2018, 1786.715, 432.0814, 2090.34))
{
SendClientMessage(i, COLOR_GREEN, "Good Boy :D");
}
}
And the Boolean must be set to true,because you want it to check the area every 7 seconds,repeatedly,no?
EDIT: Until I wrote all this, 3 other posts occurred D: