1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Store variable in dropped weapons?

Discussion in 'DarkRP Modding Questions & Help' started by flamecow, Oct 15, 2013.

  1. flamecow

    flamecow New Member

    I have a variable in each of my SWEPs that needs to be saved when the weapon is dropped - is there some way to do this without modifying core files? Thanks in advance!
  2. Scottie

    Scottie ~ Ent:King Dev ~ Contributor

    This thread is very indetailed. What var?
  3. flamecow

    flamecow New Member

    Sorry, wasn't sure of the best way of describing this. There's a variable in my SWEP base (stored like SWEP.Variable = x) and I'd like for it to be saved when the gun is dropped. Currently, when the gun is dropped, it resets the variable. Essentially, I want guns to have qualities (changes in stats - like a gun can be in terrible or excellent condition); I've done this already, I'm just having trouble with getting the variable to save. Hopefully that is an alright explanation.
  4. (FPtje) Atheos

    (FPtje) Atheos Main Developer Staff Member

    I added two hooks to help you out, but you'll need to update to the latest DarkRP 2.5.0.

    Have an example:
    Code (Lua):

    hook.Add("onDarkRPWeaponDropped", "yourThing", function(ply, spawned_weapon, original_weapon)
        print(ply, spawned_weapon, original_weapon)
        spawned_weapon.var = original_weapon.var

    hook.Add("PlayerPickupDarkRPWeapon", "alsoYourThing", function(ply, spawned_weapon, real_weapon)
        real_weapon.var = spawned_weapon.var
  5. flamecow

    flamecow New Member

    Thanks! I appreciate it a lot.

Share This Page