Home   Help Search Login Register  

Author Topic: some ammo of primary weapon  (Read 4725 times)

0 Members and 1 Guest are viewing this topic.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:some ammo of primary weapon
« Reply #15 on: 17 Jun 2005, 19:17:15 »
right. so as stated by hateR_kint above

Quote
this requires that the magazine is named the same as the weapon itself, like "M16"...

which the steyr and beretta magazines aren't. the muzzle mode of these may also be different. that's just one problem.

also -

Code: [Select]
#checkammo
? _player ammo _ammo == 0 : goto "out"

#out
? ammo : goto "out2"
ammo = true
player groupchat "d**n IM OUT OF AMMO"

let's look at that for a moment. if the ammo is equal to 0, then goto 'out'. what happens if it's not equal to 0? it goes on to the next line of code, which is what?

the 'out of ammo' routine....

then comes the

Code: [Select]
? ammo : goto "out2"
bit. have you looked at the comref entry for the ammo command? does it look like it can be used like a boolean check? if you're using a variable like this, no problem. but this is a reserved term. flashpoint is looking for its use as a command, not a variable.

thus, putting 'ammo = true' will not work either.

« Last Edit: 17 Jun 2005, 19:30:08 by bedges »

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #16 on: 17 Jun 2005, 20:03:50 »
emm interesting and this is one pain in the arse i never relised the no exit line suppose i better add that in thats why it was showing the text.
so instead of ammo = true what could i do to check if its been to the 'out' part again then go to out2 if its been to out ?

Quote
have you looked at the comref entry for the ammo command? does it look like it can be used like a boolean check? if you're using a variable like this, no problem. but this is a reserved term. flashpoint is looking for its use as a command, not a variable.
ive looked several times and was wondering why it wasnt working just a few questions
1) whats a boolean check
2) By reserved term how do you mean
ill check the com ref for the answer
hang on maybe this is it.
its a true or false statement, and the line isnt a true or false statement.
cant find out about the reserved statement though

okay i kind of understand now but not really enough
basically the code doesnt work because it is not a true or false statement, correct ?

Online h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:some ammo of primary weapon
« Reply #17 on: 17 Jun 2005, 20:44:45 »
Quote
1) whats a boolean check
Boolean check means the check for true or false (actually, 1 or 0...)
Like if you have a variable Myvar = true you can check whether it's true with
? Myvar: hint "Myvar true"

Quote
By reserved term how do you mean
You can't have a variable called ammo because that is a OFP function...


The reason why bedges got into the boolean stuff is because of the lines
Code: [Select]
#out
? ammo : goto "out2"
ammo = true
player groupchat "d**n IM OUT OF AMMO"
in your script...

You have a variable called ammo there which you treat as a boolean and you can't do that since ammo is OFP function, and therefore reserved ...
« Last Edit: 17 Jun 2005, 20:45:00 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:some ammo of primary weapon
« Reply #18 on: 17 Jun 2005, 20:55:47 »
in programming, when something is 'reserved' it means it's needed by the operating system and thus cannot be used as a user-defined variable. for example, if i was to call myself 'tony blair', that'd be silly, because there already is one, and it's used by parliament. an example of a reserved variable in flashpoint would be 'time' or '_this'. these are variables that flashpoint uses.

more to the point, 'ammo' cannot be used as a variable as it's part of a command. '_ammo', as far as i know, would be fine as a local variable name.

the trick is to use commands to create a boolean check for true or false. looking over the previous posts, all the clues are there.

from THobson's post -

Quote
So you will probably have to use primaryWeapon to find which weapon the unit has then do something like:
_mags = ""
if (unit primaryWeapon == "m16") then {_mags = "m16mag"}
if (unit primaryWeapon == you get the idea...

this means that if the player might have different weapons, you need to make the script check which weapon it is, otherwise it won't work.

so you check which weapon the player has, and according to that, you decide which muzzle mode is needed for the 'ammo' command and take it from there...

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #19 on: 18 Jun 2005, 08:57:07 »
thanks alot HateR_Kint and Bedges i think i get it now i just need to test

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #20 on: 18 Jun 2005, 09:57:56 »
Quote
if (unit primaryWeapon == "m16") then {_mags = "m16mag"}
okay ive tried this but now im getting unknown operator or something on the code 'primaryweapon' ?
so i thought ill have a nother go with the code ammo, and im so near just this is the new script

Code: [Select]
_shooter = _this select 0
_amount = _this select 2
_mags = ""

#checkammo
? player ammo "M16" == 0 : goto "out"
? player ammo "XMS" == 0 : goto "out"
? player ammo "HK" == 0 : goto "out"
? player ammo "M21" == 0 : goto "out"
? player ammo "steyr" == 0 : goto "out"
? player ammo "ak74" == 0 : goto "out"
? player ammo "PK" == 0 : goto "out"
EXIT

#out
? ammoa : goto "out2"
ammoa = true
player groupchat "DAMN IM OUT OF AMMO"

#out2
if (50 > random 100) then {player groupchat "GOD DAMN IM OUT AGAIN!"} else {player groupchat "DAMN I NEED MORE AMMO"}

#exit
exit

but when i shoot i just get one thing wrong no error messages it just says the writing anyway and ive got exit after the code i also used the name of the weapon is this becuase im using an  XMS and the magazine is called 'M4' ?
i feel like im getting close
im also sorry to everyone who is helping this must feel like a pain in the arse for you and me.
but thanks for your help so far

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:some ammo of primary weapon
« Reply #21 on: 18 Jun 2005, 10:13:52 »
what is 'ammoa'?

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #22 on: 18 Jun 2005, 10:14:54 »
well i did use ammo = true and since that's a code in ofp i checnged it to ammoa = true

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:some ammo of primary weapon
« Reply #23 on: 18 Jun 2005, 10:15:37 »
again, what is 'ammoa'?

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #24 on: 18 Jun 2005, 10:18:00 »
well its not a code im using it to trigger if that part of the script has been activated and if it has it goes on to another part with new messages i supose its not really needed too much just
if ammoa = true then it moves on to anther part of the script so you get more radio text
dont ask why its called ammoa i just tapped any random button without looking and thats what i got so ive just left it like that

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:some ammo of primary weapon
« Reply #25 on: 18 Jun 2005, 10:27:25 »
okay. so once again, look at this part of the script:

Code: [Select]
#out
? ammoa : goto "out2"
ammoa = true
player groupchat "d**n IM OUT OF AMMO"

#out2
if (50 > random 100) then {player groupchat "GOD d**n IM OUT AGAIN!"} else {player groupchat "d**n I NEED MORE AMMO"}

assuming 'ammoa' is set to 'true' someplace else - as it isn't in this script - the script jumps to "out2".

if 'ammoa' is false, the script goes to the next line, which sets 'ammoa' to true, shows the first group chat, then moves down to the next line, #out2, and shows one of the other group chats.

looking at the rest of the code, let's say the unit has an m16. the script will get to the first line of #checkammo, and if the unit has no ammo, it will go to the #out sequence. fine.

what if the unit still has ammo in his m16?

then the script continues onto the next line. it then looks for xm3 ammo, finds none - as the unit has an m16 - and triggers the #out sequence.

what if the unit doesn't have an m16. what if the unit has the m21, with plenty of ammo? then the script goes to the first check, the m16, finds no m16 ammo, and jumps to the #out sequence....
« Last Edit: 18 Jun 2005, 10:27:46 by bedges »

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #26 on: 18 Jun 2005, 10:29:30 »
oh yeah i supose i need 'or' then well ill have a go with that and report back with what happens thanks alot

EDIT - Okay i tried or now and got no error message but ohh now i relised that or wont work because he doesnt have any of the other kind of ammo but atleast i got no error messages

EDIT 2 - okay i remembereed this is an event handler fired and _this select 1 is what weapon so i can do
? player ammo _weapname == 0 : goto "out"
EXIT
wich is what im about to try

TESTED and almost there and i think i know what to do now
« Last Edit: 18 Jun 2005, 10:45:19 by 456820 »

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #27 on: 18 Jun 2005, 10:51:22 »
okay my ideaa didnt work what it was is i remember seeing a command

magazines vehicle

Operand types:
vehicle: Object
Type of returned value:
Array
Description:
Returns array of types names of all vehicle's magazines.

Example:
magazines player
 
and i thought
magazines player == 0 but that didnt work
and nothing in the fired event handler to help about what kind of magazine used the closest is the amm type used
any more suggestions?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:some ammo of primary weapon
« Reply #28 on: 18 Jun 2005, 10:55:35 »
i have found that the best way to learn something is through trial and error, but in this case i'm just going to do it for you. see attached.
« Last Edit: 18 Jun 2005, 11:50:31 by bedges »

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #29 on: 18 Jun 2005, 12:01:27 »
thanks alot bedges im just testing it now