Falling crates.
#1

Hey guys, Is it possible to have crates being dropped from the sky on command?
Is there such object that drops down on spawn, And doesn't stay flying in the sky?
Reply
#2

On default created objects are static, they are not affected by gravity. You could manually move the object by using MoveObject or maybe this include would be helpful: Objects Physics
Reply
#3

Quote:
Originally Posted by Schneider
Посмотреть сообщение
On default created objects are static, they are not affected by gravity. You could manually move the object by using MoveObject or maybe this include would be helpful: Objects Physics
Looks useful, But confused in how to use it.
Reply
#4

I think there are some objects that type. Try models 1220, 1221 and 1224.
Reply
#5

I just got an idea, I'll test it out myself to see if it works and i'll get back to you.
Reply
#6

Quote:
Originally Posted by ball
Посмотреть сообщение
I think there are some objects that type. Try models 1220, 1221 and 1224.
Hmm i'll try that

Quote:
Originally Posted by Schneider
Посмотреть сообщение
I just got an idea, I'll test it out myself to see if it works and i'll get back to you.
Thanks buddy.
Reply
#7

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!
Reply
#8

I don't know if this will help.

But couldn't you just spawn a RC vehicle at the box so it falls down?.
And then just destroy (delete the vehicle) ?.

Another way maybe: Make a explosion, but the cardboard will get destroyed then. But I don't know if it still will get affected if the explosion is more far away then the object?.

I guess it gonna get destroyed anyway even if the explosion is a bit away from the object or not affected at all.
Reply
#9

I tried both things, but rc-vehicles will just land on them and heavy vehicles will destroy them. Same for explosions.
Reply
#10

This ?
https://www.youtube.com/watch?v=zt9t77i5iQE
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)