OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: myke13021 on 15 Jan 2004, 00:49:05

Title: Creating diff patrols with script...help!
Post by: myke13021 on 15 Jan 2004, 00:49:05
hey scripting gods (and goddesses, if present)

i got a little prob...i would like to use a script to insert diff patrols on a map using the createunit command. i alread know about the group problem which is discussed in another thread and i followed instructions described there to get an empty group. I created a unit and inserted into his init field: GroupAlpha=group this; deletevehicle this
as far as good...next i made a trigger with the following on activation:
["INFANTERY", "patrol1", "GroupAlpha"] exec "patrol.sqs"
the script goes as this:

; get the parameters given
_type = _this select 0
_pos = _this select 1
_group = _this select 2

; check which patrol to create
?(_type == "SPETZNATZ"): Goto "Spetznatz"
?(_type == "RPGPATROL"): Goto "RPGPatrol"
?(_type == "INFANTERY"): Goto "Infantery"
?(_type == "SNIPER"): Goto "Sniper"

; No type was found so alert creator theres a typo
_errorText = Format["ERROR: INVALID TYPE %0", _type]
Hint _errorText
Exit

; creating Spetznatz Patrol
#Spetznatz
"SoldierESaboteurPipe" CreateUnit [GetMarkerPos _pos, _group, "", 0.8, "CAPTAIN"]
"SoldierESaboteurPipe" CreateUnit [GetMarkerPos _pos, _group, "", 0.7, "LIEUTENANT"]
"SoldierESaboteurPipe" CreateUnit [GetMarkerPos _pos, _group, "", 0.6, "SERGEANT"]
"SoldierESaboteurPipe" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "CORPORAL"]
"SoldierESaboteurPipe" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierESaboteurPipe" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierESaboteurPipe" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierESaboteurPipe" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
exit

;creating RPG Patrol
#RPGPatrol
"OfficerE" CreateUnit [GetMarkerPos _pos, _group, "", 0.8, "LIEUTENANT"]
"SoldierEMG" CreateUnit [GetMarkerPos _pos, _group, "", 0.7, "SERGEANT"]
"SoldierELAW" CreateUnit [GetMarkerPos _pos, _group, "", 0.6, "CORPORAL"]
"SoldierELAW" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierEMedic" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierEMG" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierELAW" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierELAW" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
exit

;creating Inf Patrol
#Infantery
"OfficerE" CreateUnit [GetMarkerPos _pos, _group, "", 0.8, "LIEUTENANT"]
"SoldierEMG" CreateUnit [GetMarkerPos _pos, _group, "", 0.7, "SERGEANT"]
"SoldierELAW" CreateUnit [GetMarkerPos _pos, _group, "", 0.6, "CORPORAL"]
"SoldierEB" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierEMedic" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierEB" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierEB" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
"SoldierEB" CreateUnit [GetMarkerPos _pos, _group, "", 0.5, "PRIVATE"]
exit

;creating Sniper Patrol
#Sniper
"SoldierESniper" CreateUnit [GetMarkerPos _pos, _group, "", 0.9, "CAPTAIN"]
"SoldierESniper" CreateUnit [GetMarkerPos _pos, _group, "", 0.8, "LIEUTENANT"]
"SoldierESniper" CreateUnit [GetMarkerPos _pos, _group, "", 0.7, "SERGEANT"]
"SoldierESniper" CreateUnit [GetMarkerPos _pos, _group, "", 0.6, "CORPORAL"]
exit

as you see the script should create a patrol of give type but it doesn't...where's the error?
What did i wrong? Is anything in this script that could work?
Please help me, i would pray to you for the rest of my life if you do ;-)
Title: Re:Creating diff patrols with script...help!
Post by: deaddog on 15 Jan 2004, 00:55:00
You are passing the groupname as a string, which is not valid.  A string is a string and a group is a group.  Do this instead:

["INFANTERY", "patrol1", GroupAlpha] exec "patrol.sqs"
Title: Re:Creating diff patrols with script...help!
Post by: macguba on 15 Jan 2004, 00:55:42
Should it be

getMarkerPos "_pos"

Edit:  kinda the opposite comment from deaddog's ...

Edit edit:  go with deaddog
Title: Re:Creating diff patrols with script...help!
Post by: deaddog on 15 Jan 2004, 00:58:43
Yeah, the marker name is correct.  Marker names are strings.  I didn't see anything else wrong (quick glance) except infantry is misspelled :)  Not that it matters  ;D

*edit*

I mean that getmarkerpos _pos is correct.
Title: Re:Creating diff patrols with script...help!
Post by: myke13021 on 15 Jan 2004, 01:00:08
omg...so f***in simple i didn't recognized it....and so fast the answer.....thx a lot deaddog......maybe i think i'm too stupid for this  ;D

(note for myself: add deaddog to the credits in mission for his help


imo closed...thx again
Title: Re:Creating diff patrols with script...help!
Post by: deaddog on 15 Jan 2004, 01:03:13
Quote
......maybe i think i'm too stupid for this

Not at all.  It just takes practice and making a lot of mistakes.

An expert is someone who has made all the mistakes :)

(No, I'm not claiming I'm an expert)
Title: Re:Creating diff patrols with script...help!
Post by: macguba on 15 Jan 2004, 01:18:13
I knew I should have kept my mouth shut. :P
Title: Re:Creating diff patrols with script...help!
Post by: myke13021 on 15 Jan 2004, 01:37:25
hmm...now by thinking over the script....does it matter if the script is executed on server AND on clients? or would i get multiple patrols insted of just one?....and if yes...how do i prevent this?

sry for beeing a noob  :-[