Jump to content
Sign in to follow this  
DeadNuts

Help with funny little "mortar ride" script

Recommended Posts

One of the servers I frequent has a admin that likes to run custom scripts via the debug console between serious missions from time to time. Stupid but fun things like dog followers or shooting rpg rounds from your gun via an addEventhandler. I was inspired enough to try my hand at some basic coding and came up with the following:

//==========START OF CODE=================

//spawns pod launcher with return function at stand

mort = "B_Mortar_01_F" createVehicle getPos player;
mort setPosATL (player modelToWorld[0,3,0]);
pod9991 = "Land_Pod_Heli_Transport_04_covered_F" createVehicle getPos player;
pod9991 setPosATL (player modelToWorld[0,10,0]);
pod9991 allowDamage false;
stand9991 = "Land_InfoStand_V1_F" createVehicle getPos player;
stand9991 setPosATL (player modelToWorld[4,3,0]);
stand9991 addAction["return carpet", {pod9991 setPosATL (stand9991 modelToWorld[0,10,0]);}];

mort addEventHandler ["Fired", { _null = _this spawn
{ missile = _this select 6;

podref = nearestObject [player, "Land_Pod_Heli_Transport_04_covered_F"];

waitUntil {

podref attachto [missile,[0,-4,1.3]];

}; }; }];

//============END OF CODE=================

 

What it is supposed to do:
- Spawns mortar, taru pod and stand at player location
- Firing mortar attaches the pod to mortar round and allows players to "ride" it
- stand has a return function that teleports the pod back

 

Works perfectly in the editor and switching between playable units... testing online via a hosted game with friend....not so much. If I run script locally and friend enters the pod they teleport to a far corner of map during the mortar round flight and teleport back when the round impacts. If I run globally and friend enters the pod *he* spawned I can use his mortar and the flight effect works for him (pod teleports away from my perspective and teleports back to impact). I have a very basic understanding of the whole server/global/local running of scripts and from what can gather it's got something to do with the addEventHandler "fired" for mortar only being local to the player that spawned it regardless of how the script is run. Running it on the server side had the same effect as local, I assume this is because it was a hosted game?

 

Is what I'm trying to accomplish even possible via running with the debug console? Is there is issue with the code itself? Would running the script server side with a actual dedicated server and not via a hosted game give the desired effect?

 

Below is a quick youtube video of it in the editor:
https://www.youtube.com/watch?v=zQYaJIiRMq0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×