PDA

View Full Version : AttachObjectToVehicle Never works..


-CaRRoT
07/06/2012, 07:22 AM
Well.. I've tried it with different ways.. With Neons / Sirens.. etc - But still , it don't work..


I am using a Streamer.. Here is some of my CMD's..

if(strcmp(cmd, "/addsiren", true) == 0)
{
new VID = GetPlayerVehicleID(playerid);
if(IsACop(playerid) || IsAAgent(playerid))
{
BigSiren[VID] = CreateDynamicObject(19419, 10.0, 10.0, 10.0, 0, 0, 0);
AttachObjectToVehicle(BigSiren[VID], VID, -0.039999, -0.469999, 0.669999, 0.000000, 0.000000, 0.000000);
format(string, sizeof(string), "* %s puts the siren on the vehicle's roof.", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
}
else
{
SendClientMessage(playerid, COLOR_WHITE,"You are not a cop");
}
return 1;
}




//blue
SetPVarInt(playerid, "Status", 1);
SetPVarInt(playerid, "neon", CreateDynamicObject(18648,0,0,0,0,0,0));
SetPVarInt(playerid, "neon1", CreateDynamicObject(18648,0,0,0,0,0,0));
AttachObjectToVehicle(GetPVarInt(playerid, "neon"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
AttachObjectToVehicle(GetPVarInt(playerid, "neon1"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
}
if(listitem == 1)
{


//red
SetPVarInt(playerid, "Status", 1);
SetPVarInt(playerid, "neon2", CreateDynamicObject(18647,0,0,0,0,0,0));
SetPVarInt(playerid, "neon3", CreateDynamicObject(18647,0,0,0,0,0,0));
AttachObjectToVehicle(GetPVarInt(playerid, "neon2"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
AttachObjectToVehicle(GetPVarInt(playerid, "neon3"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0xFFFFFFAA, "neon installed");

}
if(listitem == 2)
{


//green
SetPVarInt(playerid, "Status", 1);
SetPVarInt(playerid, "neon4", CreateDynamicObject(18649,0,0,0,0,0,0));
SetPVarInt(playerid, "neon5", CreateDynamicObject(18649,0,0,0,0,0,0));
AttachObjectToVehicle(GetPVarInt(playerid, "neon4"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
AttachObjectToVehicle(GetPVarInt(playerid, "neon5"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0xFFFFFFAA, "neon installed");

}


none of them works.. I have other CMD's like that.. but - Everything in the CMD works except the Object - it never get attached -.-.. Hope someone can help

Lorenc_
07/06/2012, 07:39 AM
AttachObjectToVehicle only works with objects created with CreateObject - Unless streamer.inc has a function like AttachObjectToVehicle though for dynamic objects then that can be used (AttachDynamicObjectToVehicle)

HDFord
07/06/2012, 07:44 AM
That was a really hard way to script. And please only use [php] for php codes. At the siren command you're using a not nessesary variable. You can use VID on GetPlayerVehicleID but not the object just create a new siren; something. AttachObjectToVehicle should be used with the most common way of scripting couse it might not understand everything. Also it try CreateObject instead.
Pawno is wierd i know that.

ikey07
07/06/2012, 07:54 AM
if(IsACop(playerid)

can player be a cop car? :P

-CaRRoT
07/06/2012, 09:08 AM
AttachObjectToVehicle only works with objects created with CreateObject - Unless streamer.inc has a function like AttachObjectToVehicle though for dynamic objects then that can be used (AttachDynamicObjectToVehicle)

- Thanks , you the best - Worked xD [Repped +]