SA-MP Forums Archive
IsPlayerAttachedObjectSlotUsed +rep! - 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: IsPlayerAttachedObjectSlotUsed +rep! (/showthread.php?tid=319108)



IsPlayerAttachedObjectSlotUsed +rep! - PawnoQ - 17.02.2012

hi,

how could i loop trough all object slots/indexes and check how many objects a player has attached?

pawn Код:
IsPlayerAttachedObjectSlotUsed();
please help


Re: IsPlayerAttachedObjectSlotUsed +rep! - Jefff - 18.02.2012

pawn Код:
stock AttachedObjects(playerid)
{
    new Objects;
    for(new d; d < MAX_PLAYER_ATTACHED_OBJECTS; d++)
        if(IsPlayerAttachedObjectSlotUsed(playerid, d);
            Objects++;
    return Objects;
}



Re: IsPlayerAttachedObjectSlotUsed +rep! - PawnoQ - 18.02.2012

so i could use this like?
pawn Код:
if(Objects>1)return //...ERROR: only 1 object possible



Re: IsPlayerAttachedObjectSlotUsed +rep! - Jefff - 18.02.2012

if(AttachedObjects(playerid) > 1)


Re: IsPlayerAttachedObjectSlotUsed +rep! - Rob_Maate - 18.02.2012

Ye - Calling the AttachedObjects stock from above would return the number attached to that player.
So if you wanted to use it externally:

pawn Код:
new Variable;
Variable = AttachedObjects(playerid);
if(Variable>1)
{
    //Do things if there is more than one object attached
}