SA-MP Forums Archive
Attach Objects to Vehicles and Dettach - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Attach Objects to Vehicles and Dettach (/showthread.php?tid=194936)



Attach Objects to Vehicles and Dettach - tony_fitto - 30.11.2010

Hey All SA:MP guys.

I'm working on a Siren for the Premier with the siren from 0.3c.

I use AttachObjectToVehicle works correct, but how can I delete the siren after i added it?


Re: Attach Objects to Vehicles and Dettach - Zamaroht - 01.12.2010

Use DestroyObject


Re: Attach Objects to Vehicles and Dettach - tony_fitto - 01.12.2010

I'v tested it but i dont get it to work :S

Using this code
Код:
if(strcmp(cmd, "/siren", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        new VID;
			VID = GetPlayerVehicleID(playerid);
	        if(HideBriefcase[playerid] == 0)
	        {
	            new TO = CreateObject(18646, 1.0, 1.0, 1.0, 0, 0, 0);
             	//AttachObjectToVehicle(TO, VID, -0.43, 0.0, 0.785, 0.0, 0.1, 0.0); // tak - Premier
             	//AttachObjectToVehicle(TO, VID, 0.0, 0.75, 0.275, 0.0, 0.1, 0.0); // Inside - Premier
	        	HideBriefcase[playerid] = 1;
			}
			else if(HideBriefcase[playerid] == 1)
	        {
	            new TO = DestroyObject(18646);
	            AttachObjectToVehicle(TO, VID, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0);
	        	HideBriefcase[playerid] = 0;
			}
		}
		return 1;
	}



Re: Attach Objects to Vehicles and Dettach - Krypton - 01.12.2010

you dont need "else if" , else is enough


Re: Attach Objects to Vehicles and Dettach - Krypton - 01.12.2010

if(strcmp(cmd, "/siren", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new VID;
VID = GetPlayerVehicleID(playerid);
if(HideBriefcase[playerid] == 0)
{
new TO = CreateObject(18646, 1.0, 1.0, 1.0, 0, 0, 0);
//AttachObjectToVehicle(TO, VID, -0.43, 0.0, 0.785, 0.0, 0.1, 0.0); // tak - Premier
//AttachObjectToVehicle(TO, VID, 0.0, 0.75, 0.275, 0.0, 0.1, 0.0); // Inside - Premier
HideBriefcase[playerid] = 1;
}
else if(HideBriefcase[playerid] == 1)
{
DestroyObject(TO);

HideBriefcase[playerid] = 0;
}
}
return 1;
}


Re: Attach Objects to Vehicles and Dettach - tony_fitto - 01.12.2010

Know that part with else, but I think it's better to do it like this, Anyways I tested the last one, which I didn't get to work, Get an Error on it :S

Код:
error 017: undefined symbol "TO"
Error on DestroyObject :S


Re: Attach Objects to Vehicles and Dettach - DVDK - 01.12.2010

You need to create TO outside of your command, like above it or something.


Re: Attach Objects to Vehicles and Dettach - ExeC - 01.12.2010

Top of your gamemode:
pawn Код:
new TO;
pawn Код:
if(strcmp(cmd, "/siren", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
      new VID;
      VID = GetPlayerVehicleID(playerid);
      if(HideBriefcase[playerid] == 0)
      {
         TO = CreateObject(18646, 1.0, 1.0, 1.0, 0, 0, 0);
         AttachObjectToVehicle(TO, VID, -0.43, 0.0, 0.785, 0.0, 0.1, 0.0); // tak - Premier
         AttachObjectToVehicle(TO, VID, 0.0, 0.75, 0.275, 0.0, 0.1, 0.0); // Inside - Premier
         HideBriefcase[playerid] = 1;
         }
         else if(HideBriefcase[playerid] == 1)
         {
         DestroyObject(TO);

         HideBriefcase[playerid] = 0;
       }
     }
     return 1;
     }



Re: Attach Objects to Vehicles and Dettach - Rainbow_Six - 01.12.2010

How did you get the coords from inside?


AW: Re: Attach Objects to Vehicles and Dettach - XCarBOn - 04.12.2010

Quote:
Originally Posted by ExeC
Посмотреть сообщение
Top of your gamemode:
pawn Код:
new TO;
pawn Код:
if(strcmp(cmd, "/siren", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
      new VID;
      VID = GetPlayerVehicleID(playerid);
      if(HideBriefcase[playerid] == 0)
      {
         TO = CreateObject(18646, 1.0, 1.0, 1.0, 0, 0, 0);
         AttachObjectToVehicle(TO, VID, -0.43, 0.0, 0.785, 0.0, 0.1, 0.0); // tak - Premier
         AttachObjectToVehicle(TO, VID, 0.0, 0.75, 0.275, 0.0, 0.1, 0.0); // Inside - Premier
         HideBriefcase[playerid] = 1;
         }
         else if(HideBriefcase[playerid] == 1)
         {
         DestroyObject(TO);

         HideBriefcase[playerid] = 0;
       }
     }
     return 1;
     }

I tried the same but with neon lights.. Won't be dettached.