• Error when trying to create a custom entity for DarkRP
    3 replies, posted
I'm trying to create an entity for my Black Market Dealer that grants a player a gun license when picked up. Unfortunately, I'm having some troubles. My error: [CODE][ERROR] addons/darkrpmodification/lua/entities/forged_license/init.lua:28: attempt to call method 'SetDarkRPVar' (a nil value) 1. unknown - addons/darkrpmodification/lua/entities/forged_license/init.lua:28[/CODE] My code: [CODE]function ENT:Use( activator, caller ) if self.USED then return end self.USED = true if ( activator:IsPlayer() ) then -- Give the player a gun license if ( !activator.DarkRPVars.HasGunlicense ) then activator:SetDarkRPVar( "HasGunlicense", true ) -- Line 28, generating errors DarkRP.notify( activator, 0, 4, "Picked up a gun license." ) end end self:Remove() end[/CODE] How do I fix this?
It's a lowercase s: setDarkRPVar
Inside your if statement you have the wrong thing trying to detect if the player already has a license. Try using this [CODE]if(!activator:getDarkRPVar("HasGunlicense")) then[/CODE]
[QUOTE=code_gs;49302147]It's a lowercase s: setDarkRPVar[/QUOTE] Worked like a charm, thank you very much! [QUOTE=boxvader;49302158]Inside your if statement you have the wrong thing trying to detect if the player already has a license. Try using this [CODE]if(!activator:getDarkRPVar("HasGunlicense")) then[/CODE][/QUOTE] I've changed that as well. Thank you too!
Sorry, you need to Log In to post a reply to this thread.