Checkpoint help
#1

I'm trying to create a script where once the player enters the checkpoint, he'll be able to roam freely and capture turf under certain coordinates(gangzone turf).

But the capture just fails instantly when the player enters, any idea?

Код:
public OnPlayerEnterCheckpoint(playerid)
{
    SendClientMessage(playerid, 0x00FF007A, "Please wait sixty seconds to capture this zone again."); // Telling the player to        wait 30 seconds.
    GangZoneFlashForAll(TURF1,  0xFF80FF76); // Makes the turf Flash Pink ( telling everyone its being taken over )
    SendClientMessageToAll(0xFF80FFFF, "This zone is currently being taken over! Find the capturer and kill him!"); // Sending Message to all players.
    timer = SetTimerEx("SetZone", 60000, false, "i", playerid); // Setting the Timer... ( 30 seconds )
    Checkpoint[playerid] = 1; // Telling the variable that the player is in the checkpoint.
    return 1;
}
Код:
public OnPlayerUpdate(playerid)
{
    if(Checkpoint[playerid] == 1)
        IsPlayerInArea(playerid, 1946.4427, 1908.5669, -1761.9777, -1792.7344);
    return 1;
}

forward IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy);
public IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if (x >= minx || x <= maxx || y >= miny || y <= maxy)
    {
        return 1;
    }
    else
    {
        SendClientMessage(playerid, 0x00FF007A, "You've left the checkpoint, you failed to capture the turf!");
        GangZoneStopFlashForAll(TURF1);
        SendClientMessageToAll(0x00FF007A, "ZONE was not taken over.");
        KillTimer(timer);
        Checkpoint[playerid] = 0;
    }
    return 1;
}
Reply
#2

replace || with && in the "IsPlayerInArea"
Reply
#3

Quote:
Originally Posted by [WSF]ThA_Devil
Посмотреть сообщение
replace || with && in the "IsPlayerInArea"
I just tried that and it still instant-fails upon entering checkpoint.
Reply
#4

Nevermind. I think I found the problem. You've mixed out your minx and maxx in your function.

IsPlayerInArea(playerid, 1946.4427, 1908.5669, -1761.9777, -1792.7344);

change that to

IsPlayerInArea(playerid, 1908.5669, 1946.4427, -1792.7344, -1761.9777);

It is important that minx isn't smaller than maxx, otherwise it will fail.
Reply
#5

Quote:
Originally Posted by [WSF]ThA_Devil
Посмотреть сообщение
Nevermind. I think I found the problem. You've mixed out your minx and maxx in your function.

IsPlayerInArea(playerid, 1946.4427, 1908.5669, -1761.9777, -1792.7344);

change that to

IsPlayerInArea(playerid, 1908.5669, 1946.4427, -1792.7344, -1761.9777);

It is important that minx isn't smaller than maxx, otherwise it will fail.
Ah, stupid mistake by me! Thank you so much though.
Reply
#6

Quote:
Originally Posted by ccodey
Посмотреть сообщение
Ah, stupid mistake by me! Thank you so much though.
Happens to everyone of us..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)