• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=iJohnny;51689324]You must call [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/AddCSLuaFile]AddCSLuaFile[/url] from serverside and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/include]include[/url] from clientside [code]if SERVER then AddCSLuaFile("cl_hud.lua") else include("cl_hud.lua") end[/code][/QUOTE] Tks but I already did
[QUOTE=YoutoYokodera;51691557]Tks but I already did[/QUOTE] So you've [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/AddCSLuaFile]AddCSLuaFile[/url]'d the file in init.lua, and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/include]include[/url]'d it in cl_init.lua? If so, put a print in the file so you can see if it's loading.
[code] local F3Menu, F3SubMenu, F3Display local function DrawButtons(parent) -- This function is working flawlessly... -- Applicable Code: F3Menu:SetVisible(true) F3Menu:SetDeleteOnClose(false) F3Menu:ShowCloseButton(false) -- More unnecessary code follows end local function GameF3Menu() if !IsValid(F3Menu) then local parent = DrawMenu() --Draws the DFrame, and returns the DFrame for parenting AddButtons(parent) else if(F3Menu:IsVisible()) then F3Menu:SetVisible(false) gui.EnableScreenClicker(false) else F3Menu:SetVisible(true) gui.EnableScreenClicker(true) end end end local function F3Check() local MYTEAM = LocalPlayer():Team() if MYTEAM ~= 6 then GameF3Menu() end end concommand.Add("selectweapons", F3Check) [/code] Greetings, and thank you in advance! I am trying to build an F3 Menu (obviously), and I want the menu to refresh every single time it's re-opened. The reason is, is because Team 6 has different weapons available in the menu (let's say it's the admin team for simplicity). Due to this, Teams 1-5 need to be able to have the same buttons, but team 6 has totally different buttons. It works fine the first time the menu is drawn; Teams 1-5 has their weapons and Team 6 has their weapons. The problem comes when you switch from Team 1 to Team 6. The menu shows the buttons for Team 1, and vice versa.
[QUOTE=Shenesis;51692974]could you perhaps take a screenshot of your gamemode's file structure? Even better (though I'll understand if you don't want to), compress and upload the whole thing and post the link here/send the link to me in PM, to try and find the issue?[/QUOTE] Thanks but I already solved it with a very strange way I restart my pc after restart gmod many times and it works magically
I have no idea what PLAYER: SetupDataTables do Can someone explain it for me? And if I add networkvar to it and put that on player spawn it will set the var to the default everytime a person join? [editline]19th January 2017[/editline] Oh great where my merge
[QUOTE=YoutoYokodera;51693642]I have no idea what PLAYER: SetupDataTables do Can someone explain it for me? And if I add networkvar to it and put that on player spawn it will set the var to the default everytime a person join? [/QUOTE] It's equivalent to [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/SetupDataTables]ENT:SetupDataTables[/url] for players, that is it a hook in which you can create networked values and add setter and getter functions for them (using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/NetworkVar]Entity:NetworkVar[/url]). The system used internally for it (afaik) is the same of that being used for NW2.
[QUOTE=bigdogmat;51693784]It's equivalent to [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/SetupDataTables]ENT:SetupDataTables[/url] for players, that is it a hook in which you can create networked values and add setter and getter functions for them (using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/NetworkVar]Entity:NetworkVar[/url]). The system used internally for it (afaik) is the same of that being used for NW2.[/QUOTE] [QUOTE=YoutoYokodera;51693642] And if I add networkvar to it and put that on player spawn it will set the var to the default everytime a person join?[/QUOTE] [editline]19th January 2017[/editline] And is this way the best way to add var like money to player
[QUOTE=YoutoYokodera;51694012][editline]19th January 2017[/editline] And is this way the best way to add var like money to player[/QUOTE] Yes and no, networked variables setup using either of those methods will only be networked to entities within their pvs. Because of that if you for example wanted to display the money of everyone on the server, you'd have to use another method such as the normal NW system, or net messages. [editline]19th January 2017[/editline] [QUOTE=YoutoYokodera;51693642] And if I add networkvar to it and put that on player spawn it will set the var to the default everytime a person join?[/QUOTE] What do you mean? If you set the value then yes, there's no default.
[QUOTE=bigdogmat;51694028]Yes and no, networked variables setup using either of those methods will only be networked to entities within their pvs. Because of that if you for example wanted to display the money of everyone on the server, you'd have to use another method such as the normal NW system, or net messages. [/QUOTE] Alright thanks Not that clearly but it gave me the concept I'll try and come back if anything pop up
Hi, I'm trying to mute player footsteps, by viewing the wiki [URL="http://wiki.garrysmod.com/page/GM/PlayerFootstep"]http://wiki.garrysmod.com/page/GM/PlayerFootstep[/URL] it should be that [CODE] KInvisible = Color(255,255,255,0) local function PlayerFootstep(ply, pos, foot, sound, volume, filter) if ply:GetColor() == KInvisible then return true end end hook.Add("PlayerFootstep", "sls_MuteFootsteps_Invisible", PlayerFootstep) [/CODE] But just nothing happen, any idea ? [B]Edit:[/B] Apparently it just work called in a 'Shared context' (muting sound) and I was calling it server-side
Try printing their color
If I have a PANEL:Paint() function and then I call it later in a separate function to refresh it, will it remove the previous paint and replace it or will it just paint over the old?
[QUOTE=PigeonTroll;51696882]If I have a PANEL:Paint() function and then I call it later in a separate function to refresh it, will it remove the previous paint and replace it or will it just paint over the old?[/QUOTE] You shouldn't have to ever refresh it yourself.. what are you trying to do?
[QUOTE=MPan1;51696971]You shouldn't have to ever refresh it yourself.. what are you trying to do?[/QUOTE] You're right, I had a variable that changed whenever the player equipped or holstered an item which affected the color of something - I didn't realize that it automatically updates.
I set my variable on player, and once I print it, It's nil. Can someone explain me this? When I play single-player It works, but when I change the players counts so it becomes multiplayer, It won't work. [lua] local ply = net.ReadEntity() local items = net.ReadTable() ply.PS_Items = items print(items) -- Output: table:0x3feb3ac0 print(ply.PS_Items) -- Output: nil [/lua]
Did you check if ply is nil? you might be sending it too early
[QUOTE=gonzalolog;51698833]Did you check if ply is nil? you might be sending it too early[/QUOTE] Yes that's it, My player entity is NULL, seems like there's an issue with the garry's mod it self. It works perfectly fine on dedicated-servers, Just not on the gmod built-in server. Needs a little delay If your functions are getting called from PlayerInitialSpawn, Since player loads faster than the server does.
Might be a reach asking this here but I'm using _Undefined's Pointshop on my server, but when I use it with my custom gamemode the hats/accessories/etc dont equip on join or on respawn. Everything else loads like the points and you still have the items purchased, they just dont equip automatically. This only happens with my gamemode. Anyone know what could cause this? Am I overwriting something on accident in my gamemode that stops the items from auto-equipping? No errors that I can find
[QUOTE=!!!WARLOCK!!!;51699001]Yes that's it, My player entity is NULL, seems like there's an issue with the garry's mod it self. It works perfectly fine on dedicated-servers, Just not on the gmod built-in server. Needs a little delay If your functions are getting called from PlayerInitialSpawn, Since player loads faster than the server does.[/QUOTE] The hook is serverside only for a reason -- it takes the client more time to be aware of the player.
Hey, beautiful people! I was wondering if anyone knows a way to show a traitor on the scoreboard with a function or something. For example, I want some code like this... [code] if condition is true then -- Notify players -- Set the players color on scoreboard to red, as if they were dead. end [/code] Any help would be appreciated! :) EDIT: I also made a thread for this because I'm dumb and forgot amazing threads like this exist.
Don't know why I'd be getting the rating of dumb. If you'd like me to elaborate a bit more I'd be glad to. The gamemode is obviously TTT, thought I'd throw it out there though. The code is for my T-Defib in the game. It's a defib that has the chance to turn the resurrected into a traitor. However, if the tefib backfires the resurrected will automatically call out the person who tried to turn them into a traitor. I want some kind of line of code, or anything really to paint a permanent mark on them in scoreboard, preferably how traitors are labeled when their bodies are found. Here's the current code for the traitor turn chance and what-not: [code] local toTOrNotToT = math.Round(math.random(1,100)) local turnIntoTPercent = 65 ply:SpawnForRound(true) if toTOrNotToT <= turnIntoTPercent then ply:SetRole(ROLE_TRAITOR) ply:SetCredits(2) elseif ply:GetRole() == ROLE_TRAITOR then ply:SetCredits(credits) else timer.Simple(0.2, function() ply:Say(plyRes .. " is a traitor and he defibbed me!") end ) end [/code]
Any idea why this keep making error? [code]-- this is the function function ply:SetVar(key, value) if self:IsPlayer() then net.Start("set") net.WriteInt(value, 32) net.WriteString(key) net.Send(self) end end -- when i call it function GM:PlayerSpawn( ply ) ply:SetVar("money", 100) end -- the error pop up [ERROR] gamemodes/revorp/gamemode/sv_money.lua:8: bad argument #1 to 'WriteInt' (number expected, got userdata) 1. WriteInt - [C]:-1 2. SetVar - gamemodes/revorp/gamemode/sv_money.lua:8 3. unknown - gamemodes/base/gamemode/player.lua:482 4. Spawn - [C]:-1 5. unknown - gamemodes/base/gamemode/player.lua:115 [/code]
[QUOTE=YoutoYokodera;51708345]Any idea why this keep making error? [code]-- this is the function function ply:SetVar(key, value) if self:IsPlayer() then net.Start("set") net.WriteInt(value, 32) net.WriteString(key) net.Send(self) end end -- when i call it function GM:PlayerSpawn( ply ) ply:SetVar("money", 100) end -- the error pop up [ERROR] gamemodes/revorp/gamemode/sv_money.lua:8: bad argument #1 to 'WriteInt' (number expected, got userdata) 1. WriteInt - [C]:-1 2. SetVar - gamemodes/revorp/gamemode/sv_money.lua:8 3. unknown - gamemodes/base/gamemode/player.lua:482 4. Spawn - [C]:-1 5. unknown - gamemodes/base/gamemode/player.lua:115 [/code][/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetVar]Entity:SetVar[/url] is a default function, you're overwriting it. If you followed the error stack you could've found out where this errored ([URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/player.lua#L482"]here[/URL]).
-snip- dumped code for not making the post hard to scroll
[QUOTE=YoutoYokodera;51708370] Any idea why this doesn't work in cl? :snip: [/quote] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/SendToServer]net.SendToServer[/url] is just a variation of [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Send]net.Send[/url], you still need to call [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Start]net.Start[/url], and have a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Receive]net.Receive[/url] server side for it. Also, even if you could somehow use the code above, your `Getplyvar` will return before it sets that value. Think about it like this, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] simply tells the game to execute that function once that time has pasted, but the thing is, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] has already been called, and the function (Getplyvar) has already returned that value as well, so once that function executes, its change on value won't have any effect. Just like this [code] local function createTimer(func) a = func end local function doStuff() local value createTimer(function() value = 2 end) return value end local b = doStuff() a() [/code] b doesn't magically become 2 when a is called, it stays nil. Only way b would be able to be 2 is if a was called within the `createTimer` function itself, but that's not the case here, or with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url]. [editline]22nd January 2017[/editline] Also just to add, the logic of sending the value to the client, then asking for the same value back is inherently flawed unless the client is allowed to change it. Simply store it server side and send it client side, this allows instant access on both states, and doesn't allow tampering from the client.
[QUOTE=bigdogmat;51708586][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/SendToServer]net.SendToServer[/url] is just a variation of [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Send]net.Send[/url], you still need to call [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Start]net.Start[/url], and have a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Receive]net.Receive[/url] server side for it. Also, even if you could somehow use the code above, your `Getplyvar` will return before it sets that value. Think about it like this, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] simply tells the game to execute that function once that time has pasted, but the thing is, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] has already been called, and the function (Getplyvar) has already returned that value as well, so once that function executes, its change on value won't have any effect. Just like this [code] local function createTimer(func) a = func end local function doStuff() local value createTimer(function() value = 2 end) return value end local b = doStuff() a() [/code] b doesn't magically become 2 when a is called, it stays nil. Only way b would be able to be 2 is if a was called within the `createTimer` function itself, but that's not the case here, or with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url]. [editline]22nd January 2017[/editline] Also just to add, the logic of sending the value to the client, then asking for the same value back is inherently flawed unless the client is allowed to change it. Simply store it server side and send it client side, this allows instant access on both states, and doesn't allow tampering from the client.[/QUOTE] So i will now dump all to the trashbin right :v: Any idea for a better way I haven't had any idea from ur hint
[QUOTE=YoutoYokodera;51708638]So i will now dump all to the trashbin right :v: Any idea for a better way I haven't had any idea from ur hint[/QUOTE] Store the value on a the player entity or within a table, then send it to the client and do the same there. Write a function to read from that player entity or table. I kind of explained it in my post.
[QUOTE=bigdogmat;51708655]Store the value on a the player entity or within a table[/quote] I'm finding the best way to do this, any specific idea? SetNW is obviously not ok I've search and found a way of adding var to the player metatable but then after that the guy say I could try to change the var by SetNW so I think that is bad as the first idea
Probably the wrong place but not sure where to post it, the wiki page for [url]https://wiki.garrysmod.com/page/DListView/OnRowSelected[/url] has its arguments inverted.
[QUOTE=0V3RR1D3;51708872]Probably the wrong place but not sure where to post it, the wiki page for [url]https://wiki.garrysmod.com/page/DListView/OnRowSelected[/url] has its arguments inverted.[/QUOTE] There is a thread for the wiki btw
Sorry, you need to Log In to post a reply to this thread.