AttachObjectToVehicle. HELP!
#1

This is my command:
Код:
if (strcmp("/siren", cmdtext, true, 6) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You must be in a vehicle to use this command!");
        new object = CreateDynamicObject(18646,0,0,-1000,0,0,0,100);
        AttachObjectToVehicle(object, GetPlayerVehicleID(playerid), -0.300000,0.000000,0.749999,0.000000,0.000000,0.000000);
        return 1;
    }
What is wrong?
Reply
#2

Quote:
Originally Posted by Mecool
Посмотреть сообщение
This is my command:
Код:
if (strcmp("/siren", cmdtext, true, 6) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You must be in a vehicle to use this command!");
        new object = CreateDynamicObject(18646,0,0,-1000,0,0,0,100);
        AttachObjectToVehicle(object, GetPlayerVehicleID(playerid), -0.300000,0.000000,0.749999,0.000000,0.000000,0.000000);
        return 1;
    }
What is wrong?
I am unsure about the streamer plugin you better use the normal CreateObject function and give it a try. You can do like this:-

pawn Код:
new objectid = CreateObject(...); // your own createObject
new vehicleid = GetPlayerVehicleID(playerid); // put the vehicle id in vehicleid variable
AttachObjectToVehicle(objectid, vehicleid, fx, fy, fz,frx, fry, frz); // and finally attachs to the vehicle.
-FalconX
Reply
#3

You using this streamer: https://sampforum.blast.hk/showthread.php?tid=102865

If you read the thread, you will establish the fact that this include does not posses a AttachDynamicObjectToVehicle, so when you use the default function, it does not respond/do anything.

Although there is a obvious solution to this problem, may i hint with a bit of code?

Код:
stock AttachDynamicObjectToVehicle(vehicleid, objectid, Float:OffsetX, Float:OffsetY, Float:OffsetZ, Float:RotX, Float:RotY, Float:RotZ)
{
    DestroyDynamicObject(objectid);// :O
    new Float:x, Float:y, Float:z;
    GetVehiclePos(vehicleid, x, y, z);
    new object = CreateObject(objectid, x + 2.0, y + 2.0, z, 0.0, 0.0, 100.0);//Make sure you set the draw distance to suit your fancy. (Default: 100.0)
    AttachObjectToVehicle(object, vehicleid, OffsetX, OffsetY, OffsetZ, RotX, RotY, RotZ);
    return 1;
}
Note: NOT tested.


Then simply, DestroyObject and CreateDynamicObject to "Detach".


You get the point tho.
Reply
#4

What is wrong? Don't create object me?
Код:
if( newkeys == KEY_YES )
{
new objectid = CreateObject(18646,0,0,-1000,0,0,0,100);
new vehicleid = GetPlayerVehicleID(playerid);
AttachObjectToVehicle(objectid, vehicleid, -0.300000,0.000000,0.749999,0.000000,0.000000,0.000000);
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)