• How to save a loadout
    41 replies, posted
I'm trying to do a custom loadout, so that whenever you select a weapon and spawn, it will save that loadout for next time you join, like Bad Company 2 does. Should I use an SQL database?
[QUOTE=thejjokerr;21979604]Well. If you use an SQL database to also save other kinds of information yes. If your only saving a loadout, you could simply save it to a .txt file. PS: I always like MySQL saving because it allows me to show statistics on my website :3[/QUOTE] Oh ok :D thankyou :D [editline]11:28AM[/editline] Gah MySQL is not installing, it keeps giving me the errors message: [code]Could not start the service MySQL. Error: 0[/code] Can anyone help with this?
[QUOTE=HeavyMtl123;21979896]Oh ok :D thankyou :D [editline]11:28AM[/editline] Gah MySQL is not installing, it keeps giving me the errors message: [code]Could not start the service MySQL. Error: 0[/code] Can anyone help with this?[/QUOTE] I can provide you with a database(free of charge), although that one will be external. Tell me if you're interested.
I'd rather set up my own database, I just want someone to help me fix that error
[QUOTE=HeavyMtl123;21981847]I'd rather set up my own database, I just want someone to help me fix that error[/QUOTE] Google reveals many people are having the same issue. Most issues are fixed by deleting the mySQL directories and registery keys, rebooting the PC. Then to retry the installation. It's possible the service is running in the background while you're running the installer: [URL]http://www.astahost.com/info.php/Error-Installing-Mysql-Server_t3605.html[/URL] Quote: This is a known problem. Do you remember how you'd to create a MySQL Service and specify a common windows service name for MySQL when you setup 4.018 ? When you simply uninstall MySQL, it removes the present installation - without terminating the service. Under such circumstances, the original .exe file that runs as the windows service doesn't get deleted, and still keeps loading/running in the background. When you try to install a newer version over it, the running service prevents the .exe being overwritten and this generates that error message you're getting. Your simplest way out, is to reinstall the old MySQL again, use it to Stop and Disable the Service and then uninstall it. Next install the newer version. Second method: Goto Control Panel > Administrative Options > Services. From the list of services, find out the MySQL service and Stop It. Then Disable it from running for good. Next go to the mysql installation directory and remove it entirely. Now you can install the new version without a hitch. Delete any registery data too.
You're wrong, i'm not upgrading, I installed MySQL first time, and it gave me the error, it didn't run anything.
[QUOTE=HeavyMtl123;21981995]You're wrong, i'm not upgrading, I installed MySQL first time, and it gave me the error, it didn't run anything.[/QUOTE] Edited post. Instead of narrowing your focus on this, my offer still stands. I can create a db where you can develop on, since getting the tmysql or mysql module to run "can" be a pain.
is ther any way to safe a faction to a database or can that be saved to a .txt file as well
Unless you have multiple servers, it's much much much easier to just use the database and library included with GMod.
[QUOTE=Entoros;21988246]Unless you have multiple servers, it's much much much easier to just use the database and library included with GMod.[/QUOTE] How would I go about using these. (Sorry, i've never used databases before)
Here's the library: [url]http://wiki.garrysmod.com/?title=Sql[/url] If you don't know any SQL, well then I would recommend learning. It's very useful to know.
[QUOTE=Entoros;21989604]Here's the library: [URL]http://wiki.garrysmod.com/?title=Sql[/URL] If you don't know any SQL, well then I would recommend learning. It's very useful to know.[/QUOTE] Thankyou, you're a very helpful person :D
Also, using the commands like sql.TableExists do I need to put that code in a seperate folder, or in shared.lua? The tutorial isn't very clear. Gah double post D:
Dunno if this helps [lua] require( "glon" ) hook.Add( "PlayerLoadout", "SethLoadouts", function( ply ) local weps = glon.decode( ply:GetPData( "Weapons" ) ) if !weps then return end for k, v in pairs( weps ) do ply:Give( v ) end end ) concommand.Add( "ld_setweapon", function( ply, cmd, args ) if !ValidEntity( ply ) or ply:IsSuperAdmin() then if !args[2] then return end for k, v in ipairs( player.GetAll() ) do if string.find( string.lower( v:Nick() ), string.lower( args[1] ) ) then local weps = glon.decode( v:GetPData( "Weapons" ) ) or {} table.insert( weps, args[2] ) v:SetPData( "Weapons", glon.encode( weps ) ) v:Give( args[2] ) if !ValidEntity( ply ) then print( "Set " .. args[2] .. " for " .. v:Nick() .. "." ) else ply:ChatPrint( "Set " .. args[2] .. " for " .. v:Nick() .. "." ) end end end else ply:ChatPrint( "Superadmin access required.") end end ) concommand.Add( "ld_takeweapon", function( ply, cmd, args ) if !ValidEntity( ply ) or ply:IsSuperAdmin() then if !args[2] then return end for k, v in ipairs( player.GetAll() ) do if string.find( string.lower( v:Nick() ), string.lower( args[1] ) ) then local weps = glon.decode( v:GetPData( "Weapons" ) ) or {} for k, v in pairs( weps ) do if v == args[2] then table.remove( weps, k ) end end v:SetPData( "Weapons", glon.encode( weps ) ) if !ValidEntity( ply ) then print( "Removed " .. args[2] .. " from " .. v:Nick() .. "." ) else ply:ChatPrint( "Removed " .. args[2] .. " from " .. v:Nick() .. "." ) end end end else ply:ChatPrint( "Superadmin access required.") end end ) concommand.Add( "ld_takeallweapons", function( ply, cmd, args ) if !ValidEntity( ply ) or ply:IsSuperAdmin() then if !args[1] then return end for k, v in ipairs( player.GetAll() ) do if string.find( string.lower( v:Nick() ), string.lower( args[1] ) ) then local weps = {} v:SetPData( "Weapons", glon.encode( weps ) ) v:StripWeapons() if !ValidEntity( ply ) then print( "Removed all of " .. v:Nick() .. "'s weapons." ) else ply:ChatPrint( "Removed all of " .. v:Nick() .. "'s weapons." ) end end end else ply:ChatPrint( "Superadmin access required.") end end ) [/lua]
If you've ever played BC2, you'll know that when you choose your weapons and spawn with them it saves that particular loadout for that class, that's what I want to do.
Okay, i've created the SQL code ( Thanks to Entoros ) where does it go? will it be in shared.lua? :ninja: Failmerge strikes again :ninja:
[QUOTE=iRzilla;22005179]Serverside code. Go's in init.lua.[/QUOTE] Have some Love iRzilla :D
wow 6 months of coding and you still dont know where to put serverside code sucks to be you
[QUOTE=|King Flawless|;22006012]wow 6 months of coding and you still dont know where to put serverside code sucks to be you[/QUOTE] Can't you stay banned? Also, just because i've been coding for 6 months doesn't mean I know a lot, i've just been coding since 6 months ago.
[QUOTE=HeavyMtl123;22006023]Can't you stay banned? Also, just because i've been coding for 6 months doesn't mean I know a lot, i've just been coding since 6 months ago.[/QUOTE] Explain what you did in month one if on month 6 you learned where to put serverside lua
[QUOTE=|King Flawless|;22006083]Explain what you did in month one if on month 6 you learned where to put serverside lua[/QUOTE] I started learning lua, but unlike you, i wasn't forcing it into my brain every day, i just looked over tutorials every 1 or 2 days, and tried to learn it, I had exams and revising to do as well, so it's really two shits i just couldn't give.
[QUOTE=HeavyMtl123;22006114]I started learning lua, but unlike you, i wasn't forcing it into my brain every day, i just looked over tutorials every 1 or 2 days, and tried to learn it, I had exams and revising to do as well, so it's really two shits i just couldn't give.[/QUOTE] wow so 6 months is about 180 days so if you looked at 1 tutoral every two days you looked at 90 tutorals there is about 25 tutorals on the wiki so you have seen every tutoral 3.6 times and yet you still had to make a thread about how you failed to follow a derma tutoral?
[QUOTE=|King Flawless|;22006207]wow so 6 months is about 180 days so if you looked at 1 tutoral every two days you looked at 90 tutorals there is about 25 tutorals on the wiki so you have seen every tutoral 3.6 times and yet you still had to make a thread about how you failed to follow a derma tutoral?[/QUOTE] Again. Two shits that I just don't give, if I don't understand something, I don't understand something.
[QUOTE=HeavyMtl123;22006230]Again. Two shits that I just don't give, if I don't understand something, I don't understand something.[/QUOTE] You should just give up after 180 days you have got no where
[QUOTE=|King Flawless|;22006249]You should just give up after 180 days you have got no where[/QUOTE] Can't you go get banned?
@ King Flawless, you are seriously stalking this guy, and just wont let it go, that he's not as good at Lua as you are. [sp]Atleast he's not a dick.[/sp]
[QUOTE=HeavyMtl123;22006401]Can't you go get banned?[/QUOTE] flawless is pro~
[QUOTE=CombineGuru;22006877]flawless is pro~[/QUOTE] But he's a dick.
[QUOTE=|King Flawless|;22006249]You should just give up after 180 days you have got no where[/QUOTE] i have spent 2 months figuring out where every thing goes what have u done u have been a dick to words him cant u just go troll some where else and i was reading this topic for help 2
[QUOTE=cap5555;22024796]i have spent 2 months figuring out where every thing goes what have u done u have been a dick to words him cant u just go troll some where else and i was reading this topic for help 2[/QUOTE] Yeah well what he wants is us to sprint before we can even crawl. It's like forcing a 3 month old baby to talk and if it doesn't you kill it. Also cap, from now on, I recommend just imagining his posts don't exist, just ignore them, and carry on the thread without paying attention to him.
Sorry, you need to Log In to post a reply to this thread.