Alright, I did some few tests but I encountered some problems and samp-side bugs.
As user 'ball' already mentioned there are indeed a few 'movable' objects like the cardboard boxes.
The problem with these kind of object are:
- They are static until a player touches them. So they won't move if you spawn them in the air.
- GetObjectPos does not seem to work with these objects (it returns the coords they originally spawned at).
I found a way to make them spawn in the air AND have them fall down is to spawn a RC-vehicle at the same position and attach the object to that vehicle.
The problems i found with his method:
- If the 'movable' object is attached to a vehicle, it won't move anymore.
To solve this problem I added a timer that will destroy the rc-vehicle, which will make the object movable again.
Another problem turned up:
- There is no native DetachObjectFromVehicle-function and object only gets detached if you destroy the vehicle, but the object stays virtually connected to that vehicle-id. So if somewhere a new vehicle gets spawned with that same id assigned to it, the object will teleport and be attached automatically to t that new vehicle.
I can't think of an other way to solve this and get it working in a nice way.
So here's my code, the box falls from the sky, a few meters north of the player and 6 meters in the air, but you can't move it (unless you hit it with a car).
You'll have to use GetVehiclePos(cratecar[playerid], x, y, z); go get the position of the crate (since GetObjectPos does not work).
I've created it as a command, you'll have to change it whatever you want to do with it.
pawn Код:
native IsValidVehicle(vehicleid);
new crate[MAX_PLAYERS];
new cratecar[MAX_PLAYERS];
pawn Код:
COMMAND:spawncrate(playerid, params[])
{
if(IsValidObject(crate[playerid])) DestroyObject(crate[playerid]);
if(IsValidVehicle(cratecar[playerid])) DestroyVehicle(cratecar[playerid]);
new Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
crate[playerid] = CreateObject(1220, pos[0], (pos[1]+5), (pos[2]+6.0), 0.0, 0.0, 0.0);
cratecar[playerid] = CreateVehicle(594, pos[0], (pos[1]+5.0), (pos[2]+6.0), 0.0, -1, -1, 999);
AttachObjectToVehicle(crate[playerid], cratecar[playerid], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
return 1;
}
Good luck with it!