1. Post #1
    Gold Member
    Robert64's Avatar
    November 2007
    1,326 Posts
    I've placed a custom entity in hammer, and set a keyvalue called "Cost" to 750 (see below).
    In the entity's init.lua I'm trying to get this keyvalue like this:
    function ENT:Initialize()
    
    	self.RoomOwner = nil
    	self.DoorOpen = false
    	
    	local keyVals = self.Entity:GetKeyValues()
    	
    	self.Cost = keyVals[ "Cost" ]
    
    end
    But that returns nil. How do I refer to a keyvalue?


  2. Post #2
    Gold Member
    Crazy Quebec's Avatar
    May 2008
    2,449 Posts
    I can't really answer this directly right now(on my Wii), but shouldn't you be doing that part entirely trough lua instead of setting static data directly into the map? It would give you alot more control and is something you'll have to do anyway if you want to have the doors owned.

  3. Post #3
    Gold Member
    Saint Devil's Avatar
    January 2009
    227 Posts
    How would you do it through lua? I've always wanted to do something like this.

  4. Post #4
    Gold Member
    Crazy Quebec's Avatar
    May 2008
    2,449 Posts
    Well the simplest way would be to create a table of all of the map's doors and index them by their entID, and then save that to a txt\sqlLite and load it on map load. Then use admin commands\sweps to go around the map and set the door propreties. You could look at DarkRP for an example of that.

  5. Post #5
    Gold Member
    Nevec's Avatar
    June 2008
    1,091 Posts

  6. Post #6
    Gold Member
    Robert64's Avatar
    November 2007
    1,326 Posts
    I can't really answer this directly right now(on my Wii), but shouldn't you be doing that part entirely trough lua instead of setting static data directly into the map? It would give you alot more control and is something you'll have to do anyway if you want to have the doors owned.
    I guess I'll have to add an admin command to set the price of each room in-game, and save it to a txt file for each map then.
    Thanks anyway

    Edited:

    Ok, I'll try this first

    Edited2:

    OMFG... I can't believe it actaully works!! Thank you so much! :DDDD