PDA

View Full Version : AttachObjectToVehicle problem


Sreadon
12/11/2011, 11:31 PM
Hello,

I have a problem with my command, the objets doesn't appear on the vehicle, but they are created at 0, 0, 0, anyone know why? Here the code..


if(!strcmp(cmdtext, "/sultanadmin", true))
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new veh, Float:Pos[4];
new currentveh;
currentveh = GetPlayerVehicleID(playerid);
veh = GetVehiclePos(currentveh, Float:Pos[0], Float:Pos[1], Float:Pos[2]);
SetVehicleHealth(currentveh,10000);
VehicleObject[0] = CreateObject(2985, -0.03, 0.25, -0.06, 0.00, 0.00, 90.00);
VehicleObject[1] = CreateObject(2985, -0.09, -0.63, -0.06, 0.00, 0.00, 270.00);
VehicleObject[2] = CreateObject(362, -1.00, 1.72, 0.21, 25.62, 24.00, 90.00);
VehicleObject[3] = CreateObject(362, 1.15, 1.72, 0.21, 25.62, 24.00, 90.00);
VehicleObject[4] = CreateObject(18646, -0.60, 0.12, 0.85, 0.00, 0.00, 0.00);
VehicleObject[5] = CreateObject(18637, -0.80, -2.45, 0.30, 90.00, 0.00, 0.00);
VehicleObject[6] = CreateObject(18637, 0.18, -2.45, 0.30, 90.00, 0.00, 0.00);
VehicleObject[7] = CreateObject(18637, -0.32, -2.45, 0.30, 90.00, 0.00, 0.00);
VehicleObject[8] = CreateObject(18637, 0.56, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[0], veh, -0.03, 0.25, -0.06, 0.00, 0.00, 90.00);
AttachObjectToVehicle(VehicleObject[1], veh, -0.09, -0.63, -0.06, 0.00, 0.00, 270.00);
AttachObjectToVehicle(VehicleObject[2], veh, -1.00, 1.72, 0.21, 25.62, 24.00, 90.00);
AttachObjectToVehicle(VehicleObject[3], veh, -0.60, 0.12, 0.85, 0.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[4], veh, -0.80, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[5], veh, 0.18, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[6], veh, -0.32, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[7], veh, 0.56, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[8], veh, 1.15, 1.72, 0.21, 25.62, 24.00, 90.00);
SendClientMessage(playerid, COLOR_GRAD2, "Sultan équipée, 10000 PV!");
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "Vous n'avez pas accès à cette commande!");
}
}
return 1;
}



Thanks.

[HiC]TheKiller
13/11/2011, 02:37 AM
veh = GetVehiclePos(currentveh, Float:Pos[0], Float:Pos[1], Float:Pos[2]);

What is that meant to do? Take that line out and change it to


veh = GetPlayerVehicleID(playerid);

leong124
13/11/2011, 04:14 AM
Not really, I don't think the GetVehiclePos is useful.

if(!strcmp(cmdtext, "/sultanadmin", true))
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new currentveh = GetPlayerVehicleID(playerid);
SetVehicleHealth(currentveh,10000);
VehicleObject[0] = CreateObject(2985, -0.03, 0.25, -0.06, 0.00, 0.00, 90.00);
VehicleObject[1] = CreateObject(2985, -0.09, -0.63, -0.06, 0.00, 0.00, 270.00);
VehicleObject[2] = CreateObject(362, -1.00, 1.72, 0.21, 25.62, 24.00, 90.00);
VehicleObject[3] = CreateObject(362, 1.15, 1.72, 0.21, 25.62, 24.00, 90.00);
VehicleObject[4] = CreateObject(18646, -0.60, 0.12, 0.85, 0.00, 0.00, 0.00);
VehicleObject[5] = CreateObject(18637, -0.80, -2.45, 0.30, 90.00, 0.00, 0.00);
VehicleObject[6] = CreateObject(18637, 0.18, -2.45, 0.30, 90.00, 0.00, 0.00);
VehicleObject[7] = CreateObject(18637, -0.32, -2.45, 0.30, 90.00, 0.00, 0.00);
VehicleObject[8] = CreateObject(18637, 0.56, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[0], currentveh, -0.03, 0.25, -0.06, 0.00, 0.00, 90.00);
AttachObjectToVehicle(VehicleObject[1], currentveh, -0.09, -0.63, -0.06, 0.00, 0.00, 270.00);
AttachObjectToVehicle(VehicleObject[2], currentveh, -1.00, 1.72, 0.21, 25.62, 24.00, 90.00);
AttachObjectToVehicle(VehicleObject[3], currentveh, -0.60, 0.12, 0.85, 0.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[4], currentveh, -0.80, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[5], currentveh, 0.18, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[6], currentveh, -0.32, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[7], currentveh, 0.56, -2.45, 0.30, 90.00, 0.00, 0.00);
AttachObjectToVehicle(VehicleObject[8], currentveh, 1.15, 1.72, 0.21, 25.62, 24.00, 90.00);
SendClientMessage(playerid, COLOR_GRAD2, "Sultan equipee, 10000 PV!");
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "Vous n'avez pas acces a cette commande!");
}
}
return 1;
}

Sreadon
13/11/2011, 12:48 PM
Thanks for your response but it don't work. And, I've try to get the coords of the vehicle to place the objets on this.

Sreadon
13/11/2011, 02:27 PM
Sorry for the double post, but I've seen something, the vehicle's HP don't moves, they stay to 1000. Moreover, I've try to add a component and the component (nos) is perfectly added to the vehicle...

leong124
14/11/2011, 09:20 AM
It is because you've added SetVehicleHealth(currentveh,10000); in your script, making your vehicle to have more than 1000 health. AttachObjectToVehicle's coordinates is in terms of offset, so that you don't need to get the vehicle's coordinates for that.

If the script above doesn't work, then probably you're using an object streamer and you haven't limit the number of visible objects.