AttachObjectToVehicle Problem
#1

sup guy I got a problem
with those codes
I want only for id 550 (sunrise) to attach those objects & add components
pawn Код:
public OnGameModeInit()
{
    AddVehicleComponent(550, 1001);
    AddVehicleComponent(550, 1005);
    AddVehicleComponent(550, 1006);
    AddVehicleComponent(550, 1010);
    AddVehicleComponent(550, 1020);
    AddVehicleComponent(550, 1025);
    AddVehicleComponent(550, 1143);
    tmpobjid = CreateDynamicObject(1593,0.0,0.0,-1000.0,0.0,0.0,0.0,-1,-1,-1,300.0,300.0);
    SetDynamicObjectMaterial(tmpobjid, 0, 1560, "7_11_door", "CJ_CHROME2", -16738048);
    AttachDynamicObjectToVehicle(tmpobjid, 550, 0.000, 3.000, -0.400, 0.000, 90.000, 90.000);
    tmpobjid = CreateDynamicObject(1593,0.0,0.0,-1000.0,0.0,0.0,0.0,-1,-1,-1,300.0,300.0);
    SetDynamicObjectMaterial(tmpobjid, 0, 1560, "7_11_door", "CJ_CHROME2", -16738048);
    AttachDynamicObjectToVehicle(tmpobjid, 550, 0.000, 3.000, -0.200, 0.000, 90.000, 90.000);
   return 1;
}

public OnVehicleSpawn(vehicleid)
{
if(vehicleid == GetVehicleModel(vehicleid ==550))
    {
        AddVehicleComponent(550, 1001);
        AddVehicleComponent(550, 1005);
        AddVehicleComponent(550, 1006);
        AddVehicleComponent(550, 1010);
        AddVehicleComponent(550, 1020);
        AddVehicleComponent(550, 1025);
        AddVehicleComponent(550, 1143);
       tmpobjid = CreateDynamicObject(1593,0.0,0.0,-1000.0,0.0,0.0,0.0,-1,-1,-1,300.0,300.0);
       SetDynamicObjectMaterial(tmpobjid, 0, 1560, "7_11_door", "CJ_CHROME2", -16738048);
       AttachDynamicObjectToVehicle(tmpobjid, 550, 0.000, 3.000, -0.400, 0.000, 90.000, 90.000);
       tmpobjid = CreateDynamicObject(1593,0.0,0.0,-1000.0,0.0,0.0,0.0,-1,-1,-1,300.0,300.0);
       SetDynamicObjectMaterial(tmpobjid, 0, 1560, "7_11_door", "CJ_CHROME2", -16738048);
       AttachDynamicObjectToVehicle(tmpobjid, 550, 0.000, 3.000, -0.200, 0.000, 90.000, 90.000);
    }
    return 1;
}
I don't get any error in server but when I connect and type admin cmd /car sunrise the object don't attach to the Vehicle
can anyone help me ?
Reply
#2

vehicle id IS NOT vehicle model id, please don't be confused with it.
Sunrise Vehicle model ID is 550, but vehicle id is the ID of every vehicle (like player ID).
If you type /dl you can see a label on vehicle, the "id" means the vehicle id, and the "type" means the model id

Here, try use this instead:
Код:
public OnVehicleSpawn(vehicleid)
{
	if(GetVehicleModel(vehicleid) == 550))
    {
        AddVehicleComponent(vehicleid, 1001);
        AddVehicleComponent(vehicleid, 1005);
        AddVehicleComponent(vehicleid, 1006);
        AddVehicleComponent(vehicleid, 1010);
        AddVehicleComponent(vehicleid, 1020);
        AddVehicleComponent(vehicleid, 1025);
        AddVehicleComponent(vehicleid, 1143);
        tmpobjid = CreateDynamicObject(1593,0.0,0.0,-1000.0,0.0,0.0,0.0,-1,-1,-1,300.0,300.0);
        SetDynamicObjectMaterial(tmpobjid, 0, 1560, "7_11_door", "CJ_CHROME2", -16738048);
        AttachDynamicObjectToVehicle(tmpobjid, vehicleid, 0.000, 3.000, -0.400, 0.000, 90.000, 90.000);
        tmpobjid = CreateDynamicObject(1593,0.0,0.0,-1000.0,0.0,0.0,0.0,-1,-1,-1,300.0,300.0);
        SetDynamicObjectMaterial(tmpobjid, 0, 1560, "7_11_door", "CJ_CHROME2", -16738048);
        AttachDynamicObjectToVehicle(tmpobjid, vehicleid, 0.000, 3.000, -0.200, 0.000, 90.000, 90.000);
    }
	return 1;
}
Reply
#3

Try how i did using a variable for the car

Example from samp wiki
Код:
new object1 = CreateObject(...);
new vehicle1 = GetPlayerVehicleID(playerid);
AttachObjectToVehicle(object1, vehicle1, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
And use a if vehicle1 = id of sunrise and then add your stuff... If still isn’t working use your script and attachcameratoobject to see where the objects are after the spawn of the vehicle . that’s how i did when i had troubles
Reply
#4

well thanks .. both
but still get problems
vehicles creates (Ongaemodeinit)
with id 550 got the Objects but in command wont
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)