cmd:cuttree doesnt work, if player is inrange of a tree
#2

Why in CreateTree is treed but in TreeUp is treeid?

pawn Код:
GetClosestTreeForPlayer(playerid)
{

    for(new i = 0; i < treeid; i++)
        if(IsPlayerInRangeOfPoint(playerid, 3.0, tInfo[i][pXX], tInfo[i][pYY], tInfo[i][pZZ]))
            return i;

    return -1;
}

CMD:cuttree(playerid, params[])
{
    if(GetFactionType(playerid) == FACTION_POLICE) SendClientMessage(playerid, COLOR_RED, "You can't use this feature.");
    else{
        new ID = GetClosestTreeForPlayer(playerid);
        if(ID < 0) SendClientMessage(playerid, COLOR_RED, "You are not near a tree.");
        else{
            if(tInfo[ID][Status] != TREE_STATUS_DEAD) SendClientMessage(playerid, COLOR_RED, "Tree can't be destroyed.");
            else{
                if(GetPlayerWeapon(playerid) != WEAPON_CHAINSAW) SendClientMessage(playerid, COLOR_RED, "You need have chainsaw.");
                else{
                    treejob[playerid] = TREE_FAC_STATUS_HOLD;
                    TogglePlayerControllable(playerid, 0);
                    SetTimerEx("UnfreeTimer", 3000, false, "i", playerid);
                    Treereset(ID);
                    SendClientMessage(playerid, COLOR_RED, "You have to lift the tree now.");
                }
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)