SA-MP Forums Archive
Attach Object - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Attach Object (/showthread.php?tid=298064)



Attach Object - K4P3L_KUM4R - 19.11.2011

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


Re: Attach Object - K4P3L_KUM4R - 19.11.2011

Double Post Sorry

Help Please Urgent


Re: Attach Object - KosmasRego - 19.11.2011

is it complying fine?


Re: Attach Object - K4P3L_KUM4R - 19.11.2011

yes complying fine


Re: Attach Object - GangsTa_ - 19.11.2011

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


Re: Attach Object - K4P3L_KUM4R - 19.11.2011

Change but Object Not Attaching To Car ?


Re: Attach Object - blewert - 19.11.2011

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;




Re: Attach Object - K4P3L_KUM4R - 19.11.2011

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


Re: Attach Object - blewert - 19.11.2011

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:




Re: Attach Object - K4P3L_KUM4R - 19.11.2011

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