Jump to content
Sign in to follow this  
D.murphy man

Fallout RPG - Bug fixing help

Recommended Posts

Hey all,

With my latest mission a rather strange bug has occured where every one on the map after say 20 mins tends to urm.. die.

I am presuming that the hunger script ive wrote is the proplem. Ive looked over the two main scripts related to the hunger script and i cannot find any thing wrong, leaving me with one question. If i have declared a public varible in the init.sqs and later on in the mission this varible changes (like when the player eats food the hunger goes down for example) do i have to declare the varible again? as in:

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

man1hunger=0

publicvarible "man1hunger"

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

Man1hunger=man1hunger-5

man1food=man1food-1

-->publicvarible "man1hunger"<--

The line with arrows pointing at it is the line i am adding on. So would i be correct in the fact the players are all dieing because the server still has the varible 'man1hunger' and is still adding on hunger even though the client has taken away 5 hunger from it when the player chooses to eat? And the server dosent recive the change? So i would have to send the publice varible again in the eat script?

I hope you all know what i mean, im getting kinda confused by self crazy_o.gif

Share this post


Link to post
Share on other sites

*Bump*

Sorry if i seem to be pestering tounge_o.gif But i would of thought some one out here on the forum has experience with public varibles. Or didnt i make my first post clear enough? Please say.

Share this post


Link to post
Share on other sites

I'm far from a master scripter, but from what I understand, every time you change a variable that must be public, you need to broadcast it with publicvariable. Declaring it once at the start only broadcasts it that one time.

There are exceptions. For example, as far as I understand, any variable adjusted by a trigger will be automatically broadcast.

Another issue to be careful of is locality. Scripts trying to affect a unit that is local to another PC will have trouble.

(As I said, I am not a script-ninja, please correct as necessary).

Share this post


Link to post
Share on other sites

Why not execute a script from init.sqs, have one running on each client, and one running from the server. Have the server side script sit there and wait for a global variable to change. The clients script will be counting down the players hunger until it reaches 0, when it does reach 0 set the global variable to a number corresponding to the players identity (to let the server know which one it has to kill). The server will then detect this change in global variable, kill the corresponding player, set the global variable back to 0, and start waiting again.

Make sure there is a small random delay before the clients set a global variable for the server, or multiple clients may set the variable at the same time. Also only let the client set the global variable if the global variable is 0.

Sorry if that is a bit unclear, I am in a bit of a rush and a bit drunk, if you require further explanation I will do so later, or tomorrow.

RED

Share this post


Link to post
Share on other sites

Hmm what dose that CoC NS do? The read me leaves much to be desired. Also thanks every one.

Share this post


Link to post
Share on other sites

I completely eliminated the script.. hope you dont mind D. Murphey.. and I added 48 more weapons to the random weapons script, and you find it 70% of the time.. I lowered the food gain cause face it.. you only need to eat once a day to survive.. I do it, and Im completely fine..

but good job on the mission still..

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  

×