• What do you need help with? V3
    6,419 replies, posted
I'm making a token shop in TTT, and it's all working except one bit. I'm trying to make it so I can set whether users can buy items or not using ply:CanBuy(), but it isn't working. I've tried this to get the ply:CanBuy() working [CODE]function _R.Player:CanBuy( ) if !self:Alive() or self:Team() == TEAM_SPEC then return false else return true end[/CODE] but I get this error when I try use it with the code below the error. [QUOTE][ERROR] addons/tokenshop/lua/autorun/server/sv_cmds.lua:66: attempt to call method 'CanBuy' (a nil value) 1. unknown - addons/tokenshop/lua/autorun/server/sv_cmds.lua:66 2. unknown - lua/includes/modules/concommand.lua:69 [/QUOTE] [CODE]concommand.Add("buyitem", function( p, c, a ) if a[1] == NULL then return end local id = tonumber( a[1] ) if !p:CanBuy() then p:ChatPrint("Please wait for the round to start before purchasing an item.") return end for k, v in pairs( Store.ItemsTable ) do if k == id then if p:GetTokens() >= v[2] then p:BuyItem( k ) break else p:ChatPrint( "You dont have enough tokens to buy this!" ) end end end end[/CODE] Any help would be much appreciated
[QUOTE=jarikfw;38663227]http://puu.sh/1whQO how could i make it so? hook.Add PlayerDeath than remove trail/smoke[/QUOTE] OHH UMM YOU JUST SET IT TO NOT DRAW
i'll rephrase my question to make it less confusing let's say i have a func_brush on the server, and when someone stands on it and jumps (OnEndTouch), the server prints a message it's possible right?
[QUOTE=Kwaq;38669023]i'll rephrase my question to make it less confusing let's say i have a func_brush on the server, and when someone stands on it and jumps (OnEndTouch), the server prints a message it's possible right?[/QUOTE] One way would be to check if players are standing on it, and pressing space, in a think hook. But that might be a bit messy. Another way is to loop through all the func_brushes on the map and remove them (once, when the map loads, of course), and spawn your own Lua entities in their place, which have an OnEndTouch function.
[img]http://screencloud.net/img/screenshots/52e7b48683e2594880c69c073d22fee3.png[/img] i tried that initially, but as you can see it removes the brushes (replacing with a model wouldn't work in this case) if there were a way to keep the world geometry for an existing ent on a sent it would be great
I've made a custom weapon for my TTT server but the icon in the traitor shop and killed body isn't showing, it's still just a pink and black texture. Where do I put the .vmt and .vtf files in the server files? [QUOTE]-- Equipment menu information is only needed on the client if CLIENT then -- Path to the icon material SWEP.Icon = "VGUI/ttt/icon_offisir_crossbow" -- Text shown in the equip menu SWEP.EquipMenuData = { type = "Weapon", desc = "Powerful silenced long range weapon. /n Only has one bolt. /n Unlimited purchases, 1 bolt per purchase." }; end -- Tell the server that it should download our icon to clients. if SERVER then -- It's important to give your icon a unique name. GMod does NOT check for -- file differences, it only looks at the name. This means that if you have -- an icon_ak47, and another server also has one, then players might see the -- other server's dumb icon. Avoid this by using a unique name. resource.AddFile("materials/VGUI/ttt/icon_offisir_crossbow.vmt") end [/QUOTE]
[QUOTE=Kwaq;38669901][IMG]http://screencloud.net/img/screenshots/52e7b48683e2594880c69c073d22fee3.png[/IMG] i tried that initially, but as you can see it removes the brushes (replacing with a model wouldn't work in this case) if there were a way to keep the world geometry for an existing ent on a sent it would be great[/QUOTE] I'm not a mapping person so I'm a little lost on what func_brush even does, but wouldn't it be easier to make an entity that does what you need? I did something similar before, created info_target entities on the map wherever I wanted my entity to be. Then when the game startd I just spawned the custom entity onto all of those info_target points. Gives you more flexibility with the entity and makes mapping less complex for people who want to help.
[QUOTE=prang123;38668295]I'm making a token shop in TTT, and it's all working except one bit. I'm trying to make it so I can set whether users can buy items or not using ply:CanBuy(), but it isn't working. I've tried this to get the ply:CanBuy() working [CODE]function _R.Player:CanBuy( ) if !self:Alive() or self:Team() == TEAM_SPEC then return false else return true end[/CODE] but I get this error when I try use it with the code below the error. [CODE]concommand.Add("buyitem", function( p, c, a ) if a[1] == NULL then return end local id = tonumber( a[1] ) if !p:CanBuy() then p:ChatPrint("Please wait for the round to start before purchasing an item.") return end for k, v in pairs( Store.ItemsTable ) do if k == id then if p:GetTokens() >= v[2] then p:BuyItem( k ) break else p:ChatPrint( "You dont have enough tokens to buy this!" ) end end end end[/CODE] Any help would be much appreciated[/QUOTE] Bump. Still need help with this
change a[1] == NULL to a[1] == nil
How can I send a message between the server and an entity?
Once again, does anyone know how to use the OpeningURL functions? [lua] HtmlFrame:SetSize(500,500) HtmlFrame:SetPos( 10,10) HtmlFrame:OpenURL("http://facepunch.com/") HtmlFrame.FinishedURL = function (url) print("Loaded: "..url) end HtmlFrame.OpeningURL = function (url) print("Opening: "..url) end [/lua]
Why do you have the [URL] tags there?
I think the form did that automaticaly [editline]1st December 2012[/editline] forum*
[QUOTE=Banana Lord.;38671098]I think the form did that automaticaly [editline]1st December 2012[/editline] forum*[/QUOTE] You are correct sir.
[QUOTE=101kl;38670938]Once again, does anyone know how to use the OpeningURL functions? [lua] HtmlFrame:SetSize(500,500) HtmlFrame:SetPos( 10,10) HtmlFrame:OpenURL("http://facepunch.com/") HtmlFrame.FinishedURL = function (url) print("Loaded: "..url) end HtmlFrame.OpeningURL = function (url) print("Opening: "..url) end [/lua][/QUOTE] What if you create HtmlFrame.OpeningURL function before opening the url, does it even matter?
[QUOTE=ollie;38674751]What if you create HtmlFrame.OpeningURL function before opening the url, does it even matter?[/QUOTE] I doubt it, but i will try that anyway. [B]Edit:[/B] No such luck. Produces same results, page loads but nothing sent to console.
[QUOTE=101kl;38675011]I doubt it, but i will try that anyway. [B]Edit:[/B] No such luck. Produces same results, page loads but nothing sent to console.[/QUOTE] [lua] HtmlFrame.HTML.FinishedURL = function( panel, url, target, postdata, bredirect ) print("Loaded: "..url) end HtmlFrame.HTML.OpeningURL = function( panel, url, target, postdata, bredirect ) print("Opening: "..url) end [/lua]
[QUOTE=prang123;38668295]I'm making a token shop in TTT, and it's all working except one bit. I'm trying to make it so I can set whether users can buy items or not using ply:CanBuy(), but it isn't working. I've tried this to get the ply:CanBuy() working [CODE]function _R.Player:CanBuy( ) if !self:Alive() or self:Team() == TEAM_SPEC then return false else return true end[/CODE] but I get this error when I try use it with the code below the error. [CODE]concommand.Add("buyitem", function( p, c, a ) if a[1] == NULL then return end local id = tonumber( a[1] ) if !p:CanBuy() then p:ChatPrint("Please wait for the round to start before purchasing an item.") return end for k, v in pairs( Store.ItemsTable ) do if k == id then if p:GetTokens() >= v[2] then p:BuyItem( k ) break else p:ChatPrint( "You dont have enough tokens to buy this!" ) end end end end[/CODE] Any help would be much appreciated[/QUOTE] don't use _R, use a local variable whose value is set to FindMetaTable("Player"), then replace your _R.Player with that variable
[QUOTE=find me;38675166][lua] HtmlFrame.HTML.FinishedURL = function( panel, url, target, postdata, bredirect ) print("Loaded: "..url) end HtmlFrame.HTML.OpeningURL = function( panel, url, target, postdata, bredirect ) print("Opening: "..url) end [/lua][/QUOTE] Console is spitting out the following when using that method: [code]attempt to index field 'HTML' (a nil value)[/code]
[QUOTE=101kl;38675261]Console is spitting out the following when using that method: [code]attempt to index field 'HTML' (a nil value)[/code][/QUOTE] The vgui you are creating is HTML right? vgui.Create( "HTML" ) [editline]2nd December 2012[/editline] That last post was just a shot in the dark by the way. :p [editline]2nd December 2012[/editline] [code] vgui: Adding child in layout!vgui: Adding child in layout!vgui: Adding child in layout!vgui: Adding child in layout!vgui: Adding child in layout! [/code] Yes thank you for telling me what I am doing, but why is this error here? I don't understand how creating a vgui in PerformLayout then parenting it to that main vgui is bad. It works, how it should, although if you open the console you get all that garbage. Not to mention it can't be done in init because the size of the panel is not ready at that time.
Why can I not get this code to work... problem after problem. "Error!: MySQL server has gone away" "Duplicate entry" How can I get what thought to be a basic setup, to work? Any help is appreciated. [lua] function sql_newplayer(ply) local query2 = db:query("INSERT INTO player_info(steamid, name, money) VALUES ('".. ply:Nick() .. "', '" .. ply:SteamID() .. "', '" .. '500' .. "')") query2.onSuccess = function(q) print("Player added to database!") end query2.onError = function(q, e, s) print("SQL Error!: " .. e .. " " .. s) end query2:start() end function sql_checkplayerexists(ply) local query1 = db:query("SELECT * FROM player_info WHERE steamid = '" .. ply:SteamID() .. "'") query1.onSuccess = function(q) if (query1:getData()[1] ~= nil) then print("Player exists!") else sql_newplayer(ply) end end query1.onError = function(q, e) print("Error!: " .. e) end query1:start() end [/lua]
[QUOTE=NintendoEKS;38675535]Why can I not get this code to work... problem after problem. "Error!: MySQL server has gone away" "Duplicate entry" How can I get what thought to be a basic setup, to work? Any help is appreciated. [lua] function sql_newplayer(ply) local query2 = db:query("INSERT INTO player_info(steamid, name, money) VALUES ('".. ply:Nick() .. "', '" .. ply:SteamID() .. "', '" .. '500' .. "')") query2.onSuccess = function(q) print("Player added to database!") end query2.onError = function(q, e, s) print("SQL Error!: " .. e .. " " .. s) end query2:start() end function sql_checkplayerexists(ply) local query1 = db:query("SELECT * FROM player_info WHERE steamid = '" .. ply:SteamID() .. "'") query1.onSuccess = function(q) if (query1:getData()[1] ~= nil) then print("Player exists!") else sql_newplayer(ply) end end query1.onError = function(q, e) print("Error!: " .. e) end query1:start() end [/lua][/QUOTE] You're getting the MySQL has gone away error because you haven't communicated with the server for a time defined in wait_timeout. I simply made a timer which made a query every 30 seconds to avoid the MySQL server to go away. I can't tell if that's the smartest solution but it solved the problem.
Can someone tell me if it is possible to create a controllable NPC? And I mean as good as the player, with smooth and precise aiming and movement. I need to know that before I go further into my gamemode. I plan to make the player control some NPCs and make them use custom weapons.
Could anyone help me fixing this error? [ERROR] gamemodes/darkrp/entities/entities/slot_machine/init.lua:215: attempt to index a nil value 1. unknown - gamemodes/darkrp/entities/entities/slot_machine/init.lua:215 function ENT:Think() if self.Spinning then if self.Wheels[3].StopTime and CurTime() >= self.Wheels[3].StopTime then self:AnnounceResults(); end end self:NextThink(CurTime() + .01); return true end Any help is appreciated.
What line is #215? Where did you define those variables and functions? Use [[b][/b]lua]
[QUOTE=Darkwater124;38676055]What line is #215? Where did you define those variables and functions? Use [[b][/b]lua][/QUOTE] Thanks for the fast reply. I got that error fixed, now i'm getting this error instead. [ERROR] gamemodes/darkrp/entities/entities/slot_machine/init.lua:139: attempt to index global 'Player' (a function value) 1. unknown - gamemodes/darkrp/entities/entities/slot_machine/init.lua:139 [lua] local RP = RecipientFilter(); RP:AddPVS(Player:GetPos()); RP:AddPlayer(Player); [/lua]
Been trying to get the TextEntry to work but it just stays blank :/ [lua] local ParentPanel = vgui.Create("DFrame") ParentPanel:SetSize(ScrW()/7, ScrH()/12) ParentPanel:Center() ParentPanel:SetTitle("Text Color Test") ParentPanel:SetDeleteOnClose(true) ParentPanel:MakePopup() local TextEntry = vgui.Create( "DTextEntry", ParentPanel ) TextEntry:SetSize(ScrW()/9, ScrH()/30) TextEntry:SetValue("Text Color Test") TextEntry:SetPos(ParentPanel:GetWide()/2-TextEntry:GetWide()/2, ParentPanel:GetTall()/2-TextEntry:GetTall()/5) TextEntry:SetEnterAllowed(false) -- Uses Simple RGBA (Red, Green, Blue, Alpha) Colors. -- TextEntry:SetTextColor(0,0,255,255) TextEntry:RequestFocus() [/lua] [url]http://gyazo.com/c96f76c370477c11897b3b32e622f6a4.png?1354460216[/url] ^ that has text in it btw
I think TextEntry:SetTextColor should take a color object instead of 4 numbers, try [lua] TextEntry:SetTextColor(Color(0,0,255,255)) [/lua]
[QUOTE=Drakehawke;38676195]I think TextEntry:SetTextColor should take a color object instead of 4 numbers, try [lua] TextEntry:SetTextColor(Color(0,0,255,255)) [/lua][/QUOTE] Thanks it worked
[QUOTE=quentuz;38676100]Thanks for the fast reply. I got that error fixed, now i'm getting this error instead. [ERROR] gamemodes/darkrp/entities/entities/slot_machine/init.lua:139: attempt to index global 'Player' (a function value) 1. unknown - gamemodes/darkrp/entities/entities/slot_machine/init.lua:139 [lua] local RP = RecipientFilter(); RP:AddPVS(Player:GetPos()); RP:AddPlayer(Player); [/lua][/QUOTE] Don't call a variable 'Player'
Sorry, you need to Log In to post a reply to this thread.