• Darkrp: Disabling entities for certain variables
    2 replies, posted
Hi guys. We were cleaning up a 'npc shop' character and would like it so when you buy the item in the store it enables an entity in the f4 menu. Anyways we have already done all the npc shop just need a way to disable/enable the entities from pdata. Here is the init.lua of the NPC entity. [LUA]function BuySMGPack(ply, ent) smgPack = 20000 if ply:GetPData( "smgpack" ) == "1" then Notify(ply, 1, 4, string.format("You already have this item!")) elseif not ply:CanAfford(smgPack) then Notify(ply, 1, 4, "You can't afford it") return "" else ply:AddMoney(-smgPack) ply:SetPData( "smgpack", 1 ) Notify(ply, 1, 4, "You can now buy SMGs!") end end concommand.Add("buy_smgpack", BuySMGPack)[/LUA] That all works fine. When you buy the item it sets "smgpack" to 1. Now for addentities.lua we tried this but it didn't work. I was thinking it has to be included properly or something? [LUA]AddCustomShipment("MP5", "models/weapons/w_smg_mp5.mdl", "weapon_mad_mp5", 3200, 5, false, 0, false, {TEAM_GUN}, function(ply) return ply:GetPData("smgpack") == 1 end)[/LUA] If you need more info just holler :D
the functions in addentities.lua and shared.lua have been buggy in 2.4.2 :\ I'd stay clear of them, and just write code around it.
The shipment adding in addentities only gets called at the beginning of the gamemode. You'll need to update the table "CustomShipments" somehow in order to make it work.
Sorry, you need to Log In to post a reply to this thread.