Attach Object
#1

I Have an problem on my command
object not attaching ? to vechile

Ther is cmd
Код:
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);
				AttachObjectToVehicle(19076, 560, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
			}
			return 1;
    }
Can anyone tell me what i miss ? in cmd
Reply
#2

Double Post Sorry

Help Please Urgent
Reply
#3

is it complying fine?
Reply
#4

yes complying fine
Reply
#5

pawn Код:
AttachObjectToVehicle(19076, mnrg[playerid], 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
Change it to this one^.
Reply
#6

Change but Object Not Attaching To Car ?
Reply
#7

Quote:
Originally Posted by K4P3L_KUM4R
Посмотреть сообщение
Код:
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);
				AttachObjectToVehicle(19076, 560, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
			}
			return 1;
    }
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(13370.00.00.00.00.00.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:XFloat:YFloat:Z;
    
GetPlayerPos(playeridXYZ);
    if(
GetPlayerMoney(playerid) >= 0)
    {
        new 
mnrg[MAX_PLAYERS];
        
GivePlayerMoney(playerid, -0);
        
mnrg[playerid] = CreateVehicle(560XY190.0, -1, -1100000000);
        
PutPlayerInVehicle(playeridmnrg[playerid], 0);
        
AddVehicleComponent(mnrg[playerid], 1079);
        
//New variable to assign object instance id to.
        
new lpObj;
        
//Create specified object at players pos.
        
lpObj CreateObject19076XYZ0.00.00.0 );
        
        
//Attach the object's instance id to the vehicle.
        
AttachObjectToVehiclelpObjmnrg[playerid], 0.00.01.00.00.00.0);
    }
    return 
1;

Reply
#8

Quote:
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(13370.00.00.00.00.00.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:XFloat:YFloat:Z;
    
GetPlayerPos(playeridXYZ);
    if(
GetPlayerMoney(playerid) >= 0)
    {
        new 
mnrg[MAX_PLAYERS];
        
GivePlayerMoney(playerid, -0);
        
mnrg[playerid] = CreateVehicle(560XY190.0, -1, -1100000000);
        
PutPlayerInVehicle(playeridmnrg[playerid], 0);
        
AddVehicleComponent(mnrg[playerid], 1079);
        
//New variable to assign object instance id to.
        
new lpObj;
        
//Create specified object at players pos.
        
lpObj CreateObject19076XYZ0.00.00.0 );
        
        
//Attach the object's instance id to the vehicle.
        
AttachObjectToVehiclelpObjmnrg[playerid], 0.00.01.00.00.00.0);
    }
    return 
1;


Not Attaching !!! Atfer Your tutorial !!!!! H E L P
Reply
#9

Quote:
Originally Posted by K4P3L_KUM4R
Посмотреть сообщение
Not Attaching !!! Atfer Your tutorial !!!!! H E L P
Well it must be something you're doing on your end (Which please note, is not my fault). I compiled & tested and it works fine for me:

Reply
#10

I Miss ? Some think Or What Is Tha Problem Can U Tell ME ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)