Refer to keyvalues?

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:
[lua]function ENT:Initialize()

self.RoomOwner = nil
self.DoorOpen = false

local keyVals = self.Entity:GetKeyValues()

self.Cost = keyVals[ "Cost" ]

But that returns nil. How do I refer to a keyvalue?

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.

How would you do it through lua? I’ve always wanted to do something like this.

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.

Try this hook…

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


Ok, I’ll try this first


OMFG… I can’t believe it actaully works!! Thank you so much! :DDDD