SA-MP Forums Archive
[[Help]] Removing Specific Attached Object - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [[Help]] Removing Specific Attached Object (/showthread.php?tid=497713)



[[Help]] Removing Specific Attached Object - HitterHitman - 28.02.2014

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?


Re: [[Help]] Removing Specific Attached Object - HitterHitman - 28.02.2014

Anyone please?


Re: [[Help]] Removing Specific Attached Object - HitterHitman - 01.03.2014

BUMP!


Re: [[Help]] Removing Specific Attached Object - Bingo - 01.03.2014

Uhm, Try using another line?

What makes them to remove CJ_Bag?


Re: [[Help]] Removing Specific Attached Object - rangerxxll - 01.03.2014

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);
}



Re: [[Help]] Removing Specific Attached Object - HitterHitman - 01.03.2014

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;
    }



Re: [[Help]] Removing Specific Attached Object - RoboN1X - 01.03.2014

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).


Re: [[Help]] Removing Specific Attached Object - HitterHitman - 01.03.2014

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?


Re: [[Help]] Removing Specific Attached Object - RoboN1X - 01.03.2014

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.


Re: [[Help]] Removing Specific Attached Object - HitterHitman - 01.03.2014

Thank you very much