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

as the title say it doesnt work, even when you are in range of an tree.

pawn Код:
stock CreateTree(model ,Float:X, Float:Y, Float:Z, Float:rottX, Float:rottY, Float:rottZ)
{
    trees[treed] = CreateDynamicObject(model, X, Y, Z, rottX, rottY, rottZ);
    tInfo[treed][Status] = TREE_STATUS_SPAWN;
    tInfo[treed][pXX] = X;
    tInfo[treed][pYY] = Y;
    tInfo[treed][pZZ] = Z;
    tInfo[treed][rotXX] = rottX;
    tInfo[treed][rotYY] = rottY;
    tInfo[treed][rotZZ] = rottZ;
    treed++;
    return 1;
}

stock TreeUp(treeid, Float:X, Float:Y, Float:Z, Float:rottX, Float:rottY, Float:rottZ)
{
    tInfo[treeid][pXX] = X;
    tInfo[treeid][pYY] = Y;
    tInfo[treeid][pZZ] = Z;
    tInfo[treeid][rotXX] = rottX;
    tInfo[treeid][rotYY] = rottY;
    tInfo[treeid][rotZZ] = rottZ;
    SetDynamicObjectPos(trees[treeid], X, Y, Z);
    SetDynamicObjectRot(trees[treeid], rottX, rottY, rottZ);
    tInfo[treeid][Status] = TREE_STATUS_SPAWN;
    return 1;
}

stock TreeDown(treeid, Float:X, Float:Y, Float:Z, Float:rottX, Float:rottY, Float:rottZ)
{
    tInfo[treeid][pXX] = X;
    tInfo[treeid][pYY] = Y;
    tInfo[treeid][pZZ] = Z;
    tInfo[treeid][rotXX] = rottX;
    tInfo[treeid][rotYY] = rottY;
    tInfo[treeid][rotZZ] = rottZ;
    SetDynamicObjectPos(trees[treeid], X, Y, Z);
    SetDynamicObjectRot(trees[treeid], rottX, rottY, rottZ);
    tInfo[treeid][Status] = TREE_STATUS_DEAD;
    return 1;
}

CMD:cuttree(playerid, params[])
{
    if(GetFactionType(playerid) != FACTION_POLICE)
    {
        for(new i = 0; i < MAX_TREES; i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3.0, tInfo[trees[i]][pXX], tInfo[trees[i]][pYY], tInfo[trees[i]][pZZ]))
            {
                if(tInfo[i][Status] == TREE_STATUS_DEAD)
                {
                    if(GetPlayerWeapon(playerid) == 9)
                    {
                        treejob[playerid] = TREE_FAC_STATUS_HOLD;
                        TogglePlayerControllable(playerid, 0);
                        SetTimerEx("UnfreeTimer", 3000, false, "i", playerid);
                        Treereset(i);
                        SendClientMessage(playerid, COLOR_RED, "You have to lift the tree now");
                        break;
                    }
                }
                else return SendClientMessage(playerid, COLOR_RED, "Tree can't be destroyed");
            }
            else return SendClientMessage(playerid, COLOR_RED, "You are not near a tree.");
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "You can't use this feature");
    return 1;
}
Reply
#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
#3

Quote:
Originally Posted by Jefff
Посмотреть сообщение
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;
}
gives still the same issue.
Reply
#4

So try to increase range to 30.0 for example
Reply
#5

Quote:
Originally Posted by Jefff
Посмотреть сообщение
So try to increase range to 30.0 for example
Still "You are not near a tree"
Reply
#6

Replace to this and show server logs
pawn Код:
GetClosestTreeForPlayer(playerid)
{
    printf("treeid: %d",treeid);
    for(new i = 0; i < treeid; i++)
    {
        printf("%d - Range: %.4f - X: %.4f - Y: %.4f - Z: %.4f",i,GetPlayerDistanceFromPoint(playerid, tInfo[i][pXX], tInfo[i][pYY], tInfo[i][pZZ]),tInfo[i][pXX], tInfo[i][pYY], tInfo[i][pZZ]);
        if(IsPlayerInRangeOfPoint(playerid, 3.0, tInfo[i][pXX], tInfo[i][pYY], tInfo[i][pZZ]))
            return i;
    }

    return -1;
}
Reply
#7

pawn Код:
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22923) : error 017: undefined symbol "treeid"
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22924) : error 017: undefined symbol "treeid"
Just
pawn Код:
new treeid
?
Reply
#8

You got in CreateTree
pawn Код:
tInfo[ treed ][Status] = TREE_STATUS_SPAWN;
and in TreeUp
pawn Код:
tInfo[ treeid ][Status] = TREE_STATUS_SPAWN;
so i dont know
Reply
#9

pawn Код:
stock CreateTree(treeid, model ,Float:X, Float:Y, Float:Z, Float:rottX, Float:rottY, Float:rottZ)
{
    trees[treeid] = CreateDynamicObject(model, X, Y, Z, rottX, rottY, rottZ);
    tInfo[treeid][Status] = TREE_STATUS_SPAWN;
    tInfo[treeid][pXX] = X;
    tInfo[treeid][pYY] = Y;
    tInfo[treeid][pZZ] = Z;
    tInfo[treeid][rotXX] = rottX;
    tInfo[treeid][rotYY] = rottY;
    tInfo[treeid][rotZZ] = rottZ;
    treeid++;
    return 1;
}
pawn Код:
C:\Users/Desktop\new server\gamemodes\roleplay.pwn(22735) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22735) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22736) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22736) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22737) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22737) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22738) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22738) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22739) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22739) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22740) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22740) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22741) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22741) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22742) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22742) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22743) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22743) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22744) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22744) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22745) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22745) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22746) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22746) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22747) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22747) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22748) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22748) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22749) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22749) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22923) : error 017: undefined symbol "treeid"
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22924) : error 017: undefined symbol "treeid"
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(40254) : warning 203: symbol is never used: "treed"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
error lines:
pawn Код:
forward CreateTrees();
public CreateTrees()
{
    CreateTree(621, 148.40112, -1594.56152, 10.41950,   0.00000, 0.00000, 0.00000);
    CreateTree(621, 872.44397, -1418.94690, 13.30900,   0.00000, 0.00000, 0.00000);
    CreateTree(615, 1329.28870, -1418.72229, 12.54483,   0.00000, 0.00000, 0.00000);
    CreateTree(620, 1196.09790, -1840.84937, 12.50620,   0.00000, 0.00000, 0.00000);
    CreateTree(620, 2104.56445, -1765.55371, 12.28000,   0.00000, 0.00000, 0.00000);
    CreateTree(621, 904.98608, -1759.67542, 11.82000,   0.00000, 0.00000, 0.00000);
    CreateTree(615, 648.93683, -1078.05432, 46.74230,   0.00000, 0.00000, 0.00000);
    CreateTree(615, 304.46860, -1240.53784, 70.27060,   0.00000, 0.00000, 0.00000);
    CreateTree(710, 1408.97498, -883.48022, 58.58970,   0.00000, 0.00000, 0.00000);
    CreateTree(710, 1525.77588, -826.54437, 82.78380,   0.00000, 0.00000, 0.00000);
    CreateTree(710, 1412.33203, -647.31122, 105.48460,   0.00000, 0.00000, 0.00000);
    CreateTree(621, 2729.79053, -1522.59143, 29.61790,   0.00000, 0.00000, -33.00000);
    CreateTree(620, 2872.42871, -1640.76050, 9.67040,   0.00000, 0.00000, 0.00000);
    CreateTree(620, 2294.92749, -1159.06360, 25.11970,   0.00000, 0.00000, 0.00000);
    CreateTree(621, 2630.13232, -1690.43982, 9.56290,   0.00000, 0.00000, 0.00000);
    return 1;
}
Reply
#10

Quote:
Originally Posted by lulo356
Посмотреть сообщение
pawn Код:
stock CreateTree(treeid, model ,Float:X, Float:Y, Float:Z, Float:rottX, Float:rottY, Float:rottZ)
{
    trees[treeid] = CreateDynamicObject(model, X, Y, Z, rottX, rottY, rottZ);
    tInfo[treeid][Status] = TREE_STATUS_SPAWN;
    tInfo[treeid][pXX] = X;
    tInfo[treeid][pYY] = Y;
    tInfo[treeid][pZZ] = Z;
    tInfo[treeid][rotXX] = rottX;
    tInfo[treeid][rotYY] = rottY;
    tInfo[treeid][rotZZ] = rottZ;
    treeid++;
    return 1;
}
pawn Код:
C:\Users/Desktop\new server\gamemodes\roleplay.pwn(22735) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22735) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22736) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22736) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22737) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22737) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22738) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22738) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22739) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22739) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22740) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22740) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22741) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22741) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22742) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22742) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22743) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22743) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22744) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22744) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22745) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22745) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22746) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22746) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22747) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22747) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22748) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22748) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22749) : warning 213: tag mismatch
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22749) : warning 202: number of arguments does not match definition
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22923) : error 017: undefined symbol "treeid"
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(22924) : error 017: undefined symbol "treeid"
C:\Users\Desktop\new server\gamemodes\roleplay.pwn(40254) : warning 203: symbol is never used: "treed"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
error lines:
pawn Код:
forward CreateTrees();
public CreateTrees()
{
    CreateTree(621, 148.40112, -1594.56152, 10.41950,   0.00000, 0.00000, 0.00000);
    CreateTree(621, 872.44397, -1418.94690, 13.30900,   0.00000, 0.00000, 0.00000);
    CreateTree(615, 1329.28870, -1418.72229, 12.54483,   0.00000, 0.00000, 0.00000);
    CreateTree(620, 1196.09790, -1840.84937, 12.50620,   0.00000, 0.00000, 0.00000);
    CreateTree(620, 2104.56445, -1765.55371, 12.28000,   0.00000, 0.00000, 0.00000);
    CreateTree(621, 904.98608, -1759.67542, 11.82000,   0.00000, 0.00000, 0.00000);
    CreateTree(615, 648.93683, -1078.05432, 46.74230,   0.00000, 0.00000, 0.00000);
    CreateTree(615, 304.46860, -1240.53784, 70.27060,   0.00000, 0.00000, 0.00000);
    CreateTree(710, 1408.97498, -883.48022, 58.58970,   0.00000, 0.00000, 0.00000);
    CreateTree(710, 1525.77588, -826.54437, 82.78380,   0.00000, 0.00000, 0.00000);
    CreateTree(710, 1412.33203, -647.31122, 105.48460,   0.00000, 0.00000, 0.00000);
    CreateTree(621, 2729.79053, -1522.59143, 29.61790,   0.00000, 0.00000, -33.00000);
    CreateTree(620, 2872.42871, -1640.76050, 9.67040,   0.00000, 0.00000, 0.00000);
    CreateTree(620, 2294.92749, -1159.06360, 25.11970,   0.00000, 0.00000, 0.00000);
    CreateTree(621, 2630.13232, -1690.43982, 9.56290,   0.00000, 0.00000, 0.00000);
    return 1;
}
In your stock you're having 8 parameters.
In your code you're having 7 parameters.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)