Jump to content
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Sign in to follow this  
Tim Derks

[Working!] Policestation that functions like a Fire station

Recommended Posts

So guys, since this is working now, and I'll be uploading the script some day soon (hopefully), I'll just get you started on the preparations.   (PS. The original post is at the bottom of this one)


This will be divided into the following sections:

1. Placing VO's

2. Parking spot direction on startup.

3. Change script to your liking

4. Create command icons (if needed)


1. Placing VO's

So, when you are trying this, I'm assuming you know your way around the editor, and at least have some knowledge about scripting. This 'tutorial' assumes you use the LA mod as a base, but this can be done on other mods as well.


First of all, you need to add a controlpanel for the police station to your map, which can be placed anywhere. I'd recommend somewhere near the police station of course (Name this control panel 'police_station_controlpanel'.


Starting with the VO's. In the script as it is, created for my personal liking, it is set up like this:

 - 4 parking spots behind the police station. These spots are reserved for a specific vehicle type, not every car can park there. I set them up for 1 SUV, 1 van, and 2 CHP dodge chargers.

 - 2 parking spots at the donut place near the police station (were already there). These are reserved for a LAPD patrol car. 


 - All cars spawn at the beginning of the game

 - All personnel spawns at the beginning of the game and runs to their cars


Let's call the vehicles stated above "special" vehicles from now on, since they have their own parking spot.


The 3 parking spots in front of the police station are drop-off points. All vehicles carrying transports (criminals or civilians placed into police cars) will drive to one of these 3 parking spots in front of the police stations first. There they will release the criminals, which will walk into the police station as usual. 

From here on, the special vehicles will drive to their own personal parking space. If those parking spaces are already filled by other vehicles, or if the vehicle is not special, it will start a patrol after dropping off the prisoners. 


Parking spots

Now, as you can see, this means I added 4 new parking VO's. These can be placed by you anywhere you like. Be aware: The size of the VO doesn't determine where the vehicle parks, or what kind of vehicle will fit into it. the vehicle will always place its own center point over the center point of the VO.

After you placed the parking spots (you can decide to have more or less, the addition or removal is easy in the script.), you have to place a "turnto" VO in front of it. This decides what direction the parked vehicle will turn to when it has parked. It also is the first spot the vehicles drives to. (Drive to turnto VO > Turn to parking spot > Drive to parking spot > Turn to turnto VO). The easiest way to do this is to clone the parking spot itself and placing it in front of the parking spot.

Be sure to name these VO's properly, and write them down somewhere. It'd recommend something like "ps_park01" and some one. (PS being Police Station)


Spawn points

If you want your personnel to spawn at the beginning of the game, you need to create new spawn VO's for that.

Add a spawn VO and a "moveto" VO near every cluster of vehicles you have (so one for the cars at the donut shop, and one for the cars behind the PS, if you're doing the same as me).



To tell the game where the personnel for every vehicle should spawn (since you have multiple spawn VO's), you have to make another VO that completely covers the parking spot VO's. Be careful not to cover the "turnto" VO's with the squad VO, this could cause problems.


2. Parking spot direction on startup.

For some reason, determining the direction your cars are pointed towards on startup is a bit different from when they return to base. Your cars can only be placed pointing in the same direction as another object on the map. Now this is usually a gate from the firestation (on the LA mod map). These are placed in all directions: North, south, east and west. (Front FS1, Back FS1, Front FS2, Back FS2 if I'm correct).

If any of these gates does not match the direction you want your car to be pointing towards, you can add a object to the map that points in the right direction. I used a trashcan to direct the two units at the donut shop.

This is a bit of trial and error, because you don't know what the front of an object is, so just try placing the object and check which way the cars point, then you've got your front side of the object..



3. Changing the script to your liking

Start by deciding how many parking spots you want, where you want them, and above all: what cars should park in which spots. 

Go to "...\Emergency 4\Mods\Los Angeles Mod v2.1\Prototypes\Vehicles\03 LA Police" and find the prototype files of the cars you wish to use as your "special" cars.

In example: the CHP Dodge Charger's model is called "dodge_charger_chp.e4p". If you are unsure which model file you need, you can check in the editor.

Be sure to write all these down somewhere (in a .txt file would do).


Next the personnel.

Go to "...\Emergency 4\Mods\Los Angeles Mod v2.1\Prototypes\Persons\03 LA Police" and find the prototype files of the personnel you wish to spawn from the police station for your cars.

In example: the CHP Officer's model is called "chp_officer.e4p". Again, this can be found in the editor if you're not sure.

Write these down as well.


4. Create command icons

Now this is an optional bit. It's quite a bit work to get it done. It does look better, but it is not necessary for the game to work.

You would need a headshot of every unit you want a spawn button for on the control panel. (you can also just create a bit of white text in paint or photoshop if you want).

Aftert that, use this tool to create the command icon.

Place the resulting DDS files in "...\Emergency 4\Mods\Los Angeles Mod v2.1\Ui\Game\Icons\Commands" and make sure you name them properly. The tool will name them automatically. If your base file is called "unnamed", the output will be "unnamed_disabled", "unnamed_mouseover" and so on. The easiest way is to change the name of your base file into whatever unit you are using. So if it's a headshot of an officer, call the basefile "officer.jpg" (or any other supported file extention). 

(This only can be done when you've got the script I'll provide) Go to the script file that includes the spawning command for that specific unit, and look for this bit:

object VcmdCallEMT : CommandScript{	VcmdCallEMT()	{		SetCursor("alarm");		SetIcon("callemt");	}

If you've got your script ready, the 'VcmdCallEMT' bit should already be named for the unit you want, so in this case: "VcmdCallOfficer".

After that, change the SetIcon parameter to "officer". This should automatically use the right icon.





So, the things you should have done by now:

 - You placed an extra control panel

 - You placed all VO's for your new vehicles: Park VO's, turnto VO's, spawn VO's and squad VO's.

 - You determined which cars you want to be "special" and have written all their file names down.

 - You did the same for the personnel that should occupy these vehicles.

 - You made sure all your parking spots face in the same direction as the firestation gates, or you added an extra object that does point in the right direction.

 - (optional) You've created the command icons for all personnel you want to be able to spawn by clicking on a control panel.

 - (optional) You got excited because you can almost use this script  :happy:




Original post:

Hey guys,


At the moment I'm trying to create a script for the policestation to function in a similar way as the firestation. Therefor I've made copies of LAFireStation and LAFireStationStart, renamed them and started editing. So far so good, but now I'm getting an error I just can't get my mind on. The error is, as stated in the title, as following: "Error: Symbol Spawn is not defined in current scope". This error takes place in LAPoliceStation.script.


I've been comparing the script to the firestation version of that script, but I just don't see the problem. Hopefully someone can help.



?(_LAPoliceStation9d2c5): Error: Symbol Spawn is not defined in current scope ?(_LAPoliceStation9d2c5):  FILE:mod:/scripts/game/command/LAPoliceStation.script9d2c5 LINE:865?(_LAPoliceStation9d2c5): !!!Dictionary position rewound... ?(_LAPoliceStation9d2c5): !!!Error recovered!!!?(_LAPoliceStation9d2c5): Error: Symbol Spawn is not defined in current scope ?(_LAPoliceStation9d2c5):  FILE:mod:/scripts/game/command/LAPoliceStation.script9d2c5 LINE:865?(_LAPoliceStation9d2c5): !!!Dictionary position rewound... ?(_LAPoliceStation9d2c5): !!!Error recovered!!!





I hope any of you can help me out.




PS, if any of the links don't work, let me know so I can fix them.

Edited by Tim Derks

Share this post

Link to post
Share on other sites

OK, I'm not seeing anything jumping out of the script itself that would cause the issue.


First suggestion: make sure what your constants point to exist on the map and are named correctly. I think it's caused by "if"s not finding what they need to in order to create the vector "spawn", thus it throws that error when it tries to place the person there.


So check these on the map: 

  • "policestation_spawn"
  • "spawn_police1"
  • "policestation_spawn2"
  • "police_squad01"
  • "police_squad02"
  • "police_squad03"

Share this post

Link to post
Share on other sites

First of all, thanks for taking the time to help me.


The constant points you stated all seem fine as far as I can see.

"spawn_police1" is used to spawn police cars from the garage. Could this cause a problem when I trie to spawn personnel from there?

Share this post

Link to post
Share on other sites

I don't believe dual-purposing it would harm anything, other than maybe causing things to get stuck should a vehicle and person try to spawn at the same time. I'll have to use a finer comb and see if I can find an issue.

Share this post

Link to post
Share on other sites

That would be great. I'm quite familiar with scripting, but pieces of code like the one below are a bit confusing to me, so I'm quite hesitant to change things in such code.

bool CheckTarget(GameObject *Caller, Actor *Target, int childID){   if (!Caller->IsValid() || !Target->IsValid() || (Caller->GetID() != Target->GetID()))      return false;   return true;}



Great news! I got it to work!

I didn't script the functionality to spawn personnel yet (by clicking on a button on the controlpanel), that was limiting the spawning.


Now I've got some questions on how to perfect my policestation:


  1. The controlpanel shows as a red dot on the map, like a firetruck would. Is there a way to change this to blue, or remove it completely?
  2. What is the easiest way to "direct" a car, so it spawns with it's nose facing the right direction?

Share this post

Link to post
Share on other sites

Hey guys, just restarting this topic now, seeing if I can get it all together.


I'm working on the LAToPoliceStation script right now, since I'm stuck on the other two.


In here I'm trying to achieve the following:

- 3 parking spaces in front like default, for temporary parking while dropping off criminals (this is for another time)

- 4 in the back, 1 for an SUV, 1 for a Van, 2 for a CHP charger.

- 2 at the donut shop, default settings.


I'm trying to get the 4 spaces in the back to work right now, which has taken a lot of work so far.

I've got the script bug free (AFAIK), but for some reason, those 3 specific vehicles refuse to park. When I hit the ToPolicestation button, they just keep on driving to where I sent them (or just remain stationary). They do however turn off sirens, blue lights etc.

They refuse to go to their assigned parking spaces, but no errors.

It's quite a tricky script, especially since the vehicles should go to the front 3 parking spaces when they have criminals in the back, and just go to the back when they don't. When I have an SUV with criminals in it, and hit ToPolicestation, the criminals get out and start walking to the PS by themselves.

Weird behaviour.


I've got the script here for those who are interested in having a look.


I really appreciate any help I get, I could use it.






I think I narrowed the problem down to the piece of code below that is available in the original script. I'm not sure how I should incorporate this into my own script.

This piece of code normally starts when the caller has found a parkingspace.

When I just copy it in like this, and change VO_TURNTO to the correct VO, it gives me an error that states "?(_LAToPoliceStationa8378): Error: illegal pointer to class object GetActor(0) 0x0 4"


I hope someone can help me.

					Vector PD = l1.GetActor(0)->GetPosition();					Vector PD2 = l1.GetActor(0)->GetPosition() + Vector(280,-280,0);					ActorList l8 = Game::GetActors(VO_TURNTO);					Vector TurnTo = l8.GetActor(0)->GetPosition();					Game::FindFreePosition(Caller, PD);					Audio::PlaySample3D(SND_TOSTATION, v.GetPosition());					if (!ToDonut)					{						v.PushActionMove(ACTION_NEWLIST, PD);						v.PushActionTurnTo(ACTION_APPEND, TurnTo);					} else					{						v.PushActionMove(ACTION_NEWLIST, PD2);						v.PushActionTurnTo(ACTION_APPEND, PD + Vector(320,-320,0));						v.PushActionWait(ACTION_APPEND, 0.5f);						v.PushActionMove(ACTION_APPEND, PD);					}					v.PushActionWait(ACTION_APPEND, 1.5f);					v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 2, false);					PersonList transports = v.GetTransports();					if (!ToDonut && transports.GetNumPersons() > 0)						v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 1, false);

Share this post

Link to post
Share on other sites

Alright, to finish this topic of once and for all: It's working, thanks to the great support of everyone on this forum!


The functionality's are as follows:

- 4 extra parking spaces behind the police station, set parking spots for a LAPD SUV, LASD van and 2 CHP chargers. These all spawn on startup, including personnel, just like the firestation.

- The 2 parking spaces at the donut store are now set for 2 LAPD crown vics. These also all spawn on startup, including personnel.

- The 3 front parking spaces are just for dropping off criminals.


So lets call the SUV, van, CHP chargers and LAPD crown vics the "special" cars, all other police vehicles are defaults. When a special car gets the ToPS command it directly goes to it's own set parking space. When one of those special cars has a transport inside, a criminal, it will go to one of the available parking spaces in front of the police station. When no parking space is available, the vehicle will start a patrol and will try going to the police station a minute later again.

When there is a free spot, the special vehicle will park there, drop off the criminals, wait about 6 seconds and will then drive to it's own personal set parking space.


When a default vehicle gets sent to the station, it will always drive to one of the front 3 parking spaces. This vehicle will also start a patrol and try again when no space is available. When the default vehicle has a criminal in it, it will drop off the criminal and start a patrol after 6 seconds. When it doesn't have transports, it just drives to the police station and starts a patrol 6 seconds later. (I know this is a bit strange, not starting a patrol immediately, but just imagine they have to fill out some paperwork and get some coffee before they hit the road again.


Things I'm still thinking about implementing

I might make some vehicles start a patrol automatically on startup, so I wouldn't have to start those mysef, but that's for later on.


If enough people are interested in such a police station, I might make a tutorial how to do it yourself. But be warned, it's a lot of work, and it isn't easy.

Just let me know what you think!

Share this post

Link to post
Share on other sites

Sounds good. I wouldn't bother making a tutorial though, I would assume that it would be far too complicated for most people on here. It wouldn't really be worth spending the time writing it. Plus, most on here expect others to do everything for them. I can't imagine too many people would spend the time reading a tutorial and editing the script themselves.


IF you were planning on sharing, IMO it would be much quicker and easier for you to just release the edited scripts, but that's up to you really.

Share this post

Link to post
Share on other sites

Well if that was an option, I would, but you have to add VO's to the map as well. Maybe I'll release scripts that require some personal input before they work and a small tutorial on how to edit the scripts

Share this post

Link to post
Share on other sites

Well if that was an option, I would, but you have to add VO's to the map as well. Maybe I'll release scripts that require some personal input before they work and a small tutorial on how to edit the scripts

You know, I forgot about having to add some new VOs! It would allow personalisation as well, the VOs could be placed where ever the user wanted.That would work, but you'd be surprised at how little the majority on here are willing to do when it comes to things like this.

Share this post

Link to post
Share on other sites

I can place the VO's, I would love to have the script. Making scripts and models is the only thing I am unable to do



Share this post

Link to post
Share on other sites

I,m gonna look it over and try to use it after I have all of my units done. I will then work on the map adding my VO's.

Tech Station sounds great, I was gonna try my hand at that, if it wasn't gonna be too complicated; I wanted my

tow truck/rollbacks to come from on the map.



Share this post

Link to post
Share on other sites

I'm kind of interested in having the script too. Lost the files we were working on which had spawning police officers too. Will be following this topic when you get everything finalized.

Share this post

Link to post
Share on other sites

Well, this is it.

There are 4 script files in the zip file:







All 4 are based on the LA Mod.

BE WARNED: These script should not be simply copied over to your scripts folder. They are simply examples and guides on how to edit your own scripts. (This goes for the two firestation scripts and the move script). 


You DO have to copy over the ToPoliceStation script, but first you DO have to edit it.

These changes are all explained with comments inside the scripts.


Credits go to Hoppah for making the LA Mod and enabling us to continue modding with it.

Also much thanks to ItchBoy for helping me out and sending me some examples.

Finally, thanks to everyone who replied to my many topics.


To conclude it: Thanks for all the support, good luck on editing your scripts, and if you've got any questions: let me know.


PS. I'm sorry if the comments are a bit vague, I assumed that whoever tries this does know quite a bit about scripting.


Good luck guys!


Share this post

Link to post
Share on other sites

One would say: No replies, no trouble.

On the other hand, it could mean it's just too complicated or too much work.


Let me know what's going on guys, an luck on getting it working? Any nice setups? I'm curious about what you're all doing.

Share this post

Link to post
Share on other sites

I don't know much about scripting, but I am learning more and more. Just one thing that I want to change and that is the patrol part. It's fine if they have a prisoner and they are waiting to drop them off. I want them to go to their designated spot afterward and standby, like in North Creek Mod. I will either use Xplorer's original 4x4 mod or North Creek. So how do I stop them from patrolling?



Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...