Noobish question
#1

Hello. Do I add staticvehicles in the gamemode.pwn or in some other file?
I am using Raven Roleplay
Reply
#2

Gamemode.
Reply
#3

Ok and will it automaticly give a new ig id? or will it add ID 1 and then messup all locks and stuff?
Reply
#4

it depends on where you add the vehicles. if you hardcoded their IDs, and add more vehicles after the others in the gamemode script, then they will get assigned an increasing ID each. the best trick is to use an array to store each single vehicles' ID, and access it via that "pointer". look at this:
Код:
AddStaticVehicle(425,blabla);//hunter = vehicle 1 (the 1 got retiurned by the AddStaticVehicle, but its not stored anywhere, so its almost impossible to retrieve this hunters' ID ingame)
AddStaticVehicle(522,blabla);//nrg = vehicle 2
AddStaticVehicle(415,blabla);//cheetah = vehicle 3
AddStaticVehicle(411,blabla);//infernus = vehicle 4
//...
AddStaticVehicle(415,blabla);//another cheetah = vehicle 5 (the 5, returned by AddStaticVehicle here, gets stored into the Car[5] cell, where you may access it anytime later by using like Car[5]
as you see, the last vehicle, the cheetah, gets assigned the id 5. thats the "hardcoding" style, its a bad scripting manner. by using an array as a pointer like this:
Код:
//at your scripts top, create the array for vehicles, so a cell can point to the !real id.
new Cars[2000];

//and now the vehicles from above, but slightly changed:
Cars[000]=AddStaticVehicle(425,blabla);//hunter = vehicle 1
Cars[001]=AddStaticVehicle(522,blabla);//nrg = vehicle 2
Cars[002]=AddStaticVehicle(415,blabla);//cheetah = vehicle 3
Cars[003]=AddStaticVehicle(411,blabla);//infernus = vehicle 4
//...
Cars[100]=AddStaticVehicle(415,blabla);//another cheetah = vehicle 5
as you see, you may mess around with the orders when creating the vehicles, the Car[100] will always point to the second cheetah.
btw i used the [100] for the demonstration cheetah, but its a good idea to keep the order intact (making it Car[004] in this case).
you also can use different arrays indeed like CivilianCar[] and CopCar[] etc...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)