Home   Help Search Login Register  

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

0 Members and 1 Guest are viewing this topic.

Offline 456820

  • Contributing Member
  • **
some ammo of primary weapon
« on: 11 Jun 2005, 10:32:16 »
okay ive got this script
here it is
Code: [Select]
? !someAmmo player : goto "out"
? someAmmo player : goto "exit"

#out
? ammo : goto "ammo2"
player groupchat "Damn im out of ammo"
ammo = true
EXIT

#ammo2
player groupchat "God damn it im out of ammo again"
EXIT
#exit
EXIT

that detects if the player is out of ammo but only out of primary and secondary weapons so im wondering how i can turn it into just primary weapon say the player is out of m16 ammo he says damn im out of ammo for example
how would this be done

Note - im running this through a fired event handler from the players init field if that makes a difference also there is a weapon selection so it cant just be one weapon has to be any primary rifle

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:some ammo of primary weapon
« Reply #1 on: 11 Jun 2005, 10:58:25 »
What about some combination of

unit ammo magazine

and
primaryWeapon vehicle

unit ammo primaryWeapon unit
would be where I would start.  It may need some tweeking to make it work

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #2 on: 11 Jun 2005, 11:37:43 »
ill have a go right now
thanks

EDIT - didnt work i tried
? someammo primaryWeapon player == 0 : goto "out"
and also
player ammo primaryWeapon player :  goto "out"
« Last Edit: 11 Jun 2005, 11:43:31 by 456820 »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:some ammo of primary weapon
« Reply #3 on: 11 Jun 2005, 12:17:42 »
This is a comment on ammo from Gereral Barron in comref:

Quote
Actually, the syntax for this command is incorrect. Really it works like this:

unit ammo muzzle

Where "muzzle" is a weapon's muzzle name. Often this is the same as the weapon's name, but sometimes it is different. Weapons can have multiple muzzles, such as the m16+grenades.

You can find what muzzle you are firing by putting this in the player's init field:
Quote:this addEventHandler ["fired", {hint format [{Muzzle = "%1"}, _this select 2]}];


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
etc.
etc.

then check unit ammo _mags

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:some ammo of primary weapon
« Reply #4 on: 11 Jun 2005, 12:17:49 »
Don't use someammo, it has no usage in this...

Quote
player ammo primaryWeapon player :  goto "out"
? (player ammo (primaryWeapon player)) == 0: goto "out"

This worked in a script I made a while ago..
« Last Edit: 11 Jun 2005, 12:18:42 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 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #5 on: 11 Jun 2005, 12:58:33 »
ill try both of those ideas thanks
also i thought the command was someammo not just ammo
anyway ill have a go

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #6 on: 12 Jun 2005, 11:05:03 »
HateR_Kint that kind of works but when his mag is emptu then it runs but the player still hs another 3 full mags

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:some ammo of primary weapon
« Reply #7 on: 12 Jun 2005, 11:58:08 »
Ah, I see..
So then you need to check whether the unit has the mags left and then check that ammo too..

So, first you check whether the unit has the mags you want or not and if not, exit and don't go to the ammo check yet, something like:

Code: [Select]
#checkmags
? (primaryWeapon player) in (magazines player): exit
goto "checkammo"

#checkammo
? (player ammo (primaryWeapon player)) == 0: goto "out"
exit

No guarantees whatsoever... :P

Of course that method requires that the magazine is named the same as the weapon itself, like "M16"...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #8 on: 12 Jun 2005, 15:45:24 »
okay thanks ill have a go at it

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #9 on: 16 Jun 2005, 17:45:13 »
right ive had a go with what i have so far and have come up with this

Code: [Select]
#checkmags
? (primaryWeapon player) in (magazines player) : exit
goto "checkammo"

#checkammo
? player ammo primaryWeapon player == 0 : goto "out"

#out
? ammo : goto "out2"
ammo = 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

but it doesnt work but were close the line that doesnt work is
Code: [Select]
? player ammo primaryWeapon player == 0 : goto "out"even though not long ago it worked perfectly but not now for some weird reason doe anyone know why ?
It says something like

Code: [Select]
? player #ammo primaryWeapon player == 0 : goto "out" : error unknown operator ammoso the command ammo is wrong but i checked in the com ref and it should work

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:some ammo of primary weapon
« Reply #10 on: 16 Jun 2005, 17:52:40 »
look again at hateR_kint's syntax -

Code: [Select]
? (player ammo (primaryWeapon player)) == 0: goto "out"
can anyone say 'brackets'?

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #11 on: 16 Jun 2005, 18:05:20 »
thanks but that doesnt work though it just kind of skips that line and carry's on with the script even though hes only shot one round so i start getting my out of ammo messages when ive got ammo ?

EDIT - next time i tried i got the unknown operator message on the command ammo
« Last Edit: 16 Jun 2005, 18:11:07 by 456820 »

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #12 on: 17 Jun 2005, 17:52:58 »
Quote
_player = _this select 0
_ammo = _this select 2

#checkmags
? (primaryWeapon player) in (magazines player) : exit
goto "checkammo"

#checkammo
? _player ammo _ammo == 0 : goto "out"

#out
? ammo : goto "out2"
ammo = 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

ive now tried this script but still unkown operator ammo and ive resulteed in trying the variables such as _ammo = _this select 2
but still no luck for some reason plus im not to sure if the magazine count is working as it just carry's on through the script when ive got 4 mags left ?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:some ammo of primary weapon
« Reply #13 on: 17 Jun 2005, 18:47:00 »
will this always involve an m16? or is this script going to be called for a unit who may have any type of weapon?

Offline 456820

  • Contributing Member
  • **
Re:some ammo of primary weapon
« Reply #14 on: 17 Jun 2005, 18:51:09 »
different types i have a list of the weapons if needed
oh well why not

Beretta
Binocular
HK
LAWLauncher
M16
M21
Steyr

that should be all of them