• [DarkRP]How can i update a darkrpvar on button click?
    0 replies, posted
Hello, i'm making a simple clan system for darkrp, and i'm new to making gmod addons, modules, etc... But i'm pretty sure i can make a simple clan system, i just need to understand some stuff :) I've made a tab called "Clan" and in there i have a input field, and a button. When i click the button i want to make the clan, but how do i update the value that's in the setDarkRPVar("clan") when i click the button serverside? And then save the clan so it's still there when they rejoin or the server is restarted? If this is too much to ask for, i'm sorry. Another thing i'm not sure about is how i should organize things, like when to use server, when to use shared, and then the client? cl_clanhud.lua: [CODE]local tabName = "Clan" local ply = LocalPlayer(); local clanName = "None"; local function IsInClan() if(IsValid(ply)) then if(ply:getDarkRPVar("clan") == "None") then return false; else return true; end end end function CreateClan() -- hook.Call( "ClanCreate", GAMEMODE, ply ); end local function clanTab() -- DarkRP.switchTabOrder(2, 3) -- Remove the "--" in this line if you want to move the third tab to the left of the second tab! local panel = vgui.Create("DPanel"); if(!IsInClan()) then local clanNameLbl = vgui.Create("DLabel", panel); clanNameLbl:SetText("Clan Name: "); clanNameLbl:SetSize(100, 20); local clanNameTb = vgui.Create("DTextEntry", panel); clanNameTb:SetSize(150, 20); clanNameTb:SetPos(100, 0); clanNameTb:SetText("Clan name..."); clanNameTb:SetTextColor(Color(255, 255, 255, 255)); clanNameTb.OnEnter = function( self ) clanName = self:GetValue(); end local createClanBtn = vgui.Create("DButton", panel); createClanBtn:SetSize(100, 20); createClanBtn:SetPos(50, 30); createClanBtn:SetText("Create Clan"); createClanBtn.DoClick = function() CreateClan(); end else local clanNameLbl = vgui.Create("DLabel", panel); clanNameLbl:SetText("Clan Level: " .. LocalPlayer():Health()); clanNameLbl:SetSize(200, 20); end DarkRP.addF4MenuTab(tabName, panel); end hook.Add("F4MenuTabs", "ClanTab", clanTab);[/CODE] The code is not great, but i've got no clue how else to do it. You can see i have no clue, like i use hook.Call but i'm not doing it right, because i think i'm misunderstanding alot of things sh_clansystem.lua: [CODE]if(SERVER) then local function spawn( ply ) if(ply:getDarkRPVar("clan") != nil) then ply:setDarkRPVar("clan", ply:getDarkRPVar("clan")); else ply:setDarkRPVar("clan", "None"); end end hook.Add("PlayerSpawn", "playerSpawn", spawn); end if(CLIENT) then end[/CODE] Lots of things is out of place, i would really appreciate if anyone can help me, understanding these things, and how to get started. Because i really want to make my own mods to a DarkRP server i'm making with a friend. Again, i would appreciate it alot if any one can help :-)
Sorry, you need to Log In to post a reply to this thread.