• Flow - Collection of gamemodes and accessories
    536 replies, posted
I might take some time to explain the ranking system as well. Each time someone gets a time on a specific style, these queries are executed: [code] function Timer:RecalculatePoints( nStyle ) local nMult = Timer:GetMultiplier( nStyle ) sql.Query( "UPDATE game_times SET nPoints = " .. nMult .. " * (" .. GetAverage( nStyle ) .. " / nTime) WHERE szMap = '" .. game.GetMap() .. "' AND nStyle = " .. nStyle ) local nFourth, nDouble = nMult / 4, nMult * 2 sql.Query( "UPDATE game_times SET nPoints = " .. nDouble .. " WHERE szMap = '" .. game.GetMap() .. "' AND nStyle = " .. nStyle .. " AND nPoints > " .. nDouble ) sql.Query( "UPDATE game_times SET nPoints = " .. nFourth .. " WHERE szMap = '" .. game.GetMap() .. "' AND nStyle = " .. nStyle .. " AND nPoints < " .. nFourth ) end [/code] ALL points for a specific map are recalculated. The resulting points per entry is: Map Multiplier * (Average Time / Your Time) This means, if someone gets a better time than the average, your points will go down (unless this person is you, then your points go up). When a player joins, or when a time is beaten, their rank is calculated like so: [code] function Player:LoadRank( ply, bUpdate ) local nSum = self:GetPointSum( ply.Style, ply:SteamID() ) local nRank = self:GetRank( nSum, Player:GetRankType( ply.Style, true ) ) ply.RankSum = nSum if nRank != ply.Rank then ply.Rank = nRank ply:SetNWInt( "Rank", ply.Rank ) end self:SetSubRank( ply, nRank, nSum ) if not bUpdate then Core:Send( ply, "Timer", { "Ranks", Player.NormalScalar, Player.AngledScalar } ) end end function Player:GetPointSum( nStyle, szUID ) local Data = sql.Query( "SELECT SUM(nPoints) AS nSum FROM game_times WHERE szUID = '" .. szUID .. "' AND (" .. Player:GetMatchingStyles( nStyle ) .. ")" ) if Core:Assert( Data, "nSum" ) then return tonumber( Data[ 1 ]["nSum"] ) or 0 end return 0 end function Player:GetRank( nPoints, nType ) local Rank = 1 for RankID, Data in pairs( _C.Ranks ) do if RankID > Rank and nPoints >= Data[ nType ] then Rank = RankID end end return Rank end function Player:SetSubRank( ply, nRank, nPoints ) if nRank >= #_C.Ranks then local nTarget = 10 if not ply.SubRank or ply.SubRank != nTarget then ply.SubRank = nTarget ply:SetNWInt( "SubRank", ply.SubRank ) end else local nDifference = _C.Ranks[ nRank + 1 ][ 3 ] - _C.Ranks[ nRank ][ 3 ] local nStepSize = nDifference / 10 local nOut, nStep = 1, 1 for i = _C.Ranks[ nRank ][ 3 ], _C.Ranks[ nRank + 1 ][ 3 ], nStepSize do if nPoints >= i then nOut = nStep end nStep = nStep + 1 end if not ply.SubRank or ply.SubRank != nOut then ply.SubRank = nOut ply:SetNWInt( "SubRank", ply.SubRank ) end end end [/code] I hope you can follow that, but in basic English: It gets the SUM of ALL points for that player on the related styles for that time (normal or angled styles). It then matches it against a fixed scalar that's calculated upon startup of the server. This can be changed (Player.LadderScalar) to make ranking up easier or harder. I found 1.40 is a good balance (keeps achieving the top rank hard). Let me know if there's anything else!
I'm sorry to post such a "leach" like question on here but, if anyone has been able to make progress on the Deathrun gamemode could you please let me know? I am very interested init, and would love to see the gamemode fully working.
Alright grav, extremely small and stupid question >_< Im using the !hop command on my server and I am wondering where the heck that is in your gamemode? I need to edit the !hop command so the ip's are actually right but I completely forgot where it is
[QUOTE=qTY3;47454126]Alright grav, extremely small and stupid question >_< Im using the !hop command on my server and I am wondering where the heck that is in your gamemode? I need to edit the !hop command so the ip's are actually right but I completely forgot where it is[/QUOTE] The gamemode isn't a game source of 100,000 lines. Even if it were, you can trace it easily. Modern text editors like Notepad++ have neat features where you can search all files in a folder: Ctrl + F -> 3rd tab (Find in Files) -> Change directory to your gamemode directory, set the filter to *.lua, enter what you are looking for (in this case "hop", with quotations, since it's a string). This will bring us to sv_command.lua, at the line starting with this: [code] self:Register( { "hop", "switch", "server" }, function( ply, args ) [/code] If you can somewhat understand the code, you will know it's using one table: Lang.Servers Now, simply search all files for this: Lang.Servers core_lang.lua will come up. The table in there makes a lot of sense, so I'm sure you can do it on your own from there! [code] Lang.Servers = { -- Add your servers like this: -- ["bhop"] = { "IP.ADDRESS.GOES.HERE:27015", "Our Bunny Hop Server" }, -- ["deathrun"] = { "IP.ADDRESS.GOES.HERE:27015", "Our Deathrun Server" }, } [/code] --- Despite all of that, I recommend also changing your command function to this: [code] self:Register( { "hop", "switch", "server" }, function( ply, args ) Core:Send( ply, "Client", { "Server", Lang.Servers } ) end ) [/code] Then go to cl_init.lua and change the Client:ServerSwitch function to: [code] function Client:ServerSwitch( data ) local func = {} for _,tab in pairs( data ) do table.insert( func, tab[ 2 ] ) table.insert( func, function() LocalPlayer():ConCommand( "connect " .. tab[ 1 ] ) end ) end table.insert( func, "Cancel" ) table.insert( func, function() end ) Window.MakeQuery( "Select a server to connect to", "Server hop", unpack( func ) ) end [/code] For that to work, you have to remake your Lang.Servers table to look like this: [code] Lang.Servers = { { "188.165.255.107:27015", "Bunny Hop (EU)" }, { "192.223.29.127:27015", "Bunny Hop (US)" }, { "188.165.255.107:27030", "Jailbreak" }, { "188.165.255.107:27040", "Skill Surf" }, { "188.165.255.107:27050", "Deathrun" } } [/code] That'll give you a nice little GUI rather than a chat command based hop system. Of course, you can combine both if you want (for which you'll have to change the command part of it) I'm generous again so something like this: [code] self:Register( { "hop", "switch", "server" }, function( ply, args ) if #args > 0 then local bMatched = false for k,v in pairs( Lang.Servers ) do if string.find( string.lower( v[ 2 ] ), string.lower( args[ 1 ] ), 1, true ) then -- bMatched = true ply.DCReason = "Player hopped to " .. v[ 2 ] timer.Simple( 10, function() if IsValid( ply ) then ply.DCReason = nil end end ) ply:SendLua( "LocalPlayer():ConCommand(\"connect " .. v[ 1 ] .. "\")" ) -- You should really send a string to receive and do this on the client with a confirmation, but you get the idea (this might even be illegal) break end end if not bMatched then Core:Send( ply, "Print", { "General", "The server '" .. args[ 1 ] .. "' is not a valid server." } ) end else Core:Send( ply, "Client", { "Server", Lang.Servers } ) end end ) [/code] Good luck with it! ----- Also, I'd really love to clean up cl_receive sometime by renaming functions and adding them to a local scope, allowing me to do a dynamic lookup rather than these monstrous if, elseif statement trees.
[B]Hello Gravious,[/B] After sometime of using your gamemode files, I've created a Bunny Hop server but sadly enough I've faced a few problems. One of which firstly is that I would like to have a thirdperson function which can be activated and deactivated with a click of a button "F1" in my case, it's a bit like Deathrun in other words. Not only that but I've noticed that on Deathrun as well when you spectate a player you can see the keys that they are pressing, I've tried to do that with your "cl_strafe" file, but it never turns out well since you can see the keys their pressing but the "mouse left" and "mouse right" don't show this at all. Any help would be much appreciated, and as from that I'm thoroughly loving your gamemodes, thank you for all your hard work into making this possible! [B]Thanks for reading![/B]
[QUOTE=GriefMoDz;47458959]Hello Gravious, After sometime of using your gamemode files, I've created a Bunny Hop server but sadly enough I've faced a few problems. One of which firstly is that I would like to have a thirdperson function which can be activated and deactivated with a click of a button "F1" in my case, it's a bit like Deathrun in other words. Not only that but I've noticed that on Deathrun as well when you spectate a player you can see the keys that they are pressing, I've tried to do that with your "cl_strafe" file, but it never turns out well since you can see the keys their pressing but the "mouse left" and "mouse right" don't show this at all. Any help would be much appreciated, and as from that I'm thoroughly loving your gamemodes, thank you for all your hard work into making this possible! Thanks for reading![/QUOTE] Glad to hear another person is very happy with them! Bunny Hop never had third person functionality by design, as it isn't required for Bunny Hop in my eyes. The [b]unfinished[/b] deathrun gamemode does have this functionality, since it's much more common in those gameplay environments. When you search the deathrun gamemode for "thirdperson", the important things that come up is this (Deathrun's cl_init.lua): [code] local CThirdPerson = CreateClientConVar( "sl_thirdperson", "0", true, false ) function GM:CalcView( ply, pos, angles, fov ) if CThirdPerson:GetBool() then pos = pos - (angles:Forward() * 100) + (angles:Up() * 40) local ang = (ply:GetPos() + (angles:Up() * 30 )) - pos ang:Normalize() angles = ang:Angle() end return self.BaseClass:CalcView( ply, pos, angles, fov ) end function GM:ShouldDrawLocalPlayer( ply ) return CThirdPerson:GetBool() or self.BaseClass:ShouldDrawLocalPlayer( ply ) end function Client:ToggleThirdperson() local nNew = 1 - CThirdPerson:GetInt() RunConsoleCommand( "sl_thirdperson", nNew ) end [/code] You can put this in your Bunny Hop's cl_init.lua and you'll be able to toggle thirdperson by typing sl_thirdperson 1 or sl_thirdperson 0 in console. The name for this can be changed in the CreateClientConVar function, of course (as well as in the Client:ToggleThirdperson() function). To get it to work by pressing F1, you need to add this function on the server-side of your gamemode, preferably in the command handling file: sv_command.lua: [code] function GM:ShowTeam( ply ) if not Command:Possible( ply ) then return end return Core:Send( ply, "Client", { "Thirdperson" } ) end [/code] After that, open up cl_receive.lua and search for the "TransferHandle" function ([B]local function TransferHandle( szAction, varArgs )[/B]). Look for the IF statement opening with: [B]elseif szAction == "Client" then[/B] At the bottom of that indented tree, put this code: [code] elseif szType == "Thirdperson" then Client:ToggleThirdperson() [/code] And that should be it ;) --- As for your problem with the key display, this is because the cl_strafe.lua file is 100% client-sided. It takes input from what the client receives and displays it, nothing more. The reason for this is because I made it [i]solely[/i] for my [url=https://www.youtube.com/watch?v=4EPpZz4pBy0]Bunny Hop tutorials[/url], where the only player in-game was me, so there was no need for sending over input to any spectators. (The whole module isn't that great, but then again, all it did was get the job done for my tutorials) I said I would not supply any support for making this server-sided since it's a hard task to make it as optimized as can be. It would be your task to implement this feature as a server owner, I'm assuming. I know another [url=http://facepunch.com/showthread.php?t=1242352]older Deathrun gamemode[/url] that does have the server-side spectator keys done, you could have a look at that and recreate it to work with another HUD on the client.
[QUOTE=Gravious;47460955]Glad to hear another person is very happy with them! Bunny Hop never had third person functionality by design, as it isn't required for Bunny Hop in my eyes. The [b]unfinished[/b] deathrun gamemode does have this functionality, since it's much more common in those gameplay environments. When you search the deathrun gamemode for "thirdperson", the important things that come up is this (Deathrun's cl_init.lua): [code] local CThirdPerson = CreateClientConVar( "sl_thirdperson", "0", true, false ) function GM:CalcView( ply, pos, angles, fov ) if CThirdPerson:GetBool() then pos = pos - (angles:Forward() * 100) + (angles:Up() * 40) local ang = (ply:GetPos() + (angles:Up() * 30 )) - pos ang:Normalize() angles = ang:Angle() end return self.BaseClass:CalcView( ply, pos, angles, fov ) end function GM:ShouldDrawLocalPlayer( ply ) return CThirdPerson:GetBool() or self.BaseClass:ShouldDrawLocalPlayer( ply ) end function Client:ToggleThirdperson() local nNew = 1 - CThirdPerson:GetInt() RunConsoleCommand( "sl_thirdperson", nNew ) end [/code] You can put this in your Bunny Hop's cl_init.lua and you'll be able to toggle thirdperson by typing sl_thirdperson 1 or sl_thirdperson 0 in console. The name for this can be changed in the CreateClientConVar function, of course (as well as in the Client:ToggleThirdperson() function). To get it to work by pressing F1, you need to add this function on the server-side of your gamemode, preferably in the command handling file: sv_command.lua: [code] function GM:ShowTeam( ply ) if not Command:Possible( ply ) then return end return Core:Send( ply, "Client", { "Thirdperson" } ) end [/code] After that, open up cl_receive.lua and search for the "TransferHandle" function ([B]local function TransferHandle( szAction, varArgs )[/B]). Look for the IF statement opening with: [B]elseif szAction == "Client" then[/B] At the bottom of that indented tree, put this code: [code] elseif szType == "Thirdperson" then Client:ToggleThirdperson() [/code] And that should be it ;) --- As for your problem with the key display, this is because the cl_strafe.lua file is 100% client-sided. It takes input from what the client receives and displays it, nothing more. The reason for this is because I made it [i]solely[/i] for my [url=https://www.youtube.com/watch?v=4EPpZz4pBy0]Bunny Hop tutorials[/url], where the only player in-game was me, so there was no need for sending over input to any spectators. (The whole module isn't that great, but then again, all it did was get the job done for my tutorials) I said I would not supply any support for making this server-sided since it's a hard task to make it as optimized as can be. It would be your task to implement this feature as a server owner, I'm assuming. I know another [url=http://facepunch.com/showthread.php?t=1242352]older Deathrun gamemode[/url] that does have the server-side spectator keys done, you could have a look at that and recreate it to work with another HUD on the client.[/QUOTE] [B]Hello Gravious,[/B] Thank you so much, I've now got my thirdperson fully working thanks to you. Now all that's left is to develop a server-side HUD for the spectator keys, that shouldn't be to hard to do so I wouldn't need to bother you at any chances, whilst I know you are busy more than I am, of course. Within all honesty I fully respect for what you've done here, as well as providing quick and relevant information to guide everyone on quick start and down with a nice slope. I bring you good luck in your future endeavours. Thank you again! [B]Yours Sincerely,[/B] GriefMoDz [B]EDIT:[/B] Sorry, I lied. I've noticed that when I use ULX on my server it conflicts with the gamemodes commands, for an example lets say I type !admin, it won't open the admin panel up at any cost at all, this is really puzzling as if I'm going to add a map or remove a map I need to remove ULX completely from the server, and than it works from there. I find it quite puzzling to be honest, in which makes it really hard to manage my server.
[QUOTE=GriefMoDz;47463879][B]Hello Gravious,[/B] Thank you so much, I've now got my thirdperson fully working thanks to you. Now all that's left is to develop a server-side HUD for the spectator keys, that shouldn't be to hard to do so I wouldn't need to bother you at any chances, whilst I know you are busy more than I am, of course. Within all honesty I fully respect for what you've done here, as well as providing quick and relevant information to guide everyone on quick start and down with a nice slope. I bring you good luck in your future endeavours. Thank you again! [B]Yours Sincerely,[/B] GriefMoDz [B]EDIT:[/B] Sorry, I lied. I've noticed that when I use ULX on my server it conflicts with the gamemodes commands, for an example lets say I type !admin, it won't open the admin panel up at any cost at all, this is really puzzling as if I'm going to add a map or remove a map I need to remove ULX completely from the server, and than it works from there. I find it quite puzzling to be honest, in which makes it really hard to manage my server.[/QUOTE] The ULX conflict is because my gamemode was initially made as a standalone gamemode that would replace ULX somewhat. To fix this conflict, simply open up modules/sv_admin.lua, look for "Admin:CheckPlayerStatus". What you have to do is, remove the 2nd until 4th line of the function, so it'll look like this: [code] function Admin:CheckPlayerStatus( ply, reload ) local nAccess = Admin:GetAccess( ply ) if nAccess >= Admin.Level.Base then Admin:SetAccessIcon( ply, nAccess ) end if not reload and SQL.Available then Admin:CheckBan( ply ) end end [/code] That should do it!
[QUOTE=Gravious;47465316]The ULX conflict is because my gamemode was initially made as a standalone gamemode that would replace ULX somewhat. To fix this conflict, simply open up modules/sv_admin.lua, look for "Admin:CheckPlayerStatus". What you have to do is, remove the 2nd until 4th line of the function, so it'll look like this: [code] function Admin:CheckPlayerStatus( ply, reload ) local nAccess = Admin:GetAccess( ply ) if nAccess >= Admin.Level.Base then Admin:SetAccessIcon( ply, nAccess ) end if not reload and SQL.Available then Admin:CheckBan( ply ) end end [/code] That should do it![/QUOTE] Sadly enough, I tried that area of idea and it didn't work what so ever. There's still no effect into me typing "!admin", hoping it would open the admin panel but it didn't. I wonder what could be the reason behind this issue.
I found just commenting out line 188 'ply:SetUserGroup( "admin" )' fixed it, I didn't bother commenting out/removing anything else besides that one line.
[QUOTE='[LW] Perfect;47466542']I found just commenting out line 188 'ply:SetUserGroup( "admin" )' fixed it, I didn't bother commenting out/removing anything else besides that one line.[/QUOTE] That's exactly what I instructed him to do ;) It should solve that conflict. [QUOTE=GriefMoDz;47466294]Sadly enough, I tried that area of idea and it didn't work what so ever. There's still no effect into me typing "!admin", hoping it would open the admin panel but it didn't. I wonder what could be the reason behind this issue.[/QUOTE] If it's saying the command is invalid, that means it's just not loading your admin details from the database. This hasn't got to do with ULX, this is simply because you're missing your Steam ID and access level in the gmod_admins table.
[QUOTE=Gravious;47466795]That's exactly what I instructed him to do ;) It should solve that conflict. If it's saying the command is invalid, that means it's just not loading your admin details from the database. This hasn't got to do with ULX, this is simply because you're missing your Steam ID and access level in the gmod_admins table.[/QUOTE] Yeah, everything's working perfect as its supposed to, I just had to remove one of the modules for ULX which had the same exact command as to accessing the admin panel, thank you so much, I really appreciate it!
I have this little problem, the start, end, and example zones are all showing as missing textures for me. How can I fix this?
[QUOTE=JasonMan34;47518129]I have this little problem, the start, end, and example zones are all showing as missing textures for me. How can I fix this?[/QUOTE] This should be because the client is unable to download them. Do you have a working FastDL? You have to put them on there, or you could distribute the files manually but I strongly recommend against that (unless you're hosting the server just for you).
-snip-
Hi, I noticed that there is a bug with mode switching. When a player switches mode, they will generate a lag spike for all players on the server, except themselves. You can notice this by having net_graph 4 in console enabled, looking at the performance, and changing modes. The person changing won't notice, but other players will. e.g. !l > !n in chat. Lag spike on !l, lag spike on !n. This can lead to serious abuse on the server. Can you please look into this? Thanks.
Has anyone else encountered lag while using this gamemode? Especially when people are entering the server?
[QUOTE=umpix;47572561]Has anyone else encountered lag while using this gamemode? Especially when people are entering the server?[/QUOTE] Yes I have, my servers get a ton of join lag ;-;
If you use ULX, then there will be join lag. And also lag from that bug I reported above.
I'll try to look into it. It's really always been a mystery for me why this occurs (The join lag). If anyone has suggestions, let me know. I know that if you have a good server, you won't run into problems, but with low-end single-core CPU servers you'll definitely notice the lag. Weird thing is, this "join lag" is the only type of lag in the gamemode I'm aware of, but if it's related to loading style/record data, I'll have a look at this.
[QUOTE=Gravious;47574963]I'll try to look into it. It's really always been a mystery for me why this occurs (The join lag). If anyone has suggestions, let me know.[/QUOTE] What data gets prepared and sent when I client connects? As well if you make sure you localize everything you do you can increase the speed of which lua will process things. For example instead of doing: [CODE]table.insert(table,value)[/CODE] You can do: [CODE]local TableInsert=table.insert TableInsert(table,value)[/CODE] That is a good practice to do in lua and you don't see many people doing it. Another example: [CODE]local MyToBeGlobal={} function MyToBeGlobal.Coolfunction() print("Yay!") end _G.MyToBeGlobal=MyToBeGlobal[/CODE] I don't know how much this effects speed (If at all) but a lot of people misuse ":" in functions when they really should just be using "." A specific example from your code is: [CODE]function Core:Optimize() hook.Remove( "PlayerTick", "TickWidgets" ) hook.Remove( "PreDrawHalos", "PropertiesHover" ) end[/CODE] This would do just fine with "." as it isn't calling on any type of object and Core is a static global variable anyways. Its a bit alarming when you include a lot of ":" in functions but when you search for "self" its never used. Again this most likely has no performance impact but its something that should be looked into regardless. -- I would seek to find which things load on player join and see if you can optimize them. A good example is nested tables being that a nested table is [B]significantly[/B] slower than a bunch of separate tables. (If you know what I mean) As well, after looking through the Player:Join process it appears you are doing a lot of MySQL queries which could be cached on server startup. Anyways, feel free to yell at me at on how I am wrong.
[QUOTE=itzaname;47578050]For example instead of doing: [CODE]table.insert(table,value)[/CODE] You can do: [CODE]local TableInsert=table.insert TableInsert(table,value)[/CODE] That is a good practice to do in lua and you don't see many people doing it. [/QUOTE] Can I ask why it's faster to replace this function with a local variable that is still calling the function anyway? Isn't that no different from his way? Or is Lua doing something here that languages I know don't do. [editline]23rd April 2015[/editline] [QUOTE=DannyCore;47571175]Hi, I noticed that there is a bug with mode switching. When a player switches mode, they will generate a lag spike for all players on the server, except themselves. You can notice this by having net_graph 4 in console enabled, looking at the performance, and changing modes. The person changing won't notice, but other players will. e.g. !l > !n in chat. Lag spike on !l, lag spike on !n. This can lead to serious abuse on the server. Can you please look into this? Thanks.[/QUOTE] Looked into this, on both our Surf and Bhop servers, and the issue isn't occurring for me and my server. Players see no lag and I only see a small hop in performance on the net graph. You may have accidentally added something to game code that is causing this.
[QUOTE=Clouds;47579826]Can I ask why it's faster to replace this function with a local variable that is still calling the function anyway? Isn't that no different from his way? Or is Lua doing something here that languages I know don't do.[/QUOTE] Localizing functions benefits really only shine if you are calling the function more than once. Basically local functions/variables will always be faster than globals. There are some other benefits from localizing as well but they don't really pertain to speeding up things.
[QUOTE=itzaname;47578050]What data gets prepared and sent when I client connects? As well if you make sure you localize everything you do you can increase the speed of which lua will process things. For example instead of doing: [CODE]table.insert(table,value)[/CODE] You can do: [CODE]local TableInsert=table.insert TableInsert(table,value)[/CODE] That is a good practice to do in lua and you don't see many people doing it. [/QUOTE] I've been doing programming relating things for long enough to know that this ONLY impacts when you're calling the function a lot. If you're doing this over and over everywhere your code is only gonna do one thing and that's get messy. I'm not sure if you've looked through the gamemode at all, but almost everywhere where heavy calculations or fast responses are required, essential variables are localized. [QUOTE=itzaname;47578050] Another example: [CODE]local MyToBeGlobal={} function MyToBeGlobal.Coolfunction() print("Yay!") end _G.MyToBeGlobal=MyToBeGlobal[/CODE] [/QUOTE] I think you're misunderstanding globals. Whenever you call a function like SomeRandomFunction() and it cannot be found in a local variable, it will loop over the entire _G table to find it, if it then isn't found, it will throw an error. If you're calling MyToBeGlobal.Coolfunction() outside of that file, it will be just as fast as calling any other global function, the only thing this provides is uniformity as in, you can call MyToBeGlobal.Coolfunction() from any file but in the file where it's defined it'll be looked up the fastest. [QUOTE=itzaname;47578050] I don't know how much this effects speed (If at all) but a lot of people misuse ":" in functions when they really should just be using "." A specific example from your code is: [CODE]function Core:Optimize() hook.Remove( "PlayerTick", "TickWidgets" ) hook.Remove( "PreDrawHalos", "PropertiesHover" ) end[/CODE] This would do just fine with "." as it isn't calling on any type of object and Core is a static global variable anyways. Its a bit alarming when you include a lot of ":" in functions but when you search for "self" its never used. Again this most likely has no performance impact but its something that should be looked into regardless. [/QUOTE] I did notice some strange behavior with this once, so I decided to check it out in more detail. Here's a little test I did: [CODE] local testobj = {} testobj.foo1 = function( a, b, c ) print( "FOO1", a, b, c, self ) end function testobj.foo2( a, b, c ) print( "FOO2", a, b, c, self ) end function testobj:foo3( a, b, c ) print( "FOO3", a, b, c, self ) end testobj.foo1( 1, 2, 3 ) testobj.foo2( 4, 5, 6 ) testobj.foo3( 7, 8, 9 ) testobj:foo1( 9, 8, 7 ) testobj:foo2( 6, 5, 4 ) testobj:foo3( 3, 2, 1 ) local f1 = testobj.foo1 f1( 10, 100, 1000 ) local f2 = testobj.foo2 f2( 100, 1000, 10000 ) local f3 = testobj.foo3 f3( 1000, 10000, 100000 ) [/CODE] Here are the results: [QUOTE] FOO1 1 2 3 nil FOO2 4 5 6 nil FOO3 8 9 nil 7 FOO1 table: 0x0f2c10c8 9 8 nil FOO2 table: 0x0f2c10c8 6 5 nil FOO3 3 2 1 table: 0x0f2c10c8 FOO1 10 100 1000 nil FOO2 100 1000 10000 nil FOO3 10000 100000 nil 1000 [/QUOTE] The main thing I can see from this is that when you define a function with a . and then access it by : it means you will get the self parameter (as seen in the 4th to 6th row), but if you have defined a function with : you won't see the self-object in the first parameter, but in a separate 'invisible' self variable. I was aware this is possible, but I didn't actually think about it. I just boldly used : everywhere because I am used to it from C++, bad habit in this case I guess. [QUOTE=itzaname;47578050] I would seek to find which things load on player join and see if you can optimize them. A good example is nested tables being that a nested table is [B]significantly[/B] slower than a bunch of separate tables. (If you know what I mean) As well, after looking through the Player:Join process it appears you are doing a lot of MySQL queries which could be cached on server startup. Anyways, feel free to yell at me at on how I am wrong.[/QUOTE] Yeah I'm going to see wherever I can optimize this, but it's hardly beneficial I think, so unless I'm able to make major improvements, it probably won't surface on this thread.
[QUOTE=Gravious;47580419]I've been doing programming relating things for long enough to know that this ONLY impacts when you're calling the function a lot. If you're doing this over and over everywhere your code is only gonna do one thing and that's get messy. I'm not sure if you've looked through the gamemode at all, but almost everywhere where heavy calculations or fast responses are required, essential variables are localized. I think you're misunderstanding globals. Whenever you call a function like SomeRandomFunction() and it cannot be found in a local variable, it will loop over the entire _G table to find it, if it then isn't found, it will throw an error. If you're calling MyToBeGlobal.Coolfunction() outside of that file, it will be just as fast as calling any other global function, the only thing this provides is uniformity as in, you can call MyToBeGlobal.Coolfunction() from any file but in the file where it's defined it'll be looked up the fastest.[/QUOTE] I get globals just fine but the goal for that really is the fact that calls within the script are faster. I again admit that these do not have a significant impact but it [B]is[/B] good practice to do and opens you up to other opportunities. E.G. You can wipe the global table when your scripts have been loaded and nothing will break. [T]http://puu.sh/hnWa8/638aefb76f.png[/T]
[QUOTE=itzaname;47581268]I get globals just fine but the goal for that really is the fact that calls within the script are faster. I again admit that these do not have a significant impact but it [B]is[/B] good practice to do and opens you up to other opportunities. E.G. You can wipe the global table when your scripts have been loaded and nothing will break. [T]http://puu.sh/hnWa8/638aefb76f.png[/T][/QUOTE] Yeah I got that, but I was saying that if you're only using a function once, there's no gain in first loading the address into a local variable. Don't get me wrong, thanks for the tips, they definitely caused me to revise a bunch of stuff.
[QUOTE=Gravious;47581902]Yeah I got that, but I was saying that if you're only using a function once, there's no gain in first loading the address into a local variable. Don't get me wrong, thanks for the tips, they definitely caused me to revise a bunch of stuff.[/QUOTE] Anyways I would definitely look to see if you can cache the database on server start rather than making the db call as it may be contributing to the join lag. In the gamemode me and a buddy have developing using the cache has significantly reduced lag. [CODE]local Cache=Database.Cache local List=Cache.zones2{map=game.GetMap()}[/CODE]
Snip
[QUOTE=DannyCore;47620889]Snip[/QUOTE] Oh c'mon, why is everyone snipping :(
[QUOTE=Gravious;47621313]Oh c'mon, why is everyone snipping :([/QUOTE] I reported something but felt it would be better to dig into it more myself to confirm it's not something on my end instead of bothering ya.
Sorry, you need to Log In to post a reply to this thread.