Elegy/Police Lights - 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: Elegy/Police Lights (
/showthread.php?tid=561466)
Elegy/Police Lights -
Aus - 03.02.2015
I'm trying to attach police lights to the roof of a car in my server, I'm pretty sure I'm doing everything correct but it doesn't seem to work. :/
If someone could help me that would be greatly appreciated! Will rep if you can help me
PHP код:
AddStaticVehicleEx(562,1295.4215,-984.8573,32.3540,91.0700,1,1,500);
SetVehicleNumberPlate(20,"Ohh Shit");
AttachObjectToVehicle(19419,20,0,0,0,0,0,0);
AddVehicleComponent(20,1172);
AddVehicleComponent(20,1026);
AddVehicleComponent(20,1027);
Cheers! -Aus
Re: Elegy/Police Lights -
Vince - 03.02.2015
This isn't how it works. You need to attach the
objectid, not a modelid. That means that the objects has to be created first. Secondly, you should really assign your vehicleids to a variable as well. Relying on assumptions (i.e. assuming that the vehicle will always have id 20 is considered shoddy coding). And lastly 0,0,0 denotes the center of the floor of the car. The object will not magically adjust to your desired position. You will probably want to move it up first (increase Z a bit), then a bit forward (increase Y a bit) and perhaps a bit the left (decrease X a bit).
Re: Elegy/Police Lights -
Aus - 03.02.2015
Thanks Vince. I'll have a look into it again and use your advice. I have to admit my coding is extremely crappy. Only new to it.
Just curious, how would I get the object ID of that model :/
Sorry for any inconvenience.
Re: Elegy/Police Lights -
CalvinC - 03.02.2015
You can look up object id's in a map editor, or a website.
http://gta-sa-mp.de/forum/index.php?page=Objects
Re: Elegy/Police Lights -
Mamal75 - 03.02.2015
pawn Код:
new Veh;
new Obj;
Veh = AddStaticVehicle(… );
Obj = CreateObject(…);
AttachObjectToVehicle(Obj, Veh, ……);
Re: Elegy/Police Lights -
Aus - 03.02.2015
I finally got it! Thanks guys for the help!