command not working
#1

pawn Код:
CMD:pickup(playerid, params[])
{
    for(new i = 0; i < MAX_LABELS; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, LabelInfo[i][LabelX], LabelInfo[i][LabelY], LabelInfo[i][LabelZ]))
        {
            format(GlobalString, sizeof(GlobalString), "%s picks up a weapon shell from the ground.", GetUsername(playerid));
            ProxDetector(15.0, playerid, GlobalString, COLOR_PURPLE);
            Delete3DTextLabel(Text3D:LabelInfo[i][LabelID]);
            break;
        }
        else SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" You're not near anything to pickup."); break;
    }
    return true;
}
No matter how close I am it returns "You're not near anything to pickup".
Reply
#2

Show the enum LabelInfo
Reply
#3

pawn Код:
enum DLabel
{
    LabelID,
    LabelName[60],
    Float:LabelX,
    Float:LabelY,
    Float:LabelZ,
    LabelInt,
    LabelVW,
    LabelOwner[24],
    Pickup,
    Holding[24],
}
new LabelInfo[MAX_LABELS][DLabel];
Reply
#4

Don't send the message that you're not in range in a loop because if you're not in range for the first item but you are for an item, it will send the message and stop.

PHP код:
CMD:pickup(playeridparams[])
{
    new 
bool:inrange;
    for(new 
0MAX_LABELSi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid3.0LabelInfo[i][LabelX], LabelInfo[i][LabelY], LabelInfo[i][LabelZ]))
        {
            
format(GlobalStringsizeof(GlobalString), "%s picks up a weapon shell from the ground."GetUsername(playerid));
            
ProxDetector(15.0playeridGlobalStringCOLOR_PURPLE);
            
Delete3DTextLabel(Text3D:LabelInfo[i][LabelID]);
            
inrange true;
            break;
        }
    }
    if (!
inrangeSendClientMessage(playeridCOLOR_RED"Error:"COL_WHITE" You're not near anything to pickup.");
    return 
true;

Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Don't send the message that you're not in range in a loop because if you're not in range for the first item but you are for an item, it will send the message and stop.

PHP код:
CMD:pickup(playeridparams[])
{
    new 
bool:inrange;
    for(new 
0MAX_LABELSi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid3.0LabelInfo[i][LabelX], LabelInfo[i][LabelY], LabelInfo[i][LabelZ]))
        {
            
format(GlobalStringsizeof(GlobalString), "%s picks up a weapon shell from the ground."GetUsername(playerid));
            
ProxDetector(15.0playeridGlobalStringCOLOR_PURPLE);
            
Delete3DTextLabel(Text3D:LabelInfo[i][LabelID]);
            
inrange true;
            break;
        }
    }
    if (!
inrangeSendClientMessage(playeridCOLOR_RED"Error:"COL_WHITE" You're not near anything to pickup.");
    return 
true;

Works, but sadly doesn't delete the label?
Reply
#6

Try this:
PHP код:
enum DLabel
{
    
Text3D:LabelID,
    
LabelName[60],
    
Float:LabelX,
    
Float:LabelY,
    
Float:LabelZ,
    
LabelInt,
    
LabelVW,
    
LabelOwner[24],
    
Pickup,
    
Holding[24],
}
new 
LabelInfo[MAX_LABELS][DLabel];
CMD:pickup(playeridparams[])
{
    for(new 
0MAX_LABELSi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid3.0LabelInfo[i][LabelX], LabelInfo[i][LabelY], LabelInfo[i][LabelZ]))
        {
            
format(GlobalStringsizeof(GlobalString), "%s picks up a weapon shell from the ground."GetUsername(playerid));
            
ProxDetector(15.0playeridGlobalStringCOLOR_PURPLE);
            
Delete3DTextLabel(LabelInfo[i][LabelID]);
            return 
1;
        }
        else 
SendClientMessage(playeridCOLOR_RED"Error:"COL_WHITE" You're not near anything to pickup.");
    }
    return 
1;

If it doesn't work, show the where you created the textlabel
Reply
#7

pawn Код:
CMD:pickup(playerid, params[])
{
    new bool:inrange;
    for(new i = 0; i < MAX_LABELS; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, LabelInfo[i][LabelX], LabelInfo[i][LabelY], LabelInfo[i][LabelZ]))
        {
            format(GlobalString, sizeof(GlobalString), "%s picks up a weapon shell from the ground.", GetUsername(playerid));
            ProxDetector(15.0, playerid, GlobalString, COLOR_PURPLE);
            DestroyDynamic3DTextLabel(Text3D:LabelInfo[i][LabelID]);
            inrange = true;
            break;
        }
    }
    if (!inrange) SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" You're not near anything to pickup.");
    return true;
}
I had to use DestroyDynamic3DTextLabel but it only works on the first one created.

EDIT: It likes to choose when it works. Now it works up until about the 4th or 5th one and then doesn't delete them.
Reply
#8

Show where you created these labels, probably OnGamdeModeInit
Reply
#9

Do you mean that it only destroys the first 3D label and not the rest? If so, post the code you create those 3D labels.
Reply
#10

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
Show where you created these labels, probably OnGamdeModeInit
Nope, I don't.

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Do you mean that it only destroys the first 3D label and not the rest? If so, post the code you create those 3D labels.
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new Float:pX, Float:pY, Float:pZ;
    GetPlayerPos(playerid, Float:pX, Float:pY, Float:pZ);
    CreateLabel(""COL_RED"["COL_WHITE"Weapon Shell"COL_RED"]", pX, pY, pZ, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid), GetUsername(playerid));
    return 1;
}
pawn Код:
CreateLabel(LName[60], Float:LX, Float:LY, Float:LZ, LInt, LVW, LOwner[24])
{
    format(GlobalQuery, sizeof(GlobalQuery), "INSERT INTO `labels` (LabelName, LabelX, LabelY, LabelZ, LabelInt, LabelVW, LabelOwner) VALUES ('%s', %f, %f, %f, %d, %d, '%s')", LName, Float:LX, Float:LY, Float:LZ, LInt, LVW, LOwner);
    mysql_function_query(MySQLConnection, GlobalQuery, true, "LabelCreated", "");
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)