Jump to content
Sign in to follow this  
Somerville

_this select 1

Recommended Posts

In an OFP Mission that I have, there is a script with the following code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 1

So, in Operation Flashpoint, this line of code works without a problem.

However, in Armed Assault, it returns the following error:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this |#| select 1 Error zero divisor

Is there something wrong here? A change in syntax?

Cheers for your help guys.

Share this post


Link to post
Share on other sites

What code are you using to fire the .sqs ?

for example

[man,woman] exec "my.sqs"

_man = _this select 0

_woman = _this select 1

first thing to exec the sqs is the man and bis engine start at 0

so the second thing to exec the sqs is 1

if we added something else for example

[man,woman,child] exec "my.sqs"

then it would be

_man = _this select 0

_woman = _this select 1

_child = _this select 2

and so on

Share this post


Link to post
Share on other sites

Thanks for the fast reply =]

In the mission, a man - P1 - has the following in his init line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setBehaviour "SAFE"; [p1] exec "startmoney.sqs"

'startmoney.sqs' has the following code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit=_this select 0

sm=3000

?(local Server): [sm,_unit] exec "dis.sqs"

exit

'dis.sqs' has the following:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">sm = _this select 0

_unit = {_this select 1}

? (_unit == Player) : hint Format["%1 you have $%2",name _unit,sm]

exit

But, although this works in OFP, it has no effect in Armed Assault...

Share this post


Link to post
Share on other sites

Why the curly braces around _this select 1?

There is no reason for them. Remove them and you'll be good thumbs-up.gif

Bear in mind { and } are more strict in ArmA and mean something more. In OFP, this code worked because it was technically ignored.

Share this post


Link to post
Share on other sites

Sorry, my bad...

The curly things aren't there anymore, but it still doesn't work.

It says something like _unit = _this |#| select 0 error divisor

Which is.. wierd?

Share this post


Link to post
Share on other sites

You'd be right in saying that.

My clan wants to convert CC, but I haven't been able to get in touch with the original creator. We're going to try it anyway, but not publish until we can get some confirmation from him.

If he doesn't, we may well just publish but give him credit etc.

ANYWAY.

Can anyone help with the script problem here?

Share this post


Link to post
Share on other sites

The obvious fault was what crashdome pointed out

The second one is that you dont have a man called P1

The third is that _unit is already defined in 2 .sqs so to figure out which .sqs is saying the error occured. you need to do the following.

open a browser.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">C:\Documents and Settings\Owner\Local Settings\Application Data\ArmA

copy and paste that

*note mine says owner ,yurs maybe different there

there is a arma.rpt file

right click choose open /choose notepad

press ctrl f

type _unit = _this

it should now show you even more what is going wrong.

if the rpt file is too big ,delete it start arma start mission ,let it give you error and try above again

either paste findings here or you may even solve it ?

Share this post


Link to post
Share on other sites

Hi, thanks for the help.

I found this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Error in expression <_unit = _this select 1>

 Error position: <select 1>

 Error Zero divisor

To be honest, I think it's the "_this select 1" causing the problems, but I'm not sure how to go about fixing it :\

Share this post


Link to post
Share on other sites

init field

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

this setBehaviour "SAFE"; this exec "startmoney.sqs"

startmoney.sqs

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

sm = 3000

?(local server): _this exec "dis.sqs"

dis.sqs

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

?(_this == player): hint format ["%1 you have $%2",name _this,sm]

EDIT: Of course, this whole thing doesnt really make sense anyway, is this all the code you have in those files?

Share this post


Link to post
Share on other sites
Quote[/b] ]Thanks for the fast reply =]

In the mission, a man - P1 - has the following in his init line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setBehaviour "SAFE"; [p1] exec "startmoney.sqs"

'startmoney.sqs' has the following code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit=_this select 0

sm=3000

?(local Server): [sm,_unit] exec "dis.sqs"

exit

'dis.sqs' has the following:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">sm = _this select 0

_unit = {_this select 1}

? (_unit == Player) : hint Format["%1 you have $%2",name _unit,sm]

exit

But, although this works in OFP, it has no effect in Armed Assault...

That's all that's in the original files dude =]

Share this post


Link to post
Share on other sites

_unit = {_this select 1}

again change that to _unit = _this select 1

add a gamelogic named server

and it will work. I have tested it myself.

Share this post


Link to post
Share on other sites
That's all that's in the original files dude =]

Yeah, but I dont understand...

First you call startmoney.sqs on each machine, then you run dis.sqs only on server. In that script you use local command hint if the player is playing P1. This means...

- Hint text will only be shows on the server machine

- P1 is the player hosting the game

Is this mission for multiplayer? If so, I dont see it working properly in a dedicated server and only partly on hosted one. If its a single player mission, then the whole server check is pointless?

Share this post


Link to post
Share on other sites

Hmm, I see your point now.

Yes, this is a multiplayer mission, but it's being copied across script by script from OFP, and altered accordingly. In OFP, the scripts work fine, but in ArmA, it seems to have an issue with the "_unit = _this select 0" in dis.sqs. Perhaps this is because of the server check?

Bah, this is irritating the bejesus outta me -.-

Share this post


Link to post
Share on other sites

What you want is to set starting money for players and show it to them, right?

So, why not just replace

this

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

this setBehaviour "SAFE"; [p1] exec "startmoney.sqs"

with

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

this setBehaviour "SAFE"; sm=3000; hint format ["%1 you have $%2",name this,sm]

If you want, you can remove sm=3000 from units init and put it in init.sqs/sqf file.

EDIT: Setting behaviour safe for playable units is kind of pointless. smile_o.gif

Share this post


Link to post
Share on other sites

Hi guys,

The money is now working, along with several other aspects. All I need help with now is sorting out the earnings systems. The scripts are as follows:

edit: I've fixed the earnings now.

Share this post


Link to post
Share on other sites

Sorry to jack your thread Somerville, however my problem seems very similar. I'm trying to convert a script by TJ for the BAS Tonal pack. Trying to run this script ArmA resulted in 2 errors, one of which I fixed (path to cl_basic) but the other error says...

Quote[/b] ]_vel = _this |#|select 3

Error Zero Divisor

here is the script...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; BAS - Mist script - by TJ march 2003

;execute with name of gamelogic at the centre of area for mist

; eg, [<objectname>] exec "mist.sqs"

; ? benchmark <3500:exit

;Mist duration time (in seconds)

_object = _this select 0

_delay = _this select 1

_lifeTime = _this select 2

_vel = _this select 3

_lifeTicks = _lifeTime / _delay

_lifeTick = _lifeTicks

#loop

_count =0

#Begin

_dir = random 360

_velx = _vel *sin _dir

_vely = _vel *cos _dir

#mist

drop ["\ca\data\cl_basic", "", "Billboard", 1, 40, [0,0,-0.5], [_velx,_vely,0], 1, 1.275, 1, 0, [1 + (random 2)], [[0.8,0.8,0.8,0.1]], [0], 0, 0, "", "",_object ]

_count = _count +1

?_count <20:goto "Begin"

~_delay

_lifeTick = _lifeTick - 1

?_lifeTick > 0 : goto "loop"

exit

edit: unedited the script

edit 2: According to the Biki this error occurs when the variable you are trying to divide has a value of zero, or when you attempt to divide a variable by 0.

It also occurs when you attempt to access an element of an array which does not exist.

however this doesn't help me fix it. icon_rolleyes.gif

Share this post


Link to post
Share on other sites

Note to people asking this kind of questions: always show how you start the script! You need to show the whole path how the arguments to the script are formed. Otherwise it's hard to point to you where the error happens.

Pillage's script is asking for 4 arguments to be passed for it in an array. Make sure you actually do just that. The comment in the start of the script:

Quote[/b] ];execute with name of gamelogic at the centre of area for mist

; eg, [<objectname>] exec "mist.sqs"

is talking about only 1 argument but the script itself:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_object = _this select 0

_delay = _this select 1

_lifeTime = _this select 2

_vel = _this select 3

wants 4 arguments! So if you pass only 1 argument <object> to the script, _this select 1, _this select 2 and _this select 3 will give you an error as the array that was passed to the script doesn't contain that many values.

Should it not be:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[Object,Delay,Lifetime,Velocity] exec "\bas_o\s\bas_mist.sqs"

like

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[this,.7,500,1] exec "\bas_o\s\mist.sqs"

?

(Quickly looked from http://operationflashpoint.filefront.com/file....;70484)

Share this post


Link to post
Share on other sites

Thanks very much Baddo, I will endeavor to not make this mistake again now that you've explained it that way, I never was more than a tinkerer of scripts. I always found BAS to be good at commenting their scripts but it seems in this case they were lacking those extra arguments. oh well, works now, thanks again.

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  

×