SA-MP Forums Archive
Pick up an 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: Pick up an object. (/showthread.php?tid=646228)



Pick up an object. - Mo123 - 12.12.2017

How can you pick up an object? I made a command where you spawn a crate, and I'm trying to figure out how to pick it up and walk around with it with a proper animation.


Re: Pick up an object. - RogueDrifter - 12.12.2017

See SetPlayerAttachedObject
https://sampwiki.blast.hk/wiki/SetPlayerAttachedObject


Re: Pick up an object. - jasperschellekens - 13.12.2017

You could do it like this:
When you drop/spawn the object, add it in a variable.
e.g. Item[i] = CreateDynamicObject(objectid, X, Y, Z,0,0,0, world);

ApplyAnimation(playerid,"CARRY","crry_prtial",4.0, 1,0,0,1,1,1);
SetPlayerAttachedObject(playerid, 2, objectid,3,0.13,-0.32,-0.26,0.0,0.0,0.0,1.00,1.00,1.00);
DestroyDynamicObject(Item[i]);


Re: Pick up an object. - Beckett - 13.12.2017

Store the information in an array (coordinates, the object model, and anything else you may need) in order to contain it and work on it from there by checking if the player is at the object's coordinates then execute accordingly. If you're not very familiar with the Scripting Functions you can see a full list here.