Home   Help Search Login Register  

Author Topic: Building script  (Read 1479 times)

0 Members and 1 Guest are viewing this topic.

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Building script
« on: 17 Sep 2007, 08:52:17 »
At weekend I tried to make a building script:
The player have to buld a roadblock with "sandbag" (WoodFence).

I get the position of player and add 1m to X coordinate and create a woodfence...
I know it's not the perfect solution, but in my situation, the player is watch for North, and it could be works, but didn't, because the sandbag created in random places... :( Once 2m behind the player and next time 3m left from player...etc.


Could anybody help me to create a general building script:
Parameters are the "vehicle" what the script build (eg: WoodFence) and the distance in meter from the player and the degree how the new object's direction will be...
And when script activated: the new object is created front of player (where player watch).

Please help me!
Fix bayonet!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Building script
« Reply #1 on: 17 Sep 2007, 09:14:41 »
["obj",distance,degree] execVM "LCD_buildobj.sqf"

Code: [Select]
private ["_objType","_pos","_dir"];

_objType = _this select 0;
_pos = player modeltoworld [0,_this select 1,0];
_dir = _this select 2;

_obj = _objType  createvehicle _pos;
_obj setdir _dir;

if (true) exitwith {};

exec it like i wrote above it :D

LCD OUT
« Last Edit: 18 Sep 2007, 08:21:45 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Building script
« Reply #2 on: 17 Sep 2007, 09:44:57 »
Thanks, I will check it!
Fix bayonet!

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Building script
« Reply #3 on: 18 Sep 2007, 07:36:35 »
LCD: Unfortunately, your script didn't work. (Nothing happened). But from your idea (modelToWorld) I made a working script. My script use the player direction too:



Code: [Select]
;Build script by bardosy
;thanks to LCD
;usage: ["classname",distance,degree] exec "buildscript.sqs"
;example: ["FenceWood",1.5,90] exec "buildscript.sqs"

_class = _this select 0
_distance = _this select 1
_degree = _this select 2

_pos = player modeltoworld [0,_distance,0]
_rb = _class createVehicle getPos player

_degr = getDir player
?(_degr>=180) : _degr = _degr - 180
_ndeg = _degr + _degree

_rb setDir _ndeg
_rb setPos _pos
Fix bayonet!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Building script
« Reply #4 on: 18 Sep 2007, 08:23:25 »
actualy... i had just 2 typos in da script (i forgot da underscore in two variables name...  ::)) shud work fine now if u still wana try my 1 :D

nd ur script seems 2 b fine 2 ;) :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta