OmniMax 0 Posted May 23, 2005 I did search. I want to execute this script by server side only (if you must know, the script generates random numbers and based upon these numbers fills a crate up with weapons). <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ? local(server) : [] exec "r.sqs" ;called within init.sqs <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Gamelogic Conditon of presence: True Initalization: [] exec "r.sqs" ;AND I tried the following Gamelogic Conditon of presence: local server Initalization: [] exec "r.sqs" Both methods prescribed didn't work, but I am wondering is it because I am playing the mission through multiplayer menu (yes, I am) but by myself? If there are two people would the code work or am I making some mistake? The script works by itself when I execute from the init line from say a player or init.sqs (without the localization call) so the script works fine. But when I execute the script on each individual client, as you can imagine everyone's random equipment in the crate is different. Which is the opposite of what I want. What am I doing wrong??? Share this post Link to post Share on other sites
baddo 0 Posted May 23, 2005 1. Place a game logic to the map and give it a name ("server" recommended but not compulsory). 2. Use the following to start the script on server only from a script like init.sqs: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (local <NameOfYourGameLogic>) : [] exec "r.sqs" If the game logic is named "server": <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (local server) : [] exec "r.sqs" This should work. Share this post Link to post Share on other sites
crashdome 3 Posted May 24, 2005 Quick Note: Filling ammo crates won't work server-side only. Ammo crates need to be syncronized on all clients. When you fill an ammo crate with let's say... 10 grenades on the server, only the server will see them. Any units on the server can grab those grenades but the other clients (players and AI) will see an empty ammo crate the whole time. You must syncronize your random numbers on all clients then have all clients "fill" the ammo crates along with the server. Once you get the server-side random number generator working... you must do the above to make sure it's the same on all machines. Share this post Link to post Share on other sites
OmniMax 0 Posted May 24, 2005 I'm sorry, how do I syncronize it? My browser can't get to the web-based command refference (mozilla 'firefox' 1.0.3) Share this post Link to post Share on other sites
crashdome 3 Posted May 24, 2005 you must "publicvariable" the random numbers in the init.sqs by branching the script. Have one branch for the server that creates the numbers and then publicvariables them to the clients along with a boolean value to acknowledge that they have sent. Have the other branch (for clients) pause based on the boolean conditional. When it is true, it will continue with the server code and fill the crate. Here is a rough example of an init.sqs that does this (requires a gamelogic named "server" to be placed on the map and one ammo crate named "MyAmmoCrate"): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> RandomNum = 0 ValueSent = false ? !(local server):goto "ClientBranch" #ServerBranch RandomNum = random 10 RandomNum = RandomNum - (RandomNum % 1)  ;rounds number to nearest integer PublicVariable "RandomNum"  ;send RandomNum to clients ValueSent = true PublicVariable "ValueSent"   ;send boolean to clients goto "MeetHere" #ClientBranch @ValueSent  ;wait for boolean #MeetHere ;All clients and server will continue code from this point on in sync myAmmoCrate addMagazineCargo ["HandGrenade", RandomNum] EXIT EDIT: Actually, you could avoid all this nonsense and put in a single line of code if you did not have a problem installing CoC's Network Services into your mission. However, this may be excessive if you just want to sync a few ammo crates. If you have other client-server related scripting to do you might want to consider using CoC_NS as it can significantly reduce the amount of coding when sending all kinds of values back and forth from clients to server. It might also allow you to add more features to your mission that you thought were too difficult. Share this post Link to post Share on other sites
OmniMax 0 Posted May 26, 2005 Wow, thanks! I would have been still searching for the proverbial 'wheel' if you hadn't told me that. I notice the game's sockets implementation syncronizes most things (unit positions, item positions, among other things, marker positions) but it's good to have control over what is syncronized and being able to make sure things are syncronized. Share this post Link to post Share on other sites
General Barron 0 Posted May 28, 2005 I second the motion that you use CoC's NS. Seriously, NS is EXTREMELY useful, and cuts the headache/hassle in making MP scripts by a huge amount. It might be a little difficult to understand the documentation at first, but once you get going, it is really easy to use. I highly recommend it. Share this post Link to post Share on other sites
OmniMax 0 Posted May 28, 2005 Using NS would be excessive as there aren't many things that I want to do that utilize it. Share this post Link to post Share on other sites