Jump to content
Sign in to follow this  
Doolittle

At time 0

Recommended Posts

I was trying to get a script to run for just AI people.

I had the server doing a test for if a game player (played by AI) was local to them, then it ran a script.  Like:

?local _p : _p exec "foo.sqs"

However this didn't work.  It would appear to be the case that all objects are local to the server at time 0, when everyone clicks "I'm Ready", then player objects become local to the players only.

Is this assumption correct?  That would mean the fix would be just:

~0.5

?local _p : _p exec "foo.sqs"

Thanks for any help...

Doolittle

P.S. Here's something else I can't figure out: not everyone seemed to "register" onMapSingleClick when I called it from init.sqs.  I have a delay of 1 second from when the map starts to where I call onMapSingleClick.

init.sqs

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

onMapSingleClick {[_pos, _units, _shift, _alt] exec "scripts\mapclick.sqs"; false}

How could some people miss that??  Should I put more delay in there or call it several times so that their system "registers" the fact that when you click on the map I want mapclick.sqs run??

Share this post


Link to post
Share on other sites
However this didn't work. It would appear to be the case that all objects are local to the server at time 0, when everyone clicks "I'm Ready", then player objects become local to the players only.

No, I dont think this is correct, AI are always local to the server unless the AI is in a group in which a player is the leader

In your case, if the player slots all end up in one group, the AI will usually be local to the leader of the group, if the slots are all in seperate slots than it should be local to the server.

As for the onmapsingleclick command, I'm not sure but try making the 1 second delay a little longer, sometimes the start of a mission can be slightly choppy

Share this post


Link to post
Share on other sites

Hmmm...well all the players are seperate.  This is actually the line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?local _p and player != _p : _p exec "scripts\build.sqs"

When I test on my own system (where I am client and server) this works like it should: if the player is AI controlled the build.sqs runs, otherwise it doesn't.

I do know about this code:

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

?call format ["""%1""", player] == "<NULL-object>" : playerobject = objNull

You know.... this trick to see if we are a dedicated server or not.  I think what is happening is that on my dedicated server, the line "local _p and player != _p" is really "local _p and objNull != _p"...player variable is null on a dedicated server (right!?).  So something about doing a comparison to a null object screws up and it runs.

Ok, here's the question then, if reading all the above is confusing: how do I run a command if a certain player is AI controlled (and in their own group)?  For some reason seeing if they are local doesn't work.  Ack I'm confused.

Doolittle

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">? local Server && local _man : goto "AI"

Thats probably the easiest method to check if its an AI, but you must have a game logic named Server placed on the map

Share this post


Link to post
Share on other sites

Okay, I just was able to actually test this over MP. Having the ~0.5 in there before the code actually fixed it!! Which means all objects are local to the server at time 0. As soon as you start the mission the players become local only to themselves.

Thanks for assistance though Korax.

Doolittle

Share this post


Link to post
Share on other sites

yes, i experienced similar things. "player" is not local or not initialised in MP at 0... or soemthing like that. it just doesn't work. wink_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]Okay, I just was able to actually test this over MP.  Having the ~0.5 in there before the code actually fixed it!! Which means all objects are local to the server at time 0.  As soon as you start the mission the players become local only to themselves.

This was the first problem I came across when I stared my very first attempt at MP scripting.

http://www.ofpec.com/yabbse....d=23968

I can only talk about this in terms of init events within addons. If you try and launch a function from the addons init event (time 0), the Group command will not work and neither will the local command. It's as though it waits to create everything required for the mission. Before passing it onto the Multiplayer code, to decied what belongs where and who it belongs to.

But rather than give it a fixed delay, I used the rating command to flag when all the inital network traffic (cant think of a better way of describing it) had finished.

http://www.flashpoint1985.com/cgi-bin....t=46743

But you might be able to do the same with @!(IsNull (Group Player)).

Share this post


Link to post
Share on other sites

dolittle,

i reg my onMapSingleClick 0.1 s after game start .. work fine so far

my guess is that some of the players use some addon or mod that also calls onMapSingleClick which will override ur

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  

×