• Police Locker Not giving weapon
    2 replies, posted
My Server Side Network net.Receive("GivePolicePrimaryWeapon", function(len, pl) local weapon = net.ReadString() if PrimaryWeaponList[weapon] then local wepclass = PrimaryWeaponList[weapon].class local price = PrimaryWeaponList[weapon].price local money = pl:getDarkRPVar("money") if IsValid(pl) and pl:isCP() and money > price then if pl.hasBoughtWeapon == false or pl.hasBoughtWeapon == nil then pl:addMoney(-price) pl:Give(wepclass) pl:EmitSound("items/ammo_pickup.wav") pl.hasBoughtWeapon = true buyMessage(pl, wepclass, price, true) else pl:ChatPrint("You've already bought a weapon") end else pl:ChatPrint("You can't afford this or were demoted.") end end end) My client side Networking for k,v in pairs(PrimaryWeaponList) do local primariesback = vgui.Create( "DPanel", primaryarea) primariesback:Dock( TOP ) primariesback:SetSize( 0, 200 ) primariesback:DockMargin( 5, 5, 5, 5) primariesback.Paint = function (self, w, h ) surface.SetDrawColor( 75,75,75,50) surface.DrawRect(0,0,w,h) end local primariesnames = vgui.Create( "DLabel", primariesback) primariesnames:SetText(k) primariesnames:Dock( FILL ) primariesnames:DockMargin( 75, 5, 0, 0 ) primariesnames:SetFont( "policearmory" ) primariesnames:SetTextColor( Color(200,200,200,200) ) primariesnames:SetExpensiveShadow( 2, Color(0,0,0, 200) ) local primariesmodels = vgui.Create( "DModelPanel", primariesback) primariesmodels:Dock( FILL ) primariesmodels:SetCamPos( Vector( 0, 200, 0 ) ) primariesmodels:SetLookAng( Angle( 180, 90, 180 ) ) primariesmodels:SetModel(v.model) local primariesprice = vgui.Create( "DLabel", primariesback) primariesprice:SetText("Price: "..v.price) primariesprice:Dock( FILL ) primariesprice:DockMargin( 75, 60, 0, 0 ) primariesprice:SetFont( "policearmory" ) primariesprice:SetTextColor( Color(200,200,200,200) ) primariesprice:SetExpensiveShadow( 2, Color(0,0,0, 200) ) local primariesbutton = vgui.Create( "DButton", primariesback) primariesbutton:SetSize( 164, 30 ) primariesbutton:SetPos ( 650, 80 ) primariesbutton:SetText( "" ) primariesbutton.Paint = function( self, w, h ) draw.RoundedBox( 0, 0, 0,self:GetWide(),self:GetTall(),Color(45,45,45,50)) draw.SimpleText( "Purchase", "buytext", 30, 2, Color( 200, 200, 200, 200 ) ) end function primariesbutton:DoClick() net.Start("GivePolicePrimaryWeapon") net.SendToServer() end end my config PrimaryWeaponList = { ["M42"] = {price = 1000, class = "weapon_m42", model = "models/weapons/w_rif_m4a1.mdl"}, ["AK47 CUSTOM"] = {price = 1000, class = "weapon_ak47custom", model = "models/weapons/w_rif_ak47.mdl"}, ["AK472"] = {price = 1000, class = "weapon_ak472", model = "models/weapons/w_rif_ak47.mdl"}, ["PUMPSHOTGUN"] = {price = 1000, class = "weapon_pumpshotgun2", model = "models/weapons/w_shot_m3super90.mdl"}, ["SNIPER"] = {price = 1000, class = "ls_sniper", model = "models/weapons/w_snip_g3sg1.mdl"}, } then when i click the purchase button theres no error just does not give me the weapon
net.Start("GivePolicePrimaryWeapon") net.SendToServer() Should be: net.Start("GivePolicePrimaryWeapon") net.WriteString( k ) net.SendToServer()
thank you fixed
Sorry, you need to Log In to post a reply to this thread.