• What do you need help with? V3
    6,419 replies, posted
[QUOTE=Bl00dyhell9;37999131]Is there anyone that can provide me with an example of applying a Player Colour if Player:IsAdmin() returns true, and if possible a check of the player color on player spawn? The example on the wiki wasn't very helpful in explaining to me how to call the function for a specific color, so any help would be appreciated![/QUOTE] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index249d.html"]Player Spawn Hook[/URL] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexd8ca.html"]hook.Add[/URL] [lua] function CustomPlySpawn(ply) if ply:IsAdmin() then ply:SetColor(0,255,0,255) end print(ply:GetColor()) end hook.Add( "PlayerSpawn", "CustomPlySpawn", CustomPlySpawn) [/lua]
[QUOTE=brandonj4;37999432][URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index249d.html"]Player Spawn Hook[/URL] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexd8ca.html"]hook.Add[/URL] [lua] function CustomPlySpawn(ply) if ply:IsAdmin() then ply:SetColor(0,255,0,255) end print(ply:GetColor()) end hook.Add( "PlayerSpawn", "CustomPlySpawn", CustomPlySpawn) [/lua][/QUOTE] This will work... But I was asking about the new matproxy Player Color function.
[QUOTE=find me;37992274] -snip- [/QUOTE] I already found a way around it, but thanks, might still use this.
[QUOTE=Bl00dyhell9;37999587]This will work... But I was asking about the new matproxy Player Color function.[/QUOTE] [QUOTE]Is there anyone that can provide me with an example of applying a [B]Player Colour[/B] if Player:IsAdmin() returns true, and if possible a check of the [B]player color[/B] on player spawn? The example on the wiki wasn't very helpful in explaining to me how to call the function for a specific color, so any help would be appreciated![/QUOTE] You should have explained more specifically what you needed the first time.
[QUOTE=brandonj4;38000668]You should have explained more specifically what you needed the first time.[/QUOTE] I thought I did, but then again, I never said I was talking about Garry's Mod 13, either.
Somewhat off-topic question: i'm starting to get database-itis. Im storing loads of information on about four databases for one server (experience, levels, earned items, stats, kills, on and on) And i'm using tmysql4 Can anyone tell me if there's a theoretical limit to how much databasing i can do before losing functionality of my server? or is MySQL relatively fast and awesome and wont flop over on me ever?
[QUOTE=Bl00dyhell9;38000728]I thought I did, but then again, I never said I was talking about Garry's Mod 13, either.[/QUOTE] Replace [lua] ply:SetColor(0,255,0,255) [/lua] with [lua] ply:SetPlayerColor( Vector(0, 1, 0) ) [/lua] in the code he gave you.
[QUOTE=Archemyde;38001112]Somewhat off-topic question: i'm starting to get database-itis. Im storing loads of information on about four databases for one server (experience, levels, earned items, stats, kills, on and on) And i'm using tmysql4 Can anyone tell me if there's a theoretical limit to how much databasing i can do before losing functionality of my server? or is MySQL relatively fast and awesome and wont flop over on me ever?[/QUOTE] People have SQL tables filled with hundreds of thousands of rows full of info. MySQL will be just fine (especially if connected via localhost) for the amount of information you need to store.
[QUOTE=JustSoFaded;38001167]People have SQL tables filled with hundreds of thousands of rows full of info. MySQL will be just fine (especially if connected via localhost) for the amount of information you need to store.[/QUOTE] It's not localhost. :suicide: connecting to my website for it all.
I need help with some vector math stuff. What I need is to figure out is, if a player is looking in the direction of a line, what is the point(ON THE LINE) at which the direction of the players view meets the line? I'm not really sure how to ask this question... So here's a picture! I have vectors A, B, and C(C is the player). The line coming off of C is the direction the player is looking. I need to figure out vector D, on the imaginary line between vectors A and B. How would I solve this equation? [IMG]http://s14.postimage.org/e1ik9nzun/image.png[/IMG]
[QUOTE=Archemyde;38001112]Somewhat off-topic question: i'm starting to get database-itis. Im storing loads of information on about four databases for one server (experience, levels, earned items, stats, kills, on and on) And i'm using tmysql4 Can anyone tell me if there's a theoretical limit to how much databasing i can do before losing functionality of my server? or is MySQL relatively fast and awesome and wont flop over on me ever?[/QUOTE] I use plain text files and then update to a read-only mysql database for external viewing (website stuff). If gmod breaks your mysql module (which it will) then the worst thing that happens is your website won't be getting updated stats.
Hi, im trying to use panel:LocalToScreen() but it just retruns 0, 0. Example code below. [code] local Frame = vgui.Create( "DFrame" ) Frame:SetSize( 380, 390 ) Frame:SetPos( 50, 50 ) Frame:SetTitle( "Test" ) local x, y = Frame:LocalToScreen( 0, 0 ) print( "X: " .. x .. " Y: " .. y ) [/code] im doing this in GMOD 13 and it just returns 0, 0. ive tryed in multiple different setups with different panels etc. but i just keep getting 0, 0. any help would be appriciated! thank you
[QUOTE=Persious;37997065]I'm coding a BHop gamemode, and it's going pretty good so far. I'm only having trouble with one thing: How the hell can I get the brick entities to stop going down when I jump on them, but instead teleport me back to the "safe-location"?[/QUOTE] I know I shouldn't bump this too fast, tho this is the only thing preventing me from getting a server up and running.
I'm trying to learn lua and I'm getting a better understanding slowly by sifting through codes. [lua]function sayThatName(victim,inflictor,killer)[/lua] On this, why does it go (victim, inflictor, killer) after the name of the function? I don't get it. Is it calling other hooks to use? and on the same note [lua]function SteamIDenter(ply) print("The player "..ply:Nick().." joined. [" ..ply:SteamID().. "]") end hook.Add( "PlayerAuthed", "Playerspawn", SteamIDenter )[/lua] ^ Would that display the name+steam id when they connect?
Taken from lua.org/pil [lua] -- add all elements of array `a' function add (a) local sum = 0 for i,v in ipairs(a) do sum = sum + v end return sum end [/lua] In that syntax, a function definition has a name (add, in the previous example), a list of parameters, and a body, which is a list of statements. Parameters work exactly as local variables, initialized with the actual arguments given in the function call. You can call a function with a number of arguments different from its number of parameters. Lua adjusts the number of arguments to the number of parameters, as it does in a multiple assignment: Extra arguments are thrown away; extra parameters get nil.
[QUOTE=zerothefallen;38011095]I'm trying to learn lua and I'm getting a better understanding slowly by sifting through codes. [lua]function sayThatName(victim,inflictor,killer)[/lua] On this, why does it go (victim, inflictor, killer) after the name of the function? I don't get it. Is it calling other hooks to use? and on the same note [lua]function SteamIDenter(ply) print("The player "..ply:Nick().." joined. [" ..ply:SteamID().. "]") end hook.Add( "PlayerAuthed", "Playerspawn", SteamIDenter )[/lua] ^ Would that display the name+steam id when they connect?[/QUOTE] A lot of hooks can return something, too. So the [b][url=wiki.garrysmod.com/?title=Gamemode.PlayerDeath]Gamemode.PlayerDeath [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] hook also returns the victim (player that died), inflictor (what was used to kill the victim), and the killer (who killed the victim). victim, inflictor, and killer can be whatever but they are always in that order. [lua] function playerDies( ply, weapon, murderer ) Msg( "Player " .. ply:GetName() .. " has died by the hands of "..murderer.." with a "..weapon.."\n" ) end hook.Add( "PlayerDeath", "playerDeathTest", playerDies )[/lua] Would work also. To your second question, yes and no. Yes it will display player name and SteamID but not at spawn but when he is Authed. But I believe Authed is last to be called between PlayerConnect, PlayerInitialSpawn, then PlayerAuthed, but I may be wrong on that.
So I'm repairing pointshop for gm13 and i'm almost done with the basic errors, however I still have one major one left I can't seem to fix. I'm calling net.Recieve() (clientside) and i get this error [lua] [ERROR] attempt to call field 'Recieve' (a nil value) 1. unknown - lua/pointshop/cl_player_extension.lua:23 2. include - [C]:-1 3. unknown - lua/autorun/pointshop.lua:31 [/lua] Here's what I had (serverside): [lua] //sv_player_extension.lua timer.Simple(1, function() // line 140 net.Start("PointShop_Items") net.WriteTable(self.PS_Items) net.Send(self) end) [/lua] Lastly here's where i got the error (clientside): [lua] //cl_player_extension.lua net.Recieve("PointShop_Items", function(length) //line 23 LocalPlayer().PS_Items = net.ReadTable() end) [/lua] This is my first time using the net library, so I don't expect it to be perfect. However, this is what it said to do on the tutorial on the wiki. Also, if you wondering, I already precached the string, so it's not that. Thanks.
Don't let i before e fool you. It's [I]Receive[/I]! Well, actually I was wrong. i before e works because it goes, "i before e except after c"
[QUOTE=Kidd;38013721]Don't let i before e fool you. It's [I]Receive[/I]![/QUOTE] Wow, I feel like a dumbass. Thanks Lol. I just checked my code for a half an hour.
[QUOTE=Kidd;38013721] Well, actually I was wrong. i before e works because it goes, "i before e except after c"[/QUOTE] That rule doesn't actually work in a majority of cases though; there's something like 20x the amount of words which do not conform to those that do (for those that disagree, check QI).
When doing this in GM13: BoxPhys:ApplyForceOffset( Force * 39.37 * DeltaTime, self:GetPos() + self:GetUp()*-39.37 ) BoxPhys:ApplyForceOffset( Force * -39.37 * DeltaTime, self:GetPos() + self:GetUp()*39.37 ) the game deletes the phys_prop with the message: Crazy physics on [xxx][phys_prop] - removing any ideas why and how to prevent it? Im trying to get a wheel to turn. Edit: I think the issue is when something goes to fast breaking the "speed limit". But that sucks... why is there no limiter anymore.
[QUOTE=Tingle1989;38014990]When doing this in GM13: BoxPhys:ApplyForceOffset( Force * 39.37 * DeltaTime, self:GetPos() + self:GetUp()*-39.37 ) BoxPhys:ApplyForceOffset( Force * -39.37 * DeltaTime, self:GetPos() + self:GetUp()*39.37 ) the game deletes the phys_prop with the message: Crazy physics on [xxx][phys_prop] - removing any ideas why and how to prevent it? Im trying to get a wheel to turn. Edit: I think the issue is when something goes to fast breaking the "speed limit". But that sucks... why is there no limiter anymore.[/QUOTE] It's supposed to only remove entities when they're about to cause a physics crash, [url=http://facepunch.com/showthread.php?t=1217969]this bug report looks related.[/url]
I'm ashamed to even ask such a basic question, but I've been looking through the libraries on gmodwiki.com and I can't seem to find an answer... Is there a way the user can be prompted for a variable by Lua in-console? (i.e. Input a value: 5 then set a variable equal to that 5) Or would that kind of thing have to be handled by hooks and other less direct means? I'm going through Programming in Lua and I'm not sure how much will stay relevant in GMod. EDIT: The easiest way to take input directly from the user voluntarily seems to be through parameters via a console command. In this fashion, I think? [lua] function AmIFive(userInput) if userInput == 5 then true else false end concommand.Add("AmIFive", AmIFive); [/lua] No syntax errors, but AmIFive doesn't seem to work when typed in console. Hm.
That is because the argument is a table, and it is the third argument.
I need help converting this to http.Fetch instead of the old http.Get: [CODE]http.Get(URL_RULES, "", function ( Res2 ) local Results2 = body or "" if (!PanelList) then return end local explodedResults = string.Explode("\n", ":RULES CONFIRMATION\n\n" .. Results2);[/CODE] This is how it gets URL_RULES: [CODE]URL_RULES = "http://MYWEBSITE/rules.txt";[/CODE] I can't figure it out?
http.Fetch(url, function, error) Something like this [lua]//Questn:AddFile() local Questn = {} Questn.Update = {Updater = {},Download={}} Questn.UpdatedUpdate = 0 timer.Simple(4, function() //Load First if Questn.CheckUpdate == nil then return end if Questn.UpdatedUpdate == 0 then Questn:CheckUpdate() Questn.UpdatedUpdate = 1 end end) local BackUpDate = [[local Quest = {} Quest.Version = 1.2]] local BackUpUrl = [[print("Quest Downloaded") Quest.Main["Version"] = "1.2" if IsValid(Entity(1)) then Entity(1):ChatPrint("Quest is updated to latest") end print("Quest is updated to latest")]] Questn.Update["Website"] = "url" Questn.Update.Download["Update"] = "url" local unscc = false function Questn:CheckUpdate() http.Fetch(Questn.Update["Website"], function(c) Questn.Update.Updater[1] = c unscc = true end, function(unsucc) print(unsucc) if unsucc == "unsuccessful" then unscc = false local subn = string.Explode(" ",BackUpDate) if Quest.Main["Version"] == subn[6] then print(Language:NestGet("UpToDate")) elseif Quest.Main["Version"] ~= subn[6] then print(Language:NestGet("OutOfDate")) end Questn:Updating() end end) timer.Simple(4, function() if unscc == false then return end local sub = string.Explode(" ",Questn.Update.Updater[1]) if Quest.Main["Version"] == sub[6] then print(Language:NestGet("UpToDate")) else print(Language:NestGet("OutOfDate")) Questn:Updating() end end) end function Questn:Updating() http.Fetch(Questn.Update.Download["Update"], function(a) return RunString(a) end, function(unsucc) print(unsucc) if unsucc == "unsuccessful" then RunString(BackUpUrl) end end) end [/lua]
[QUOTE=Twerty;38018640]I'm ashamed to even ask such a basic question, but I've been looking through the libraries on gmodwiki.com and I can't seem to find an answer... Is there a way the user can be prompted for a variable by Lua in-console? (i.e. Input a value: 5 then set a variable equal to that 5) Or would that kind of thing have to be handled by hooks and other less direct means? I'm going through Programming in Lua and I'm not sure how much will stay relevant in GMod. EDIT: The easiest way to take input directly from the user voluntarily seems to be through parameters via a console command. In this fashion, I think? [lua] function AmIFive(userInput) if userInput == 5 then true else false end concommand.Add("AmIFive", AmIFive); [/lua] No syntax errors, but AmIFive doesn't seem to work when typed in console. Hm.[/QUOTE] I would use something like this: [lua] function AmIFive(ply, cmd, args) local arg1 = args[1] if tonumber(arg1) != 5 then print("The first arguement doesn't equal to five.") return false end print("The first arguement equals to five!") return true end concommand.Add("AmIFive", AmIFive); // You would enter in console: AmIFive <#>; AmIFive 10; AmIFive 5; [/lua]
[QUOTE=brandonj4;38020828]I would use something like this: [lua] function AmIFive(ply, cmd, args) local arg1 = args[1] if tonumber(arg1) != 5 then print("The first arguement doesn't equal to five.") return false end print("The first arguement equals to five!") return true end concommand.Add("AmIFive", AmIFive); // You would enter in console: AmIFive <#>; AmIFive 10; AmIFive 5; [/lua][/QUOTE] Thank you handsomely brandonj4. Because of your concise example, I see quite clearly what it is I'm confused about -- the [what I assume are] built-in table references for ply, cmd, and args when creating a new function. You quite clearly use args[1] there to refer to whatever the user inputs as the first argument when calling the function. By slipping print(ply) and print(cmd) inside your function, I get "Player [1][Twerty]" and "AmIFive" respectively. So ply is a table of connected players (and maybe bots), but what exactly is cmd? It seems almost self-explanatory, but I find it very strange that defining a function would make a table with the only contents being the name of the given function -- so I'm guessing there's more to it than that? Sorry I'm blindly guessing like this -- I can't seem to find any documentation or explained examples for those three fields which seem so incremental to using functions in GMod. Just those that define the function simply as a name with the code body, and the end. So your help is appreciated, Chessnut and brandonj4. :smile:
-shnip-
[QUOTE=Twerty;38022677]but what exactly is cmd? It seems almost self-explanatory, but I find it very strange that defining a function would make a table with the only contents being the name of the given function -- so I'm guessing there's more to it than that?[/QUOTE] Cmd is the name of the console command. The function name doesn't matter. The reason cmd exists is because (in rare situations) you might want to link multiple console commands to a single function. Then, the only way to know which console command triggered the function is to check the cmd variable.
Sorry, you need to Log In to post a reply to this thread.