Originally Posted by blewert
First off, AttachObjectToVehicle's first argument takes an instance of an object, not the id used to create it. You need to make an instance of that object (i.e. create it), then attach the instance of the object to the vehicle. An example:
PHP код:
//Make a new variable to assign the object's instance ID to.
new obj;
//Create a wheelie bin at 0.0, 0.0, 0.0 and assign it's instance id to obj.
obj = CreateObject(1337, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
Secondly, I don't know why, but it seems like the second argument of AttachObjectToVehicle is using a vehicle's model id, not the specified vehicle ID? Try this code:
PHP код:
if(strcmp(cmdtext, "/test", true) == 0)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(GetPlayerMoney(playerid) >= 0)
{
new mnrg[MAX_PLAYERS];
GivePlayerMoney(playerid, -0);
mnrg[playerid] = CreateVehicle(560, X, Y, Z + 1, 90.0, -1, -1, 100000000);
PutPlayerInVehicle(playerid, mnrg[playerid], 0);
AddVehicleComponent(mnrg[playerid], 1079);
//New variable to assign object instance id to.
new lpObj;
//Create specified object at players pos.
lpObj = CreateObject( 19076, X, Y, Z, 0.0, 0.0, 0.0 );
//Attach the object's instance id to the vehicle.
AttachObjectToVehicle( lpObj, mnrg[playerid], 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
}
return 1;
}
|