I need help again...
#1

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
Reply
#2

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?
Reply
#3

I didn't used any Checks, because i don't know how to use them Can you explain Checks?
Reply
#4

You need to set a timer.
Try setting this under OnGameModeInit();

Код:
SetTimer("warning", 1000, true);
Reply
#5

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.
Reply
#6

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;
}
?
Reply
#7

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.
Reply
#8

Function you posted.
Reply
#9

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
Reply
#10

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:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)