[QUOTE=syl0r;45949941]PlayerInitialSpawn is only called when the player spawns the first time. It should work after the blacklisted player rejoins.[/QUOTE]
Hmm I see, I'll test things out and see if it works
[editline]11th September 2014[/editline]
Okay so it doesn't work, it appears that my hook for PlayerInitialSpawn is not being called as when I added logs they were not called
Is there a way to toggle a derma panel? i.e. allow the same button that brought the panel up to also close it if it's already up?
[QUOTE=zeaga;45950120]Is there a way to toggle a derma panel? i.e. allow the same button that brought the panel up to also close it if it's already up?[/QUOTE]
That should be fairly simple.
Example:
[CODE]
function button:DoClick()
if(self.Panel && self.Panel:IsValid()) then
self.Panel:Remove()
self.Panel = nil
else
self.Panel = vgui.Create("DPanel", someparent)
end
end
[/CODE]
[QUOTE=syl0r;45950249]That should be fairly simple.[/QUOTE]
Thanks! I tried something similar to that, but I used a weird method of checking if the panel was up. I guess I was just being stupid.
I need help involving files from LUA, how would I do things such as open a file then write a entry with a linebreak but afterwards if the entry is already there then just update a certain part like time or points?
I'm trying to make a system to save people to a blacklist for a vote thing, and another that will save a players points value then load it if he returns
[QUOTE=ForrestMarkX;45950576]I need help involving files from LUA, how would I do things such as open a file then write a entry with a linebreak but afterwards if the entry is already there then just update a certain part like time or points?
I'm trying to make a system to save people to a blacklist for a vote thing, and another that will save a players points value then load it if he returns[/QUOTE]
file.Exists
file.Write
file.Append
\n
I'd recommend using ispanel( ) or IsValid( panel ) instead of panel:IsValid because if the panel isn't valid, IsValid will nil error in the example above.
Here are a few documents on it:
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/creating_a_toggle_menu_system.lua.html[/url]
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/open_menu_key_tap_using_bind.lua.html[/url]
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/open_vgui_based_on_keypress.lua.html[/url]
[QUOTE=HumbleTH;45951067]file.Exists
file.Write
file.Append
\n[/QUOTE]
Hmm when using file.Append wouldn't it add a new line to the file? instead of updating the existing entry within the file
[QUOTE=ForrestMarkX;45951145]Hmm when using file.Append wouldn't it add a new line to the file? instead of updating the existing entry within the file[/QUOTE]
You need to add the newline in yourself.
[url=http://wiki.garrysmod.com/page/Main_Page]There is a wiki on this, you know..[/url]
[QUOTE=HumbleTH;45951493]You need to add the newline in yourself.
[url=http://wiki.garrysmod.com/page/Main_Page]There is a wiki on this, you know..[/url][/QUOTE]
I know about that but currently now I'm trying to find a way to find a certain value within an = like Points= then just update that value instead of writing a whole new line, I'm thinking of using something like string.find for a certain value if it exists then just find the value I want to modify with another string.find then do string.right to get the real value after =
[QUOTE=ForrestMarkX;45951703]I know about that but currently now I'm trying to find a way to find a certain value within an = like Points= then just update that value instead of writing a whole new line, I'm thinking of using something like string.find for a certain value if it exists then just find the value I want to modify with another string.find then do string.right to get the real value after =[/QUOTE]
Use the file class.
[url]http://wiki.garrysmod.com/page/Category:File[/url]
[QUOTE=BFG9000;45951736]Use the file class.
[url]http://wiki.garrysmod.com/page/Category:File[/url][/QUOTE]
I've been looking at that but with my limited knowledge of LUA, I'm not entirely sure how to use the functions there especially with ReadBool, ReadByte and etc
Come to think of it, I would actually just read the file first, then modify the returned string before overwriting the whole thing.
Unless you've got a pretty big file.
[QUOTE=BFG9000;45951755]Come to think of it, I would actually just read the file first, then modify the returned string before overwriting the whole thing.
Unless you've got a pretty big file.[/QUOTE]
The file would probably get big with players being added in as the format I have it in is like this
PlayerName, SteamID, Points
So use the file library instead like you have been in conjunction with the string library
[url]http://wiki.garrysmod.com/page/Category:string[/url]
One method is to explode the file using newline as a separator, rewrite what you need to by modifying the returned table, then implode it and file.Write it.
[editline]11th September 2014[/editline]
Woah wait a second this is for data storage?
[QUOTE=BFG9000;45951802]So use the file library instead like you have been in conjunction with the string library
[url]http://wiki.garrysmod.com/page/Category:string[/url]
One method is to explode the file using newline as a separator, rewrite what you need to by modifying the returned table, then implode it and file.Write it.
[editline]11th September 2014[/editline]
Woah wait a second this is for data storage?[/QUOTE]
I see, and yeah it is. I was originally opting to use a MySQL database but since it's not being used across more then 1 server I opted for a local approach with a .txt file
Use this instead of your current system:
[url]http://wiki.garrysmod.com/page/util/TableToKeyValues[/url]
[url]http://wiki.garrysmod.com/page/util/KeyValuesToTable[/url]
It is a bit hinky in that you have to sanitise it for booleans and vector/angle objects, and all the keys are automatically lowercased whether you like it or not, but for what you're doing it's perfect
[QUOTE=BFG9000;45951827]Use this instead of your current system:
[url]http://wiki.garrysmod.com/page/util/TableToKeyValues[/url]
[url]http://wiki.garrysmod.com/page/util/KeyValuesToTable[/url]
It is a bit hinky in that you have to sanitise it for booleans and vector/angle objects, and all the keys are automatically lowercased whether you like it or not, but for what you're doing it's perfect[/QUOTE]
Hmm interesting, I forgot that LUA can use tables
You can also use Table To JSON for a different solution with the same end result.
Problem: My DarkRP server's F4 menu is completely blank, and all jobs/ammo's don't exist.
Error: [LUA] Couldn't include file 'darkrp_customthings\jobs.lua' (File not found) (@gamemodes/darkrp/gamemode/libraries/modificationloader.lua (line 111)) [/LUA]
I do not remember exactly what I did, but I believe I messed up something in the DarkRP core files. (Don't post "Well that's why" just yet, read on.)
I reinstalled DarkRP, and got a clean version of the darkrpmodification addon.
I MANUALLY re-added/edited the settings I had in the old darkrpmodification files.
Every time I saved a file, and originally when it was broken, it gave the above error, once for each file in the "darkrp_customthings", "darkrp_modules", and "darkrp_language" folders. Though, it worked fine.
When I finished editing the last file, it broke again. I don't get any errors, though.
Any help would be greatly, greatly appreciated.
PS: If I take the darkrpmodification addon out of the server files, the F4 menu works fine, using default jobs/ammo's/etc.
So, I'm working on some circles. The issue I'm having is that I'm using an api made by someone else but the api itself is a bit limitted. It only allows for 'cutting' the image in slices Clockwise.
Example:
[T]http://puu.sh/bviNc/05459bf17f.jpg[/T]
Those circles are actually images/materials and I'm cutting away the parts/slices based on a percentage.
I was told another person made an api/a better way to achieve this, does anyone still have that link/ a better way to do it?
[QUOTE=TripsLetash;45956021]So, I'm working on some circles. The issue I'm having is that I'm using an api made by someone else but the api itself is a bit limitted. It only allows for 'cutting' the image in slices Clockwise.
Example:
[T]http://puu.sh/bviNc/05459bf17f.jpg[/T]
Those circles are actually images/materials and I'm cutting away the parts/slices based on a percentage.
I was told another person made an api/a better way to achieve this, does anyone still have that link/ a better way to do it?[/QUOTE]
It was in one of the previous WAYWOs, don't remember which one though.
I am also having a cricle problem
Bascially my friend is trying to make a HUD and I can't help him because I don't know how the fuck it works
He's trying to make a 3/4 of a circle as a healthbar. I've done it in Expression 2, but expression 2 uses degrees and Lua uses radians so I'm stuck on the conversions
here's the E2
[lua]interval(100)
Max = 135
if (X < Max) {X=X+1} --Basically for x=1, 135 do
Offset = 180 -- Rotation
#Rad = pi()/180
Rad = 1
From = Max/Rad
HPX = sin((X+Offset)*2)*10 --Position X of each for instance
HPY = cos((X+Offset)*2)*10 --Position Y of each for instance
holoCreate(X) -creation of the "menu"
holoPos(X,entity():pos() + vec(HPX,HPY,100)) -- setting the position
--useless shit
holoScaleUnits(X,vec(1,1,1))
holoAng(X,ang(0,-X*2,0))
holoColor(X,vec(X,X,X))
[/lua]
Here's the code ROFLBURGER has been helping me with in question:
[lua]
for i=1, math.min(HP,100) do
Rad = math.pi/180
Max = 135*Rad
Offset = 180*Rad
From = Max
X = i*1.35
HPX = math.sin((X+Offset)*2*From)*50
HPY = math.cos((X+Offset)*2*From)*50
surface.SetDrawColor(Color(X,X,X,255))
surface.SetMaterial( Material("vgui/writealphaonly") )
--surface.DrawTexturedRect(RingX,RingY,RingRes,RingRes) --( X axis, Y axis, Width, Height )
surface.DrawTexturedRect(ScrW()/2 + HPX,ScrH()/2 + HPY ,5,5) --( X axis, Y axis, Width, Height )
end
[/lua]
We're trying to get it to show up as a circle in 270degrees (3/4 circle) as mentioned, but we haven't been having any luck getting it to do that.
@ROFLBURGER:
Just use [URL="http://wiki.garrysmod.com/page/math/rad"]math.rad[/URL]
1 radian = 57.2957795 degree
somehow i get these error's on my TTT server
[code] ConVarRef ttt_time_limit_minutes doesn't point to an existing ConVar
ConVarRef ttt_round_limit doesn't point to an existing ConVar
ConVarRef gmod_physiterations doesn't point to an existing ConVar
[/code]
still in my config:
[code]ttt_round_limit 6
ttt_time_limit_minutes 90[/code]
gmod_physiterations ? i have no idea what this is about
[QUOTE=TripsLetash;45956021]
I was told another person made an api/a better way to achieve this, does anyone still have that link/ a better way to do it?[/QUOTE]
[QUOTE=gonzalolog;45872079]
Anyway, there's enough info and i hope someone get fun with this
[URL="https://www.dropbox.com/s/um14hwin6gyh233/Payday%20Deployment.7z?dl=0"]Payday 2 HUD Deployment[/URL]
Oh! And enjoy the circular progress API![/QUOTE]
Maybe this?
So how come does this still allows players to change the convar.
[CODE]CreateConVar("vat_procentage", 0, {FCVAR_SERVER_CAN_EXECUTE, FCVAR_NOTIFY}, "Sets vat" )[/CODE]
This thing should've stopped it from allowing that
[CODE]FCVAR_SERVER_CAN_EXECUTE[/CODE]
[editline]12th September 2014[/editline]
Anyone?
-snip- nevermind, misread the wiki
Sorry, you need to Log In to post a reply to this thread.