[ERROR] addons/police_armory_ent/lua/entities/asdasd/init.lua:50: attempt to index global 'WeaponList' (a nil value)
Shared:
WeaponList1 = {
["Сlaws"] = {price = 1000, class = "weapon_claws"},
["Colt Python"] = {price = 1100, class = "m9k_coltpython"},
["Raging Bull"] = {price = 1300, class = "m9k_m3"},
["Benelli M3"] = {price = 1600, class = "m9k_m3"},
["Ithaca M37"] = {price = 1700, class = "m9k_ithacam37"},
["Remington 870"] = {price = 1500, class = "m9k_remington870"},
["1897 Winchester"] = {price = 1800, class = "m9k_1897winchester"},
["Acr"] = {price = 1600, class = "m9k_acr"},
["M14"] = {price = 1800, class = "m9k_m14sp"},
}
Init
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
util.AddNetworkString("PoliceArmory1")
util.AddNetworkString("GivePoliceWeapon1")
function ENT:Initialize()
self:SetModel("models/props_c17/Lockers001a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
end
/*
Caller Menu
*/
function ENT:Use(pl)
if pl:isCP() then
net.Start( "PoliceArmory1" )
net.Send(pl)
else
pl:ChatPrint("[Police Armory] Sorry,only for the police")
end
end
/*
net.Receive()
*/
net.Receive("GivePoliceWeapon1", function(len,pl)
local weapon = net.ReadString()
if WeaponList[weapon] and pl:isCP() then
local wepclass = WeaponList[weapon].class
local money = WeaponList[weapon].price
if pl:HasWeapon(wepclass) then pl:ChatPrint("You already have this weapon!") pl:EmitSound("buttons/blip1.wav") return end
if pl:canAfford(money) then
local wep = pl:Give(wepclass)
pl:addMoney(-money)
pl:EmitSound("items/itempickup.wav")
pl:ChatPrint("[Police Armory] You bought - "..weapon)
wep.GivenByCP = true
else
pl:ChatPrint("[Police Armory] Not enough money!")
pl:EmitSound("buttons/blip1.wav")
end
end
end)
Rename WeaponList1 to WeaponList
Same mistake.
Is it the same error?
Yes
change it every instance.
like is a very poor code omggggg
I also recommend you to make a TakeMoney method that does the opposite as GiveMoney, this will make your code a lot more clear in the future.
Sorry, you need to Log In to post a reply to this thread.