Jump to content
Sign in to follow this  
R.Martinez

Problem with setPos

Recommended Posts

In a custom map I have a script that adds an action to a helicopter that uses the setPos command on the player that uses the action. It is intended that he uses this command while riding in a helicopter to 'teleport' to a different location, the player only, not the helicopter.

The problem I'm having is that the player is sent to this location for a fraction of a second then finds himself again back in the chopper.

If the player hosting the mission uses the action it works fine and gets teleported to that location but it doesn't work for the other players. Any ideas on how to fix this?

Share this post


Link to post
Share on other sites

I don't have much experience scripting for MP, but this might work...

Try broadcasting the setpos command globally so that it gets executed on the host machine, using this code instead of where you have the setpos command:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit setVehicleInit "this setpos place"; processInitCommands; clearVehicleInit _unit;

_unit = the unit that you want to teleport

place = the place you want to teleport to (must be a global variable).

Share this post


Link to post
Share on other sites

that worked perfectly, now I'm trying the same thing but to set a variable within an object:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player setVehicleInit "this setpos [getPos this select 0, getPos this select 1, (getPos this select 2) - 2]; this setVariable ["parajump", true]";

processInitCommands;

clearVehicleInit player;

But I get an error saying

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">'... this setVariable [|#|'

Error Missing ]

I used your code for the setPos command, using player as the _unit and that worked, teleporting the player to the area. But when I add the setVariable to the init line I get this error.

To make sure the syntax was correct for the setVariable part I tried adding it to the init line of a unit in a separate mission. And got no errors, what is missing in that code?

Share this post


Link to post
Share on other sites

You used the quotes incorrectly. When you use " to start a string, then as soon as the game sees the next ", the string will end.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player setVehicleInit "this setpos [getPos this select 0, getPos this select 1, (getPos this select 2) - 2]; this setVariable ["parajump", true]";

processInitCommands;

clearVehicleInit player;

So in that case it will end the string before the word parajump.

You can use two double quotations if you need a string inside a string, so this should work:

Quote[/b] ]player setVehicleInit "this setpos [getPos this select 0, getPos this select 1, (getPos this select 2) - 2]; this setVariable [""parajump"", true]";

processInitCommands;

clearVehicleInit player;

Notice the double 'double quotes' around the word parajump.

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  

×