Jump to content
Sign in to follow this  
Bandicoot

Script help

Recommended Posts

Hi,

I'm using a random code gen from Codepad by Blanco(Modified by - RickUK 2007-01-04) for missions involving getting a code off dead bodies or speak to someone, but what I'm having issues is that the setup in MP mode doesn't let everyone have the same code.  I've tried just the DedicServer to create the code, but how can I transfer the same code to the other clients.  

Can anyone see what the problem is?

ie-

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

Codereadycheck=false;Publicvariable "Codereadycheck"

codefound = false

Ncode1 =[]

MAXNR = 6

;If client goto #start and wait for server to create code

?!(local server): goto "Start"

#Create_random_digit

_digits = ["1","2","3","4","5","6","

;7","8","9","0","",""]

_countdigits = count _digits

_code = ""

_i = 0

#CYCLE

_r = random _countdigits

_r = _r - _r % 1

_digit = _digits select _r

; You can't put special characters in a string for some reason..., Even between double qoutes.I had to find an alternative,it works great!

? _r == 10 : _digit = "#"

? _r == 11 : _digit = "*"

_code = _code + format ["%1",_digit]

_i = _i + 1

?_i < MAXNR : goto "CYCLE"

Ncode1 = _code; Publicvariable "Ncode1"

~1

Codereadycheck=true;Publicvariable "Codereadycheck"

#Start

;clients wait for server to create code

@Codereadycheck

~1

hint format["%1",Ncode1]

[code_pad,Ncode1] exec "\TEFextras\codepad\pad\numpad.sqs"

;?(Randomunits):[Codekeeper] exec "\TEFextras\codepad\pad\randomassign.sqs";exit

[Codekeeper] exec "\TEFextras\codepad\pad\bodysearch.sqs"

exit

I endup getting the scalar error msg, meaning the clients didn't get the code I assume.

Should I be using a code that is more numeric rather than string format to make the info more of a publicvariable or is that barking up the wrong tree?

Regards,

Bandicoot

Share this post


Link to post
Share on other sites

Hi,

I tested the Publiccode.sqs,  found that the information  it sends is like setting up a trigger, you can't send Local variable.

[{Ncode1 = _code}] exec "publicCode.sqs"

This is what is sent and read:

Ncode1 = _code

So I'm trying to send what is in the variable Ncode1 to update all clients verison of Ncode1.

I see what its doing in that all clients create a unit with the init details, but its not displaying in the init what the variable equals.

Unless format ["%1", _Code], but then wouldn't it just say that instead of having the logic to display whats within the variable?

Regards,

Bandicoot

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">call format [{ [{Ncode1 = ""%1""}] exec {publicCode.sqs}}, _code];

This format-construct will make sure that the variable '_code' is evaluated first, before the message is send.

Share this post


Link to post
Share on other sites

Yeah, you can send pretty much anything. It's a matter of getting the syntax right.

This doesn't work because the local variable doesn't exist outside of the particular instance of the script on this particular machine:

_myRnd = random 1

{globalRand=_myRnd} call pub

You have to convert the value into the code string so it becames something like this:

{globalRand=0.564717} call pub

Share this post


Link to post
Share on other sites

Thanks dengibtsschon.

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

call format [{ [{Ncode1 = ""%1""}] exec {publicCode.sqs}}, _code];

This did the trick yay.gif

The "call format" to exec the publicCode was the solution for this script.  

Thank you Pulverizer for your script "publicCode.sqs".

Trying to keep the old OFP girl alive.  

Regards,

Bandicoot

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  

×