Jump to content
Sign in to follow this  
AKK

Createunit identities/names?

Recommended Posts

Ok. For starters yes I did a search and found nothing to help me. I am a major (or private ;) ) newbie and so far only understand enough of scripting to manipulate others scripts (sort of as you can see).

my question is this. I am creating multiple units in a scenario. I only want them to last for so long and then disapear thus keeping game lag to just that scenario. I have accomplished this with the "deletevehicle" command in waypoints, but only when I have all units on the field and have named them indavidualy.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; This script creates a NVA patrol (taken from TJ's Medivac)

_obj = _this select 0

#start

"SEBNAM_vcrecon" createUnit [_obj,_obj,"",0.1,"PRIVATE"]

"SEBNAM_vcrecon" createUnit [_obj,_obj,"",0.1,"PRIVATE"]

"SEBNAM_vcrecon" createUnit [_obj,_obj,"",0.1,"PRIVATE"]

"SEBNAM_vcrecon" createUnit [_obj,_obj,"",0.1,"PRIVATE"]

exit;

Ok this works great as is but as you can see none of the units have names. Now when I change it to this

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"SEBNAM_vcrecon" createUnit [_obj,_obj,"w11 = this",0.1,"PRIVATE"]

I get an error in the game saying that 0 elements provided expected 3. It says this for all the units in the script that I have named. rock.gif??

Please help. Please help. please help.

thanks

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"SEBNAM_vcrecon" createUnit [_obj,_obj,"w11 = this",0.1,"PRIVATE"]

Assuming that _obj is both position and group (how this is possible is beyond me)

Anyway.

you need to rewrite it

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">tmpSoldier[] //or how you declare an array

"SEBNAM_vcrecon" createUnit [_obj,_obj,"tmpSoldier = this",0.1,"PRIVATE"]

w11 = tmpSoldier

"SEBNAM_vcrecon" createUnit [_obj,_obj,"tmpSoldier = this",0.1,"PRIVATE"]

w12 = tmpSoldier

OFPEC seems to be down so I can't find the script done by Doolittle, so this might not work either, perhaps someone else can fill me in here?

Share this post


Link to post
Share on other sites

I don't think I can help withactive constructive info, but maybe by passive related: I'm having related problems, I can't seem to setface on created units. I think both our problems are syntax, and as Taurus mentions, position and group = same is odd.

I'm trying to setface, and this is what I have:

"uce_r_kuffiyasoldier" createunit [getpos enforce, def, "joe=this; this setface {face23}"]; deletevehicle dud

This creates a unit, groups him to a sldier hiding in a corner of the map, and then deleets that soldier. I think AKK might just have a syntax problem (I can't set a face, this code seems ignored).

Wish I could help.

Share this post


Link to post
Share on other sites

The_Taurus

Quote[/b] ]Anyway.

you need to rewrite it 

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">tmpSoldier[] //or how you declare an array

"SEBNAM_vcrecon" createUnit [_obj,_obj,"tmpSoldier = this",0.1,"PRIVATE"]

w11 = tmpSoldier

"SEBNAM_vcrecon" createUnit [_obj,_obj,"tmpSoldier = this",0.1,"PRIVATE"]

w12 = tmpSoldier

Tried it and it still gave me the same error "0 provided, expected 3" sad_o.gif

I imagine that this will end up being referenced in the init file but as of right now doodly. thanks anyway.

Share this post


Link to post
Share on other sites

WTS ownz j00

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">soldi1 = []

"SoldierWLAW" createUnit [_rspwn1, _group1,"soldi1=this", 0.5, "CORPORAL"]

w11=soldi1

This works, you need to have an respawn position and a group, it can not be the same.

Share this post


Link to post
Share on other sites

biggrin_o.gif Boy I really am a freekin noob. Why the previouse script works as is and not with names I don't know?? But I got it to work as such

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; This script creates a NVA patrol

#start

"SEBNAM_nvsoldier" createUnit [getpos gamelogic1,"nvasquad1",0.1,"PRIVATE"]

"SEBNAM_nvMG" createUnit [getpos gamelogic1,"nvasquad1,"",0.1,"PRIVATE"]

exit

Thanks a bunch Taurus I havent tried what you last posted but I pasted it in my unit reference scripts all the same.

I figure that after screwing up enough good scripts and having to fix them I might have a handle on this stuff. I wish I realy understood scripting.I am just too hands on or "kenetic".I guess thats why I am a carpenter tounge_o.gif

Share this post


Link to post
Share on other sites

Hey no problem smile_o.gif

But, as far as the reference manual go the first of your two createUnits shouldn't work crazy_o.gif

e.g.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"SEBNAM_nvsoldier" createUnit [getpos gamelogic1,"nvasquad1",0.1,"PRIVATE"]

type createUnit unitInfo

Operand types:

type: String

unitInfo: Array

Compatibility:

Version 1.34 required.

Type of returned value:

Nothing

Description:

Create unit of given type . Format of unitInfo is: [pos (Position),group (Group), init (String), skill (Number), rank (String)] Note: init, skill, and rank are optional, default values are "", 0.5, "PRIVATE".

Example:

"SoldierWB" createUnit [getMarkerPos "barracks", groupAlpha]

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  

×