[[Help]] Removing Specific Attached Object
#1

Hello All! I am attaching this object to player

pawn Код:
SetPlayerAttachedObject( playerid, 0, 1550, 1, 0.021874, -0.291005, -0.065996, 2.304857, 116.303932, 147.327270, 0.995781, 0.997286, 1.000000 ); // CJ_MONEY_BAG
And using this code to remove it.

pawn Код:
for(new t=0; t<MAX_PLAYER_ATTACHED_OBJECTS; t++)
{
    if(IsPlayerAttachedObjectSlotUsed(playerid, t)) RemovePlayerAttachedObject(playerid, t);
}
The problem is this that it removes every attached object but i need to remove only the CJ_MONEY_BAG, How can i do this?
Reply
#2

Anyone please?
Reply
#3

BUMP!
Reply
#4

Uhm, Try using another line?

What makes them to remove CJ_Bag?
Reply
#5

I've honestly not used used AttachObject before. But I may be able to help. What callback are you using this on?
pawn Код:
for(new t=0; t<MAX_PLAYER_ATTACHED_OBJECTS; t++)
{
    if(IsPlayerAttachedObjectSlotUsed(playerid, t)) RemovePlayerAttachedObject(playerid, t);
}
Reply
#6

Its on onPlayerDeath, Onplayer leave checkpoint and one self created callback, which get called every second and it is something like this
pawn Код:
if(getCheckpointType(playerid) == CP_SupaSaveMain)
    {
        if(RobbingSupaSave[playerid] >= 1)
        {
            RobbingSupaSave[playerid] =0;
            for(new t=0; t<MAX_PLAYER_ATTACHED_OBJECTS; t++)
            {
                if(IsPlayerAttachedObjectSlotUsed(playerid, t)) RemovePlayerAttachedObject(playerid, t);
            }
            return 1;
        }
        return 1;
    }
Reply
#7

pawn Код:
SetPlayerAttachedObject(playerid, 0, 1550, 1, 0.021874, -0.291005, -0.065996, 2.304857, 116.303932, 147.327270, 0.995781, 0.997286, 1.000000); // CJ_MONEY_BAG
// This is the attached object id ▲ (0) also this: ---------------------▼
/* So, remove it with this code: */ RemovePlayerAttachedbject(playerid, 0);
You can't assign the slot to a variable, you can just specify the number of it (0 to 9 since 0.3d).
Reply
#8

Quote:

SetPlayerAttachedObject(playerid, 0, 1550, 1, 0.021874, -0.291005, -0.065996, 2.304857, 116.303932, 147.327270, 0.995781, 0.997286, 1.000000); // CJ_MONEY_BAG
// This is the attached object id ▲ (0) also this: ---------------------▼
/* So, remove it with this code: */ RemovePlayerAttachedbject(playerid, 0);
You can't assign the slot to a variable, you can just specify the number of it (0 to 9 since 0.3d).

So will it remove all attached object with id 0?
Reply
#9

Quote:
Originally Posted by HitterHitman
Посмотреть сообщение
So will it remove all attached object with id 0?
It will delete attached object id 0 from the player. (Not all players).
Only one attached object with id 0, no more, Even created more it will replace the previous one if exist.
As you can see in the wiki note, https://sampwiki.blast.hk/wiki/SetPlayerAttachedObject the function is separate from the CreateObject/CreatePlayerObject pools, So its ID is different, because the id is set on the player, not on the object.
Reply
#10

Thank you very much
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)