Home   Help Search Login Register  

Author Topic: Radio Operator, Magazine Check  (Read 1588 times)

0 Members and 1 Guest are viewing this topic.

Offline Monkels

  • Members
  • *
Radio Operator, Magazine Check
« on: 07 Jun 2007, 15:59:33 »
Afternoon fella's, 2 parta for you
Was up till 5am last night searching ofpec and bi forums with no luck  :-[


1st part
So bassicly I've got the artillery script to only execute when the player has battery's for the Custom Radio

I tried using the "hasweapon" command but the radio i have is classed as a Binocular  in the config.cpp and the trigger wont execute at all

Cond:
Code: [Select]
(vehicle player) in thisList && (""RadioBattery"" In (Magazines player))Act:
Code: [Select]
[] exec "artillery1.sqs"

Now once the player has requested artillery, ive got it to decrease the battery magazine, Only problem is that it removes a battery from all players carrying a battery. Preferably id like it to only remove a battery from the player that issued the artillery request.  Is this possible?

cmd im using is
Code: [Select]
player removeMagazine "RadioBattery"
I know its going to remove them from all players just didnt know if i could remove it from specific players


2nd Part

Ties into the 1st part as in when the player has run out of batteries then the "artillery_disable.sqs" will run "just null's all the radio commands"

Only problem is i need some sort of check to see if the player has less than 1 battery, this trigger can excute on all players


eg
(vehicle player) in thisList && (""RadioBattery"" count (Magazines player) <1)


im unsure bout this as its my first real attempt at scripting, still aint found any decent tutroials on Evenhandlers and how to pass the innit line to the script

Cheers for any help

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Radio Operator, Magazine Check
« Reply #1 on: 07 Jun 2007, 16:23:26 »
there's a very good tutorial on eventhandlers right here.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Radio Operator, Magazine Check
« Reply #2 on: 07 Jun 2007, 16:24:05 »
Um... what does a radio battery have to do with artillery?  ???

I am a little confused. You have a custom radio addon that takes a battery object as its ammo? Does the custom radio actually "fire"? More specifics please on the radio.
urp!

Offline Monkels

  • Members
  • *
Re: Radio Operator, Magazine Check
« Reply #3 on: 07 Jun 2007, 16:27:00 »
its a custom clan addon

For the Radio operator to be able to access the Artillery they need batterys to use the radio

Edit*

Its not a custom radio as such, it still uses the regular 0-0-1 radio that everyone see's, but for the player to be able to use it they must be carrying a Battery

the battery is a custom addon, but it could as well be a "m16" mag or a "laserbattery"
« Last Edit: 07 Jun 2007, 16:29:22 by Monkels »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Radio Operator, Magazine Check
« Reply #4 on: 07 Jun 2007, 18:30:56 »
The problem is your trigger condition, which can fire on multiple clients if more than one player with batteries is inside the trigger. What you should do instead is add a trigger that enables the radio for each player separately(assuming Radio Alpha used):

Trigger: None,Repeatedly with Condition:
Code: [Select]
not ("RadioBattery"" In (Magazines player))

OnActivation:
Code: [Select]
1 setRadioMsg "NULL"
OnDeactivation:
Code: [Select]
1 setRadioMsg "Fire Artillery"
Now a player will only see the radio if they have battery. You do not need any extra conditions in your radio trigger other than the default this. When a player calls the artillery the script will only run on that player's machine so the battery will be removed properly.

Edit: Actually, your original code would also have removed the battery for just one player because radio triggers are only activated on the machine of the player who used it.  The trigger I have provided is still, I think, a better way to do it.
« Last Edit: 07 Jun 2007, 18:35:36 by Mr.Peanut »
urp!

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Radio Operator, Magazine Check
« Reply #5 on: 07 Jun 2007, 20:48:05 »
Why are you using thisList?  I thought the artillery was supposed to be activated via radio?  Do players need to be in a certain area?


Offline Monkels

  • Members
  • *
Re: Radio Operator, Magazine Check
« Reply #6 on: 08 Jun 2007, 16:03:23 »
Aye inside a certain area, tis all fixed now

Instead of nulling the radiomsg's ive just got it to turn off when the player runs out of batteries, looks much better and runs better to

Cheers for the help peanut