Jump to content
Sign in to follow this  
—=R.I.P.=—™

Ammocrate scripting woes....

Recommended Posts

I am having a problem with getting an ammocrate script based on Karrillion's to work properly on my dedicated server.

For some reason it will not run on the clients..

This script places ammocrates according to time along with random fog and then executes the ammocrate script.

---------------------------------------

? param2==4.75 : goto "am"

? param2==12 : goto "noon"

? param2==18.30 : goto "pm"

? param2==0 : goto "night"

#am

SetViewDistance 500

_rand1=0+random 5

_rn = (_rand1 + 0.5) - ((_rand1 + 0.5) Mod 1)

?_rn == 0: _S1=0

?_rn == 1: _S1=300

?_rn == 2: _S1=600

?_rn == 3: _S1=900

?_rn == 4: _S1=1800

_S1 setfog .60

? local server : A1 = "ReammoBoxWest" createVehicle getpos H

? local server : A2 = "ReammoBoxWest" createVehicle getpos H_1

? local server : A3 = "ReammoBoxWest" createVehicle getpos H_2

? local server : A4 = "ReammoBoxWest" createVehicle getpos H_3

? local server : A5 = "ReammoBoxWest" createVehicle getpos H_4

? local server : A6 = "ReammoBoxWest" createVehicle getpos H_5

? local server : A7 = "ReammoBoxWest" createVehicle getpos H_6  

? local server : A8 = "ReammoBoxWest" createVehicle getpos H_7

? local server : A9 = "ReammoBoxWest" createVehicle getpos H_8

? local server : A10 = "ReammoBoxWest" createVehicle getpos H_9  

? local server : A11 = "HeavyReammoBoxRes" createVehicle getpos H_10

? local server : A12 = "HeavyReammoBoxRes" createVehicle getpos H_11

? local server : A13 = "HeavyReammoBoxRes" createVehicle getpos H_12

? local server : A14 = "HeavyReammoBoxRes" createVehicle getpos H_13

? local server : A15 = "HeavyReammoBoxRes" createVehicle getpos H_14

? local server : A16 = "HeavyReammoBoxRes" createVehicle getpos H_15

? local server : A17 = "HeavyReammoBoxRes" createVehicle getpos H_16

? local server : A18 = "HeavyReammoBoxRes" createVehicle getpos H_17

? local server : A19 = "HeavyReammoBoxRes" createVehicle getpos H_18

? local server : A20 = "HeavyReammoBoxRes" createVehicle getpos H_19

["ammo1",A1] exec "ammocrates.sqs"

["ammo1",A2] exec "ammocrates.sqs"

["ammo1",A3] exec "ammocrates.sqs"

["ammo1",A4] exec "ammocrates.sqs"

["ammo1",A5] exec "ammocrates.sqs"

["ammo2",A6] exec "ammocrates.sqs"

["ammo2",A7] exec "ammocrates.sqs"

["ammo2",A8] exec "ammocrates.sqs"

["ammo2",A9] exec "ammocrates.sqs"

["ammo2",A10] exec "ammocrates.sqs"

["ammo1",A11] exec "ammocrates.sqs"

["ammo1",A12] exec "ammocrates.sqs"

["ammo1",A13] exec "ammocrates.sqs"

["ammo1",A14] exec "ammocrates.sqs"

["ammo1",A15] exec "ammocrates.sqs"

["ammo2",A16] exec "ammocrates.sqs"

["ammo2",A17] exec "ammocrates.sqs"

["ammo2",A18] exec "ammocrates.sqs"

["ammo2",A19] exec "ammocrates.sqs"

["ammo2",A20] exec "ammocrates.sqs"

goto "END"

----------------------------------------------

etc, etc....

This is the ammocrate script.

-----------------------------------------------

_type=_this select 0

_ammocrateid=_this select 1

goto "type"

#type

?(_type == "ammo1"):goto "Crates1"

?(_type == "ammo2"):goto "Crates2"

?(_type == "ammo3"):goto "Crates3"

?(_type == "ammo4"):goto "Crates4"

?(_type == "ammo5"):goto "Crates5"

?(_type == "ammo6"):goto "Crates6"

#Crates1

clearweaponcargo _ammocrateid

clearmagazinecargo _ammocrateid

_ammocrateid addweaponCargo ["Binocular",20]

_ammocrateid addweaponCargo ["G36a",30]

_ammocrateid addweaponCargo ["XMS",30]

_ammocrateid addweaponCargo ["Steyr",30]

_ammocrateid addweaponCargo ["LAWLauncher",30]

_ammocrateid addweaponCargo ["MM1",30]

_ammocrateid addweaponCargo ["6G30",30]

_ammocrateid addmagazinecargo ["G36amag",90]

_ammocrateid addmagazinecargo ["M4",90]

_ammocrateid addmagazinecargo ["Steyrmag",90]

_ammocrateid addmagazinecargo ["LAWLauncher",90]

_ammocrateid addmagazinecargo ["MM1magazine",90]

_ammocrateid addweaponCargo ["HandGrenade",100]

_ammocrateid addmagazinecargo ["6G30magazine",90]

goto "end"

---------------------------------------------------------------

etc, etc...

The ammocrates are created where they should but they are loaded with the default weapons sad_o.gif.

All works fine when playing as server/client, just not on a dedicated server.

Share this post


Link to post
Share on other sites

Well, I finally got the ammocrates to load properly after much trial and error.  It does help having the server in the other room to trouble shoot  tounge_o.gif.  By using <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? ! local server : A1 = "ReammoBoxWest" createVehicle getpos H

instead of <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? local server : A1 = "ReammoBoxWest" createVehicle getpos H it creates the ammocrate in the proper place with the weapons from the ammocrate script.  I'm not sure why I needed to add the "!"though.  I have used ? local server before with vehicles and respawn scripts and never had a problem like this.  I guess I don't fully understand what ? local server and ? ! local server mean.

Share this post


Link to post
Share on other sites

? means :if

! means :not

so if local server

and

if not local server

and how to understand why OFP handles local MP server and dedicated differently is beyond me.

Share this post


Link to post
Share on other sites

Taurus - Thanks for your reply

So, what this means is if it is not loccal then the script runs on all clients? Or does it mean the script runs on the server and is relayed to all the clients?  I am asking this becuase when I was trying to find why it was not working properly I had remove the ? local server and tried the map.  This time there were two ammocrates where only one should have been.  One had the default weapons in it and one had the weapons from the script.  It was as if the client and the server both ran the script but only the server side script had the ammo.

Share this post


Link to post
Share on other sites
Quote[/b] ]So, what this means is if it is not loccal then the script runs on all clients? Or does it mean the script runs on the server and is relayed to all the clients?

?!(local Server): exit

Will force the clients not to run any further in the script.

However, if you host an "local" MP game, you are the server, and you will always be an client too, which sometimes result in very strange an unwanted behaviour (as far as my experience go)

?(local Server): exit

Will execute on all the clients, and not the server.

Also here you will get an strange and unwanted behaviour if you host an "local" MP game.

As the script wont run on your machine at all.

So I mainly use the ?!(local Server) thing

Quote[/b] ]This time there were two ammocrates where only one should have been. One had the default weapons in it and one had the weapons from the script.

I explain later why two ammocrates is created.

the thing about that only one of them has ammo is becuase of this:

A1 = "ReammoBoxWest" createVehicle getpos H

is run twice(or depending on how many clients there are), e.g.

A1 = "ReammoBoxWest" createVehicle getpos H

A1 = "ReammoBoxWest" createVehicle getpos H

A1 will first be assigned with the created ammocrate.

on the next line it will be reassigned to another ammocrate.

leaving that only one of them which can be access via an variable in the next step where the ammo is filled.

["ammo1",A1] exec "ammocrates.sqs"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">This is the ammocrate script.

-----------------------------------------------

_type=_this select 0

_ammocrateid=_this select 1

goto "type"

#type

?(_type == "ammo1"):goto "Crates1"

This will also run on all clients, but only one of them knows what A1 is, the rest of the ammocrates will not get any custom ammo.

Quote[/b] ]This time there were two ammocrates where only one should have been. One had the default weapons in it and one had the weapons from the script. It was as if the client and the server both ran the script but only the server side script had the ammo.

This is an correct observation.

if one of your friends should join in, you would have had three ammocrates, if two more, four ammocrates and so on.

Furthermore, it looks like in the script that if the ammocrate is created on the server, all clients will "fill" the ammocrate with ammo, éven if the only thing that knows what A(num) is, is the server crazy_o.gif

I hope that this clears things up, if not, please ask again and I'll try to answer

Share this post


Link to post
Share on other sites

Yes exactly, you could try adding

?!(local Server): exit

at the top line of the script, making the rest of the script to run only on the server.

Then you should be able to remove all "? local server"

from ? local server : A1 = "ReammoBoxWest" createVehicle getpos H

and so on.

oh, I forgot.

Server can be whatever you decide to name your gameLogic.

So Server is nothing more that an object that reside on the server, as gameLogics allways is serverside they suites this purpouse well.

Share this post


Link to post
Share on other sites

Can you tell me where to get Karrillion's loadout scripts?

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  

×