Home   Help Search Login Register  

Author Topic: AMMO & WEAPONS IN VEHICLES  (Read 1113 times)

0 Members and 1 Guest are viewing this topic.

Offline ZNorQ

  • Members
  • *
  • ehr... uhm... duh...
AMMO & WEAPONS IN VEHICLES
« on: 15 Mar 2005, 20:48:51 »
I'm having difficulties adding equipment / ammo / weapons to a vehicle in a way that
the amount I add applies to all players in the MP game. Let me try being more precise;
If I add 10 mines to a humvee, ALL players get 10 mines EACH from the vehicle! Quite
annoying, or am I doing something wrong..?

I use the following command (assumes the vehicles object id is Humvee);

  Humvee addMagazineCargo ["M16", 10]

ZNorQ

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:AMMO & WEAPONS IN VEHICLES
« Reply #1 on: 15 Mar 2005, 21:19:02 »
Maybe this is being run locally on each machine, just a guess , but maybe it needs to run only on server.

However, I know practically nothing about MP, so if I'm wrong just ignore me and I'll go back into my box.  ::)


Planck
I know a little about a lot, and a lot about a little.

Kyle Sarnik

  • Guest
Re:AMMO & WEAPONS IN VEHICLES
« Reply #2 on: 15 Mar 2005, 21:42:44 »
I'm having difficulties adding equipment / ammo / weapons to a vehicle in a way that
the amount I add applies to all players in the MP game. Let me try being more precise;
If I add 10 mines to a humvee, ALL players get 10 mines EACH from the vehicle! Quite
annoying, or am I doing something wrong..?

I use the following command (assumes the vehicles object id is Humvee);

  Humvee addMagazineCargo ["M16", 10]

ZNorQ


10 mines each? Well then, simple, use the init script, since init.sqs is always run locally. Add all your lines in the init.sqs, should do the trick.

Offline ZNorQ

  • Members
  • *
  • ehr... uhm... duh...
Re:AMMO & WEAPONS IN VEHICLES
« Reply #3 on: 15 Mar 2005, 21:58:39 »
@Planck; Well, I'm usually adding the equipment using the init field in each vehicle. I've also added the equipment using serverscript, but - all players get 10 mines each... Quite annoying.

@Kyle; Might be me misunderstanding, but I think you got it wrong; I do NOT want EACH
player to get 10 mines... I want ONLY ten mines in the vehicle...

Anyway, I thought adding ten mines (or what every ammo/weapons/equipment I want
to add) I could use the INIT field for each vehicle, but seems that doesn't work properly...

ZNorQ

Kyle Sarnik

  • Guest
Re:AMMO & WEAPONS IN VEHICLES
« Reply #4 on: 16 Mar 2005, 00:02:59 »
Eh, sorry, I thought you wanted 10 mines each.

Well then, init box should be fine, I think, if not, you could always make a new addon (just a new config) with the vehicles allready containing those weapons and mags.

Offline Roni

  • Members
  • *
  • Play the Game !
Re:AMMO & WEAPONS IN VEHICLES
« Reply #5 on: 19 Mar 2005, 02:33:15 »
No, Init is most definitely run on all machines !  The way to have it run on just the server is to put a gamelogic called server (or whatever) on your map and add this line to your script -

? !(local server) : exit


Game logics are local ONLY to the server so the above line stops the script running on all but that machine.

Another trick if you're running a script on a playable unit is to add these lines -

_player = _this select 0
? _player != player : exit



Again, "player" is local only to each machine that each person is sitting at.  This means that if I run a script at start called "IamSpartacus.sqs" then EVERY machine will run that script.

If this script is called from the Init field of (say) four playable units then EACH player's machine will have all four scripts running.  The above lines at the start of the script will close of all versions of the script except the one that they're actually playing on (ie each person playing will be a unique "player").

MP is very annoying but it easy if you just remember that each and every machine is essentially running it's own version of the game all by itself.  It runs it's own scripts, does its own physics and calculates its own results.  Things that a player does are broadcast to the network so that each machine can keep running together.

This is normally invisible to the players, but problems occur if you call (say) a random function - the result of that call will be different on each machine.  As I discovered once when I wrote a sandstorm script . . .  

:)  /   :(  /   ???

I hope that this isn't too far off topic but this should solve your problem - just use either of the above solutions and you should get just 10 mines, full stop.


cheers



roni  / roni  /  roni  /  roni
(but on MY machine - roni)   :P

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Re:AMMO & WEAPONS IN VEHICLES
« Reply #6 on: 20 Mar 2005, 01:29:02 »
Quote
This is normally invisible to the players, but problems occur if you call (say) a random function - the result of that call will be different on each machine.  As I discovered once when I wrote a sandstorm script . . .  

Well I had the same experience when i tried to have random daytime settings jn MP,and everybody had a different one . ;D :noo:

Well attackers can play in Daylight while defenders see the dark :wow:

Well I could solve the prob,run a script from init.sqs (global),start with ?!(local server):exit (kicks the local machines out),use Randomcommand and PublicVariable the result :toocool:

BTW:how can U find out the max amount of Cargo  ???
Howmany mines can I put in a Cessna?
http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:AMMO & WEAPONS IN VEHICLES
« Reply #7 on: 20 Mar 2005, 04:11:34 »
Its all in the configs.

class Air has:

transportMaxMagazines = 20;
transportMaxWeapons = 3;

and class Plane inherits from class Air.

And then class A10 inherits from class Plane and finally class Cessna inherits from class A10.

There doesn't appear to be any changes to those parameters through those class definitions.


Planck
I know a little about a lot, and a lot about a little.

Offline Roni

  • Members
  • *
  • Play the Game !
Re:AMMO & WEAPONS IN VEHICLES
« Reply #8 on: 20 Mar 2005, 07:13:03 »
Re: lining up MP machines -

My sandstorm script now has a bit at the beginning that says -

? !(local server) : goto "clientloop"


before running straight in to a closed loop called "serverloop".  Clientloop is at the end of this and runs in its own closed loop.

Serverloop does all the time and weather changes as well as checks for sandstorms, which it then shouts to the network via publicVariable.  Clientloop simply checks every second for these things and acts accordingly.

In an early run of the script I had a time dilation routine running which made each day pass in about 15 minutes.  Rather than the above server/client setup I just had each machine run the script on their own.

That was when i discovered that even though the game runs in parallel on all machines, scripts run faster or slower depending upon individual game performance.  After 20 minutes of play or so one player was playing at night while the other was playing in early morning !

The moral of all this is - if you want machines to stay in step, use some form of the above client server loop.

cheers !




roni

Offline ZNorQ

  • Members
  • *
  • ehr... uhm... duh...
Re:AMMO & WEAPONS IN VEHICLES
« Reply #9 on: 21 Mar 2005, 20:03:22 »
@Roni; I know about the server scripts, and I'm pretty sure I've used that solution
too ... I'll give it another try to veriify..

Thx all
ZNorQ