Untitled

 avatar
user_0390871
plain_text
a year ago
1.8 kB
2
Indexable
Never
#define g_SPEED 5.0      // Tốc độ mở cổng

#define gBOT_DOWN2 36.8407, -1523.7463, 0.6
#define gBOT_DOWN1 35.9096, -1536.0658, 0.6
#define gBOT_UP2 36.8407, -1523.7463, 8.0000
#define gBOT_UP1 35.9096, -1536.0658, 8.0000
//new gGateIsOpen = false;
new gGateID = 0;

CMD:traphi(playerid, params[])
{
    if (PlayerInfo[playerid][pCash] <= 3000)
        SendClientMessageEx(playerid, -1, "Bạn không đủ tiền để qua trạm thu phí.");
    else
    {
        PlayerInfo[playerid][pCash] -= 3000;
        gGateID = bot_CreateGate();
        OpenGate(playerid);
        SetTimerEx("CloseGate", 5000, false, "d", playerid);
    }

    return 1;
}

OpenGate(playerid)
{
    //gGateIsOpen = true;
    if (IsPlayerInRangeOfPoint(playerid, 5.0, 42.1201, -1523.3643, 5.1700))
    {
        GateInfo[gGateID][gRange] = 5;
        MoveDynamicObject(GateBOT[1], gBOT_DOWN2, g_SPEED);
        SetTimerEx("CloseGate", 5000, false, "d", playerid, gGateID);
    }
    if (IsPlayerInRangeOfPoint(playerid, 5.0, 30.6361,-1535.6686,4.9736))
    {
        GateInfo[gGateID][gRange] = 5;
        MoveDynamicObject(GateBOT[0], gBOT_DOWN1, g_SPEED);
        SetTimerEx("CloseGate", 5000, false, "d", playerid, gGateID);
    }

    return 1;
}

forward CloseGate(playerid);
public CloseGate(playerid)
{
    //gGateIsOpen = false;
    if (IsPlayerInRangeOfPoint(playerid, 5.0, 42.1201, -1523.3643, 5.1700))
    {
        GateInfo[gGateID][gRange] = 5;
        MoveDynamicObject(GateBOT[1], gBOT_UP2, g_SPEED);
    }
    if (IsPlayerInRangeOfPoint(playerid, 5.0, 42.1201, -1523.3643, 5.1700))
    {
        GateInfo[gGateID][gRange] = 5;
        MoveDynamicObject(GateBOT[0], gBOT_UP1, g_SPEED);
    }
    

    return 1;
}

bot_CreateGate()
{
    gGateID++;
    return gGateID;
}