Where to attach objects to vehicle
#1

where do i put the code because i tried putting it in and then every car i got it the object follwed me to it :S i only want it on certain static vehicles
im guessing it wouold go in my main gamemode
it also doesnt work unless i get in the car then it shows up

can someone explain where to put every bit of the code
my codes are:

pawn Code:
new object = CreateObject( 18646,0,0,0,0,0,0,80 ); // <iVO>
AttachObjectToVehicle( object, GetPlayerVehicleID(playerid), 0.370000, 0.000000, 0.679999, 0.000000, 0.000000, 0.000000 ); // <iVO>
much help apreciated
Reply
#2

anyone
Reply
#3

pawn Code:
if (strcmp("/attachobj", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerInAnyVehilce(playerid)) return SendClientMessage(playerid, -1, "You must be in a vehicle to use this command!");
        new object = CreateObject( 18646,0,0,0,0,0,0,80 ); // <iVO>
        AttachObjectToVehicle( object, GetPlayerVehicleID(playerid), 0.370000, 0.000000, 0.679999, 0.000000, 0.000000, 0.000000 ); // <iVO>
        return 1;
    }
This could be an example on how you could use it OnPlayerCommandText.
Reply
#4

i dont want it by command i want it so certain cars that are parked up that i have assigned will get it
Reply
#5

Quote:
Originally Posted by [LHT]Bally
View Post
i dont want it by command i want it so certain cars that are parked up that i have assigned will get it
Oh okay I'll make a simple example code on how you can do it.
Reply
#6

Okay simplest way possible is to make an array with the max cars to have it

pawn Code:
new Specialcars[30];
Then define these cars under OnGameMode init as such

pawn Code:
Specialcars[0] = CreaveVehicle();
Then under

public OnVehicleSpawn(vehicleid)

write

pawn Code:
public OnVehicleSpawn(vehicleid)
{
     if(Specialcars == vehicleid)
     {
          AttachObjectToVehicle();
      }
  return 1;
}
NOTE: I'm not very good at explaining so anyquestions just ask and i'll answer them
Reply
#7

EDIT: Nevermind someone added it before me
Reply
#8

Quote:
Originally Posted by SpiritEvil
View Post
This one goes OnGameModeInt() (or OnFilterScriptInt in case it's a filterscript).

pawn Code:
new object = CreateObject( 18646,0,0,0,0,0,0,80 );
    new veh1 = AddStaticVehicle(modelid, x, y, z, angle, color1, color2); // replace these to your needs
    new veh2 = AddStaticVehicle(modelid, x, y, z, angle, color1, color2); // replace these to your needs
    AttachObjectToVehicle( object, veh1, 0.370000, 0.000000, 0.679999, 0.000000, 0.000000, 0.000000 );
    AttachObjectToVehicle( object, veh2, 0.370000, 0.000000, 0.679999, 0.000000, 0.000000, 0.000000 );
    //repeat this for all the vehicles you want to attach this object to
1. Wgt make your code over and over again when you can use an array?

2. Why dont you it on vehicle spawn its more efficent i've heard.

3. Cant think of a 3...
Reply
#9

Well I guess your method was smarter and quicker but that was the only one I could think of at the moment.
Reply
#10

anyone have teamviewer to help me ?

because my vehicles arent used like addstatic vehicle they are saved in a include
Reply
#11

Sure send me your details in a PM
Reply
#12

pmed
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)