Home   Help Search Login Register  

Author Topic: Delete ammo from created crates (serversided script)  (Read 2140 times)

0 Members and 1 Guest are viewing this topic.

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Hi all.

My script is creating crates on server only, also the script removes the ammo from the crates. That works...........

However, it doesnt work in MP. Clients of the dedi can see the crates and the crates are still filled with ammo.
It seems the script only deletes the ammo locally on the server and not on the clients.

In the prievew mode of the editor the ammo gets deleted just as it should so it works.

As a possible solution I add all created crates to an array.
All clients exit the main script  and go to a side script which is checking the said array for ammorcates. As soon as the main script has completely finished the cliens will remove the ammo from the crates by checking that array.

This works in the editor as well, but still not in MP (dedicated server).
In MP it doesnt recognize the created array although it does when tested in the preview in editor.

Anyone has an idea how I can delete ammo from crates on clients computers while the crates are created on the server only?


Just to clearify.
The created array is created (GRF_total_ied_array = []) before the clients exit, so they recognize the array.
However they can not see any additions the script added to that array at a later point), logical yes indeed. But how can I make the clients be able to read the array?

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Delete ammo from created crates (serversided script)
« Reply #1 on: 09 Apr 2007, 05:04:26 »
When you execute a script locally, any script or command you execute from that will be local only.

The only way you can make something global from this is publicvariable command.

You would need to put a few lines in a trigger, and publicvariable that (with the variable being what you put in the condition field, and making it true/false).

You could however do something like this (thats the idea, not the syntax)

Quote
cratedone = false
if the player is not server : goto "notserver"

create the crate code

cratedone = true
publicvariable "cratedone"

#notserver
@cratedone

remove ammo code

exit

Thats a possible idea..

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: Delete ammo from created crates (serversided script)
« Reply #2 on: 09 Apr 2007, 15:15:20 »
I know about publicvariables and such.

But what you are typing is exactly what I am asking.
How does a client know what is a crate? The client doesnt know of any crates so how can he ever remove the ammo from it?

Assigning it a variable name doesnt work. Neither does adding the crate to an array work cause they array will only be known at the server and not the client (even though I create the array before the client leaves).

Again, I am very aware of the fact that if a script creates things locally on a server I may run into troubles, I am not asking about that.
I am asking how to fix it.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Delete ammo from created crates (serversided script)
« Reply #3 on: 10 Apr 2007, 17:25:58 »
Okay, here's the shiz. Near as I can figure, all commands that add/remove weapons/ammo are local, so you will need to run your ammo/weapon removal script on all clients.���  Why not add the crates to the map, remove the ammo using the init field of each crate and then setPos them into position when you need them?

If you really want to do it all dynamically you will have a challenge. What you must do is publicVariable the name of each crate. Then you will be able to operate on them on a client level. You can not PV an array. You may also consider using a counter variable for your crates that starts at a value of -99 on all clients, but then the server sets it to the number of crates and PV's it once all the crates have been created and their variable names have also been PV'd. You will have to use metavariables for the crate names and call format. Funny that such a simple task is so complicated and my bet is that you are not laughing.���  :weeping:

edit: One last thought. You might try using camCreate to make the crates. Not sure if the crate will be able to hold anything.

edit2: camCreate createVehicleLocal the crates on each client. They will be dummy crates. Now on the server createVehicle a weaponholder 1m underneath each crate.�  This is assuming "weaponholder" is still a valid type in ArmA.



« Last Edit: 10 Apr 2007, 23:58:14 by Mr.Peanut »
urp!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Delete ammo from created crates (serversided script)
« Reply #4 on: 10 Apr 2007, 21:58:39 »
Quote
camCreate the crates on each client.
Won't work, it seems that in ArmA you can't camCreate anything but cameras..

I guess that's why they added createVehicleLocal.. :dunno:

Quote
his is assuming "weaponholder" is still a valid type in ArmA.
Not at all sure but I think in ArmA weaponHolder is Library_WeaponHolder
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Delete ammo from created crates (serversided script)
« Reply #5 on: 10 Apr 2007, 23:59:38 »
Does createVehicleLocal create working vehicles? Will the crates created in this manner be dummies or the real thing?
urp!

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Delete ammo from created crates (serversided script)
« Reply #6 on: 11 Apr 2007, 06:34:13 »
class WeaponHolder does still exist in Arma, it inherits from ReammoBox just like it does in OFP.


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

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Delete ammo from created crates (serversided script)
« Reply #7 on: 11 Apr 2007, 16:23:40 »
Oh, I did only find that Library_ tagged one...  :dunno:

@Mr.Peanut
It works the same way as createVehicle, it's just local in MP..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.