Variables and work with them (Переменные и работа с ними)

For info on the site, community and 'battlefieldy' things
Post Reply
User avatar
OldGoodMan
Posts: 22
Joined: Thu Aug 30, 2012 6:40 am

Variables and work with them (Переменные и работа с ними)

Post by OldGoodMan »

а. Where can I read about variables and work with them?
For example the variable Var - what it is and how to treat it? )
I feel that it will be very helpful to me.
b. Where can I get the absolute coordinates of the object (rotation x, y, z)?

а. Где мне можно прочитать про переменные и работу с ними?
Например переменная Var - что это и с чем её едят? )
Я чувствую что мне это очень поможет.
b. Где я могу получить абсолютные координаты объекта (rotation x, y, z)?
exe
Posts: 60
Joined: Wed Feb 08, 2012 10:04 pm

Re: Variables and work with them (Переменные и работа с ними

Post by exe »

a. A good start is this site: http://www.velotech.net/battlefield/tutorials.php (Select "Using Conditional Statements" in the drop-down list)
Sadly the programming possibilities are very very limited in BF1942. The only way to start your code while playing is by pressing a certain key, see here

b. You can obtain this information with this code

Code: Select all

rem *** variables ***
var v_id
var v_Position_Vec

rem *** get the vehicle's ID which the player is currently using ***
player.vehicle -> v_id
rem *** activate that object ***
object.active v_id
rem *** get current position (vector) of this object ***
object.absolutePosition -> v_Position_Vec
But the problem is the command player.vehicle because it always returns the ID of the vehicle which is currently used by the player who joined last, I haven't found a way yet to call a specific player. If you only plan to code for Singleplayer it should work though.
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Variables and work with them (Переменные и работа с ними

Post by Diamondback »

exe wrote:a. A good start is this site: http://www.velotech.net/battlefield/tutorials.php (Select "Using Conditional Statements" in the drop-down list)
Sadly the programming possibilities are very very limited in BF1942. The only way to start your code while playing is by pressing a certain key, see here

b. You can obtain this information with this code

Code: Select all

rem *** variables ***
var v_id
var v_Position_Vec

rem *** get the vehicle's ID which the player is currently using ***
player.vehicle -> v_id
rem *** activate that object ***
object.active v_id
rem *** get current position (vector) of this object ***
object.absolutePosition -> v_Position_Vec
But the problem is the command player.vehicle because it always returns the ID of the vehicle which is currently used by the player who joined last, I haven't found a way yet to call a specific player. If you only plan to code for Singleplayer it should work though.
It has recently been found that the player.active command works in MP; however the command only accepts names with no spaces as arguments. My question is, In your code, the object.absolutePosition should return the position of the object where it spawns, and not where it currently is? Also, any way to get the position of a soldier on the field or does this code only works for PCOs? Don’t have a PC right now so I can’t test any code.
See my Strasbourg map project here.
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Variables and work with them (Переменные и работа с ними

Post by Diamondback »

Allright so, this code is confirmed to work in a local server, but it does not work online. This is based on the code that was posted above by exe. What I added was a few variables and most notably the v_locator variable equals the possible outputs of player.vehicle. player.vehicle entered without an argument in the Debugger returns your current player name, followed by your soldier skin. So for example if you enter that command while in Berlin and your team is the Russians, the output of player.vehicle in the console will be "Your nickname"RussianSoldier. So for me, it would be mambaRussianSoldier. Your nickname must not contain spaces or the code will not work, as russ and SkullKid pointed out.

Code: Select all

Var v_locator = mambaRussianSoldier
Var v_pos
player.vehicle -> v_locator
object.active v_locator
object.absolutePosition -> v_pos

if v_locator

debug.debugOutputMessage v_pos 1

else

endIf
See my Strasbourg map project here.
Post Reply