• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=Willox;46787115][code] type( PWep ) == TYPE_ENTITY [/code] This won't work. [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/type]Global.type[/url] returns a string, while the [url=http://wiki.garrysmod.com/page/Enums/TYPE]type enums[/url] are numbers.[/QUOTE] [code]if !PWep || !type( PWep ) == TYPE_ENTITY || !PWep.Magazines then return true end[/code] [B]!type( PWep ) == TYPE_ENTITY[/B] Yet the function still goes on past that point, and returns false when I want it to. I'm not trying to be rude, but only stating an apparent exception to your statement. [QUOTE=Blasteh;46787679]Already told you what your problem was. You're using ipairs instead of pairs; your table is not integer keyed. /facepalm[/QUOTE] One, I found that statement rude for some reason. Two, I already got it working. Three, you are right, and I can't believe I didn't consider that; in actuality, I thought the tables were automatically indexed with numbers. I needed it to run in ordered pairs by index, and so my solution worked perfectly. Thank you for trying to help, though!
[code]!type( PWep ) == TYPE_ENTITY type( variable ) -- will always return a string !str -- will always evaluate to false !type( variable ) -- will always evaluate to false false == TYPE_ENTITY -- will always evaluate to false[/code] That condition will never cause the if statement to evaluate to true, while your other conditions might as you are using "or" operators, not "and" operators.
Something interesting though, errors pop up at times that make no sense to me. [code]local PWep = ply:GetWeapon( wep:GetClass() )[/code] always works, except lately there have been times when that would return an error, GetClass() being a nil value. I inserted this line to fix it, but I don't entirely understand the cause of the error: [code]if not wep:GetClass() then return false end[/code] [editline]24th December 2014[/editline] [QUOTE=Willox;46789909]Proving me wrong[/QUOTE] Well, I didn't really think it through that well lol... I guess you're right.
[lua]hook.Add("HUDShouldDraw","RemoveDefaultChat",function(x) if x == "CHudChat" then return false end end)[/lua] Using this code prevents my console/menu from being able to pop up after attempting to open the chatbox. Does anyone have any idea why?
try using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/StartChat]GM/StartChat[/url]
[QUOTE=PortalGod;46792206]try using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/StartChat]GM/StartChat[/url][/QUOTE] I found that it just visually hides the chatbox rather than remove the functionality. I can still type messages, I just can't see what I'm doing. Wouldn't that create double chat messages?
if you're making a chatbox, use startchat if you just want to change how the chatbox looks, otherwise use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerBindPress]GM/PlayerBindPress[/url] and return true for messagemode
I'm running into a weird issue with srcds. When I start my server up it will spam "KeyValues Error: LoadFromBuffer: missing { in file scripts/sound*.txt". The asterisk can be replaced with anything literally, it just spams the error for all soundscape files. See [url=https://gist.github.com/mcd1992/5d98413ff1f9386ee6f4]this[/url]. Any ideas as to why it's doing this? Its not breaking the game it just adds 45 seconds to the servers startup time...
How can I properly stop a shader such as DrawSharpen? [editline]25th December 2014[/editline] i was using hook.remove wrong
[code] draw.SimpleText("Godded: "..LocalPlayer():HasGodMode(), "Trebuchet18", ScrW() / 2 - 400 , ScrH() - 42 , GREEN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) [/code] [code]Error: gamemode/cl_hud.lua:42: attempt to concatenate a boolean value[/code] Does anyone know how to get the boolean to respond with True or false?
Either: [code]tostring( bool ) --or .. ( bool and "True" or "False" )[/code]
Can you use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/Dock]Panel:Dock[/url] to dock something to the bottom left and something else to the bottom right? (IE. fill 'bottom' with 2 elements?) By default, it seems to just stack the elements, I'm looking to split the space.
[QUOTE=Kogitsune;46795482]Either: [code]tostring( bool ) --or .. ( bool and "True" or "False" )[/code][/QUOTE] I've tried .. ( bool and "True" or "False" ) Same result?
[QUOTE=SwikCoder;46795536]I've tried .. ( bool and "True" or "False" ) Same result?[/QUOTE] draw.SimpleText("Godded: " .. tostring( LocalPlayer():HasGodMode() ), "Trebuchet18", ScrW() / 2 - 400 , ScrH() - 42, GREEN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
[QUOTE=SwikCoder;46795478][code] draw.SimpleText("Godded: "..LocalPlayer():HasGodMode(), "Trebuchet18", ScrW() / 2 - 400 , ScrH() - 42 , GREEN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) [/code] [code]Error: gamemode/cl_hud.lua:42: attempt to concatenate a boolean value[/code] Does anyone know how to get the boolean to respond with True or false?[/QUOTE] You can use tostring( bool )... My meta-table replacements for __tostring, __concat makes almost everything print using my custom print, toprint and string.concat functions. I'll be adding the rest of the data-types very soon which will cover all methods of data output. [editline]26th December 2014[/editline] [QUOTE=zeaga;46788491]Does anyone have a copy of the skeleton gamemode from garrysmod.org? I'm trying to find an entity file I found in one of those skeletons a while back but I can't find a copy of it anywhere.[/QUOTE] Not the same one but I have a basic one and a more advanced on depending on what you're looking for... Basic: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/includes/gm_name.rar[/url] Advanced info and links: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_acecooldev_base_gamemode_info.lua.html[/url] [editline]26th December 2014[/editline] [QUOTE=Exho;46789568]If I'm looking to create a multiplayer game between 2 players using my phone addon, would it be bad to frequently use the net library to send data to and from the server/clients? Thats how I imagine it would work but it seems wrong :/[/QUOTE] Not bad at all unless you exceed 20kb / sec of data. Then it'll keep backlogging and eventually overflow the client. Most messages aren't that large though. [editline]26th December 2014[/editline] [QUOTE=iamgoofball;46775645]okay so this is a really stupid question but I can't find any tutorials on it: how do I make a derma panel show up on using an entity? as the code for that would go in cl_init.lua but I can't do ENT:Use() definitions in cl_init.lua.[/QUOTE] Pretty sure I saw a thread on this from you and I responded. It may have been someone else, but here: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_zipped_code/acecool_npc_jointeam_example.rar[/url] [editline]26th December 2014[/editline] [QUOTE=Sparky-Z;46776621]Thanks! That's exactly what I needed. [/QUOTE] One small change to make it auto-refresh compatible... Change: [code]local oldRegister = player_manager.RegisterClass[/code] To: [code]oldRegister = oldRegister || player_manager.RegisterClass;[/code] If you don't do this you'll get a stack overflow on refresh when that function is called again. By setting it as a global to be assigned to itself if it exists or the function if it doesn't will let it get set as the original the first time it runs and itself the next x times.
What's the function to set player's aim angle?
[QUOTE=rebel1324;46797575]What's the function to set player's aim angle?[/QUOTE] _p:SetEyeAngles( vector_origin )
AAOA Heck, I applied that on calc view and my third person stuff is brokenASDJKASLDK Let me help to think about thirdperson aim assist.
[QUOTE=rebel1324;46798263]AAOA Heck, I applied that on calc view and my third person stuff is brokenASDJKASLDK Let me help to think about thirdperson aim assist.[/QUOTE] If it is modified on client and server it mucks up. If you only applied it once you should be fine. CalcView controls the camera.. Also, to JVS, how is the correct answer dumb? This is a snippet from my thirdperson free-cam CalcView code: [code]// If the user is moving or aiming down sights, lock the camera if ( _p:KeyDown( bit.bor( IN_FORWARD, IN_BACK, IN_MOVELEFT, IN_MOVERIGHT, IN_ATTACK2 ) ) ) then _p:SetFlag( "view_angle_old", Angle( _ang.p, _angle.y, 0 ), true ); _p:SetEyeAngles( Angle( _ang.p, _angle.y, 0 ) ); [/code] So, it will lock the view ( and aim at this point ).. _ang is from: hook.Add( "CalcView", "ThirdpersonFreecam:CalcView", function( _p, _pos, _ang, _fov, _znear, _zfar )
[QUOTE=Acecool;46798510]Also, to JVS, how is the correct answer dumb? [/QUOTE] First off, link to the [URL="http://wiki.garrysmod.com/page/Player/SetEyeAngles"]wiki page[/URL], secondly the function takes an angle, not a vector ( guess what vector_origin is? ). If you want to help people like that at least do it properly.
Is there a way to get created NetworkVars for an entity (after SetupDataTables has been called)?
I'm trying to replicate this [img]http://i.imgur.com/fB02dev.png[/img] That SetEyeAngles only locks the view.
[QUOTE=rebel1324;46798604]I'm trying to replicate this [img]http://i.imgur.com/fB02dev.png[/img] That SetEyeAngles only locks the view.[/QUOTE] [url]http://facepunch.com/showthread.php?t=1399034&p=45004733#post45004733[/url]
What stupid syntax error am I doing with this? Basically it's a bunch of checks to that get called when a person does an action to gain reputation, it checks to see if you are within the reputation levels and are not the level you are trying to promote to, then promotes you. No errors, just doesnt function. [url]http://pastebin.com/2aKGTPxi[/url]
[QUOTE=makermod1;46799161]What stupid syntax error am I doing with this? Basically it's a bunch of checks to that get called when a person does an action to gain reputation, it checks to see if you are within the reputation levels and are not the level you are trying to promote to, then promotes you. No errors, just doesnt function. [url]http://pastebin.com/2aKGTPxi[/url][/QUOTE] First what error are you getting? Second is that the entirety of the code? If it is then you have wayyyyyy too many "end"s. You do not need an end for an "elsif." How not to do it: [code] if a == b then --stuff elseif a == c then --stuff elseif a == d then --stuff end end end [/code] How to do it: [code] if a == b then --stuff elseif a == c then --stuff elseif a == d then --stuff end [/code] Damn it I misread your code =) Look below
[QUOTE=makermod1;46799161]What stupid syntax error am I doing with this? Basically it's a bunch of checks to that get called when a person does an action to gain reputation, it checks to see if you are within the reputation levels and are not the level you are trying to promote to, then promotes you. No errors, just doesnt function. [url]http://pastebin.com/2aKGTPxi[/url][/QUOTE] *SORRY FOR LONG POST* Your lesson for today: ALWAYS INDENT/STRUCTURE YOUR CODE PROPERLY. Here's your code with proper tabulation: [code] function meta:AddReputation( amt ) self:SetReputation( self:GetReputation() + amt ) //CheckRepPass(100, 0, TEAM_SAMARITAN) local GetRepForCheck = self:GetReputation() local GetJobTableVar = self:getJobTable().command local TableDoesNotHaveValue = !table.HasValue if GetRepForCheck >=0 and GetRepForCheck <=100 then local This_Class = {"Wanderer"} if TableDoesNotHaveValue("Wanderer", GetJobTableVar) then self:changeTeam(TEAM_WANDERER, true) else if GetRepForCheck >=100 and GetRepForCheck <=200 then local This_Class = {"Survivor"} if TableDoesNotHaveValue("Survivor", GetJobTableVar) then self:changeTeam(TEAM_SURVIVOR, true) else if GetRepForCheck >=200 and GetRepForCheck <=600 then local This_Class = {"Samaritan"} if TableDoesNotHaveValue("Samaritan", GetJobTableVar) then self:changeTeam(TEAM_SAMARITAN, true) else if GetRepForCheck >=600 and GetRepForCheck <=800 then local This_Class = {"Avenger"} if TableDoesNotHaveValue("Avenger", GetJobTableVar) then self:changeTeam(TEAM_AVENGER, true) else if GetRepForCheck >=800 and GetRepForCheck <=1400 then local This_Class = {"Protector"} if TableDoesNotHaveValue("Protector", GetJobTableVar) then self:changeTeam(TEAM_PROTECTOR, true) else if GetRepForCheck >=1400 and GetRepForCheck <=2200 then local This_Class = {"Sentinel"} if TableDoesNotHaveValue("Sentinel", GetJobTableVar) then self:changeTeam(TEAM_SENTINEL, true) else if GetRepForCheck >=2200 and GetRepForCheck <=4400 then local This_Class = {"Ranger"} if TableDoesNotHaveValue("Ranger", GetJobTableVar) then self:changeTeam(TEAM_RANGER, true) else if GetRepForCheck >=4400 and GetRepForCheck <=6800 then local This_Class = {"PeaceKeeper"} if TableDoesNotHaveValue("PeaceKeeper", GetJobTableVar) then self:changeTeam(TEAM_PEACEKEEPER, true) else if GetRepForCheck >=6800 and GetRepForCheck <=8800 then local This_Class = {"Paladin"} if TableDoesNotHaveValue("Paladin", GetJobTableVar) then self:changeTeam(TEAM_PALADIN, true) else if GetRepForCheck >=8800 and GetRepForCheck <=8800 then local This_Class = {"Hero"} if TableDoesNotHaveValue("Hero", GetJobTableVar) then self:changeTeam(TEAM_HERO, true) else self:print(yay) --else if Do bad guy ranks next, but find out how this works with negative rep. end end end end end end end end end end end end end end end end end end end end end[/code] See the problem yet? It is "elseif" in lua, not "else if". Let's look at improved code: [code] function meta:AddReputation( amt ) self:SetReputation( self:GetReputation() + amt ) //CheckRepPass(100, 0, TEAM_SAMARITAN) local GetRepForCheck = self:GetReputation() local GetJobTableVar = self:getJobTable().command local TableDoesNotHaveValue = !table.HasValue if GetRepForCheck >=0 and GetRepForCheck <=100 then local This_Class = {"Wanderer"} if TableDoesNotHaveValue("Wanderer", GetJobTableVar) then self:changeTeam(TEAM_WANDERER, true) end elseif GetRepForCheck >=100 and GetRepForCheck <=200 then local This_Class = {"Survivor"} if TableDoesNotHaveValue("Survivor", GetJobTableVar) then self:changeTeam(TEAM_SURVIVOR, true) end elseif GetRepForCheck >=200 and GetRepForCheck <=600 then local This_Class = {"Samaritan"} if TableDoesNotHaveValue("Samaritan", GetJobTableVar) then self:changeTeam(TEAM_SAMARITAN, true) end elseif GetRepForCheck >=600 and GetRepForCheck <=800 then local This_Class = {"Avenger"} if TableDoesNotHaveValue("Avenger", GetJobTableVar) then self:changeTeam(TEAM_AVENGER, true) end elseif GetRepForCheck >=800 and GetRepForCheck <=1400 then local This_Class = {"Protector"} if TableDoesNotHaveValue("Protector", GetJobTableVar) then self:changeTeam(TEAM_PROTECTOR, true) end elseif GetRepForCheck >=1400 and GetRepForCheck <=2200 then local This_Class = {"Sentinel"} if TableDoesNotHaveValue("Sentinel", GetJobTableVar) then self:changeTeam(TEAM_SENTINEL, true) end elseif GetRepForCheck >=2200 and GetRepForCheck <=4400 then local This_Class = {"Ranger"} if TableDoesNotHaveValue("Ranger", GetJobTableVar) then self:changeTeam(TEAM_RANGER, true) end elseif GetRepForCheck >=4400 and GetRepForCheck <=6800 then local This_Class = {"PeaceKeeper"} if TableDoesNotHaveValue("PeaceKeeper", GetJobTableVar) then self:changeTeam(TEAM_PEACEKEEPER, true) end elseif GetRepForCheck >=6800 and GetRepForCheck <=8800 then local This_Class = {"Paladin"} if TableDoesNotHaveValue("Paladin", GetJobTableVar) then self:changeTeam(TEAM_PALADIN, true) end elseif GetRepForCheck >=8800 and GetRepForCheck <=8800 then local This_Class = {"Hero"} if TableDoesNotHaveValue("Hero", GetJobTableVar) then self:changeTeam(TEAM_HERO, true) end else self:print(yay) --else if Do bad guy ranks next, but find out how this works with negative rep. end end[/code] Looks better already. Let's examine this code closer: [code] local TableDoesNotHaveValue = !table.HasValue [/code] What do you think this code does? No. What it does is "not table.HasValue", means "not function", means "false" because function equals to true. Furthermore you don't even use the proper parameters if above would've worked: [code] TableDoesNotHaveValue("Wanderer", GetJobTableVar)[/code] [url=http://wiki.garrysmod.com/page/table/HasValue]table.HasValue[/url] takes table as first argument and the value to check as second. So, what it should be is: [code]table.HasValue(GetJobTableVar, "Wanderer" )[/code] Assuming GetJobTableVar is a table that can have the value "Wanderer". Next, this bit of code in each elseif: [code]local This_Class = {"Ranger"}[/code] Is completely useless because you never use this variable. (?) And lastly:[code]self:print(yay)[/code] This function doesn't exist by default and you are passing to it a non existent variable called 'yay', what it should be is simply [code]print("yay")[/code] So, by now the proper code would be: [code]function meta:AddReputation( amt ) self:SetReputation( self:GetReputation() + amt ) //CheckRepPass(100, 0, TEAM_SAMARITAN) local GetRepForCheck = self:GetReputation() local GetJobTableVar = self:getJobTable().command -- This should be a table of jobs or something local table.HasValue = !table.HasValue if GetRepForCheck >=0 and GetRepForCheck <=100 then if table.HasValue( GetJobTableVar, "Wanderer" ) then self:changeTeam(TEAM_WANDERER, true) end elseif GetRepForCheck >=100 and GetRepForCheck <=200 then if table.HasValue( GetJobTableVar, "Survivor" ) then self:changeTeam(TEAM_SURVIVOR, true) end elseif GetRepForCheck >=200 and GetRepForCheck <=600 then if table.HasValue( GetJobTableVar, "Samaritan" ) then self:changeTeam(TEAM_SAMARITAN, true) end elseif
Making the changes you suggested: [url]http://pastebin.com/jHj8HjrV[/url] I get the following errors: [CODE]Lua Error: [ERROR] gamemodes/riseofthebadlands/gamemode/sh_reppoints.lua:236: 'end' expected (to close 'if' at line 177) near '<eof>' 1. unknown - gamemodes/riseofthebadlands/gamemode/sh_reppoints.lua:0[/CODE] **EDIT** Dear god, didnt refresh. I'll read, thank you! I'll take a look at this in a few hours, however, the way it is set up I'm actually making sure via !table.HasValue that you are not the class you are trying to promote to.
snip
I have this idea where I want to create an addon that uses my database, so across servers it would only use mine. Now there are some issues... First off, I would be sending the info I want saved to a webpage and doing the work there, this would stop people from having access to my info for the database (although I'm not sure how to make sure it's really secure) [B][B][*][/B] What's to stop players from changing the code and changing what's saved/sent to the webpage in the addon? [B][*][/B] How would I best defend against any DDoS attacks/hacking from people who would be pissed if they lost? [/B] My main fear is that people will change the code in the addon so then it sends ridiculous high amounts of (for example gold) for their account, and there'd be no way to really check to see if it was legit or not since they could change the code. Any suggestions? Or is this not really plausible because of how many ways it could be exploited.
Is the Windows 10 "fastdl not working" issue something that has to be fixed on Facepunch or Microsoft's side?
Sorry, you need to Log In to post a reply to this thread.