Jump to content

Making a button to restock ammo help!


psrfreddyz06

Recommended Posts

I'm just trying to make a simple button which will restock (enable) some ammo on a shelf, and ammo itself are activators. I have this script from the different kinds of ammo:

scriptname shelfscript

begin OnActivate
if Getisid EHAmmo9mmP

player.additem Ammo9mmP 12
disable
endif

;---------------------------

elseif Getisid EHAmmo556mm

player.additem Ammo556mmArmorPiercing 24
disable
endif

;---------------------------

elseif Getisid EHAmmo44magnum

player.additem Ammo44MagnumHollowPoint 24
disable
endif

end

And then on the restock button i have this script:

scriptname infiniteammorestock

ref linkammo

Begin Onactivate

Set linkammo to Getlinkedref

if linkammo.GetDisabled

linkammo.enable

else

showmessage alreadystockedXXXX

endif

end

I'm a beginner when it comes to scripting and I've written these from scratch. All is working good except that i have the button linked to the first ammo, so the script ONLY restocks one of the ammos.. I've tried using the linked ref and linked all the ammo togheter. But only the first one get's enabled.. Any tips? Thanks!

Edited by psrfreddyz06
Link to comment
Share on other sites

Update: The only way i managed to get it to work is if i use a different restock button for every type of ammo.. Which is not what i want. Damn this is hard sometimes haha

 

Or if anyone could tell me if/how it is possible to link a button to multiple objects at once..

Edited by psrfreddyz06
Link to comment
Share on other sites

You could try giving each ammo activator it's own ref ID and referencing them in the script that way. It makes the script longer, but will allow you to restock several activators at once. Just add a new if statement for how ever many ammo activators you're using.

 

For example;

scn restockscript

begin onactivate

   if ammo1ref.getdisabled == 1
      ammo1ref.enable
   endif

   if ammo2ref.getdisabled == 1
      ammo2ref.enable
   endif

end

Hope that helps.

Edited by SGTbayk47
Link to comment
Share on other sites

You could try giving each ammo activator it's own ref ID and referencing them in the script that way. It makes the script longer, but will allow you to restock several activators at once. Just add a new if statement for how ever many ammo activators you're using.

 

For example;

scn restockscript

begin onactivate

   if ammo1ref.getdisabled == 1
      ammo1ref.enable
   endif

   if ammo2ref.getdisabled == 1
      ammo2ref.enable
   endif

end

Hope that helps.

Dude you are AWESOME!! Exactly what i wanted. Thank you. Curious, if i where to put "if ammo1ref.getdisabled == 0" instead of 1, would that mean IF ammo1ref is enabled instead of disabled?

Link to comment
Share on other sites

Yes ... getdisabled returns 1 if the ref is disabled ... therefore 0 = not disabled , or in other words enabled

 

Most all of the functions are that way ... the intuitive question they ask is ... true =1 , false = 0

 

err I should say that another way ...

 

If the function is asking a yes or no question ... 1 = yes , 0 = no

 

With "GetDisabled" there is no other possibility than ... Disabled = 1/yes or Enabled =0/no

 

All of the "Get" & "Is" functions are for asking questions (conditions)

and the "has" and just a few others.

The rest are commands

Edited by Mktavish
Link to comment
Share on other sites

Yes ... getdisabled returns 1 if the ref is disabled ... therefore 0 = not disabled , or in other words enabled

 

Most all of the functions are that way ... the intuitive question they ask is ... true =1 , false = 0

 

err I should say that another way ...

 

If the function is asking a yes or no question ... 1 = yes , 0 = no

 

With "GetDisabled" there is no other possibility than ... Disabled = 1/yes or Enabled =0/no

 

All of the "Get" & "Is" functions are for asking questions (conditions)

and the "has" and just a few others.

The rest are commands

Thank you very much! I understand much better now! :D

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...