SA-MP Forums Archive
Why isn't this working.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why isn't this working.. (/showthread.php?tid=264328)



Why isn't this working.. - Jay. - 25.06.2011

ok this is really annoying me

I have made a timer that will check if a player is in a area and if he is , kill him..... but it isn't working!!
It's so annoying. oh yeah and I used a tutorial


I tried , i tested. now i just don't know. so i decided to post here.

timer:

pawn Код:
SetTimer("Checks",3000,1);
function:

pawn Код:
forward Checks();
public Checks()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i)) continue;
        if(IsPlayerInArea(i,-2931.596, -2981.811, 219.2902, -123.9217))
        {
           
            SetPlayerHealth(i,0);
        }
    }
    return 1;
}
Please help , thanks!


Re: Why isn't this working.. - Willow - 25.06.2011

Maybe you use wrong coordinates?


Re: Why isn't this working.. - Wesley221 - 25.06.2011

Edit: Ignore me,


Re: Why isn't this working.. - sleepysnowflake - 25.06.2011

pawn Код:
forward Checks();
public Checks()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
{
        if(IsPlayerInArea(i,-2931.596, -2981.811, 219.2902, -123.9217))
        {
           
            SetPlayerHealth(i,0);
 
}
   }
    }
    return 1;
}
The identitation sucks ... Hope it helped


Re: Why isn't this working.. - Jay. - 25.06.2011

Quote:
Originally Posted by Berlovan
Посмотреть сообщение
pawn Код:
forward Checks();
public Checks()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
{
        if(IsPlayerInArea(i,-2931.596, -2981.811, 219.2902, -123.9217))
        {
           
            SetPlayerHealth(i,0);
 
}
   }
    }
    return 1;
}
The identitation sucks ... Hope it helped
Didn't work , but thanks


area:

pawn Код:
stock IsPlayerInArea(playerid, Float:min_x, Float:max_x, Float:min_y, Float:max_y)
{
    new Float:pos[3]; //Save his position this this triple-var.
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]); //Save his X in pos[0], his Y in pos[1] and his Z in pos[2].
    if(min_x <= pos[0] && max_x >= pos[0] && min_y <= pos[1] && max_y >= pos[1]) return 1; //Checks if the player is in the area, and if so returns 1.
    return 0; //Else it returns 0.
}
Willow: I'm sure they're right, i can upload a picture if you want.

picture
uploaded:

http://imageshack.us/photo/my-images/41/useryh.png/


Re: Why isn't this working.. - Jay. - 25.06.2011

I also checked to see if my other timers were working and they are fine.
Oh and yeah , picture uploaded is above


Re: Why isn't this working.. - gimini - 25.06.2011

pawn Код:
forward Checks();
public Checks()
{
    print("DEBUG 1");
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i)) continue;
        if(IsPlayerInArea(i,-2931.596, -2981.811, 219.2902, -123.9217))
        {
            print("DEBUG 2");
            SetPlayerHealth(i,0);
        }
    }
    return 1;
}
Try this and check if it works


Re: Why isn't this working.. - Jay. - 25.06.2011

Quote:
Originally Posted by gimini
Посмотреть сообщение
pawn Код:
forward Checks();
public Checks()
{
    print("DEBUG 1");
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i)) continue;
        if(IsPlayerInArea(i,-2931.596, -2981.811, 219.2902, -123.9217))
        {
            print("DEBUG 2");
            SetPlayerHealth(i,0);
        }
    }
    return 1;
}
Try this and check if it works
it spams DEBUG 1 in the console(when in the area)
and it doesn't work

EDIT: Even when im not in the area it spams it.


Re: Why isn't this working.. - gimini - 25.06.2011

If this timer works, then try to replace
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
with this
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
If it still doesn't work, then I have no other ideas..


Re: Why isn't this working.. - MyLife - 25.06.2011

pawn Код:
forward Checks();
public Checks()
{
    print("DEBUG 1");
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInArea(i,-2931.596, -2981.811, 219.2902, -123.9217))
        {
            print("DEBUG 2");
            SetPlayerHealth(i,0);
        }
    }
    return 1;
}
pawn Код:
if(!IsPlayerConnected(i)) continue;
Tip for " countinue "