• Refer to keyvalues?
    5 replies, posted
  • 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" ] end[/lua] But that returns nil. How do I refer to a keyvalue? [img]http://img4.imageshack.us/img4/3423/kvals.png[/img]
  • 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.
  • 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.. [url]http://wiki.garrysmod.com/?title=ENT.KeyValue[/url]
  • [QUOTE=Crazy Quebec;16544597]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.[/QUOTE] 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: [QUOTE=Nevec;16544946]Try this hook.. [url]http://wiki.garrysmod.com/?title=ENT.KeyValue[/url][/QUOTE] Ok, I'll try this first Edited2: OMFG... I can't believe it actaully works!! Thank you so much! :DDDD