• Will this work as a timer
    74 replies, posted
[QUOTE=sintwin;22042306]Yeah, but I think his main issue now is the texture. I am unsure why that is happening, you sure that it is a valid texture? Wait till someone awesome comes and solves it like maker or flapjack lol.[/QUOTE] Well it's a custom texture made by a friend Short Story: I asked him to make a compass, health and armor icons for the hud, then he sent me the .tga files, I used VTFEdit to convert them into .vmt and .vtf files, and shoved them in materials/gui/silkicons. But now when I call them they just appear like that picture above. Btw, that picture does not have the Health and Armor icons because i posted that pic before i set them up.
Can you post the vmt please.
Okay, hang on, uploading... [editline]04:39PM[/editline] [url]http://www.mediafire.com/?zg1ynw0ydon[/url] here you go
The base texture needs to be relative to your materials folder, you also need to use the UnlitGeneric shader. [code]"UnlitGeneric" { "$basetexture" "path/to/vtf" "$ignorez" 1 "$vertexcolor" 1 "$vertexalpha" 1 "$nolod" 1 }[/code]
[QUOTE=MakeR;22043155]The base texture needs to be relative to your materials folder, you also need to use the UnlitGeneric shader. [code]"UnlitGeneric" { "$basetexture" "path/to/vtf" "$ignorez" 1 "$vertexcolor" 1 "$vertexalpha" 1 "$nolod" 1 }[/code][/QUOTE] I am testing to see if it works. [editline]05:12PM[/editline] It still does not work [code]"UnlitGeneric" { "$basetexture" "D:/Program Files/Valve/Steam/steamapps/storewars123/garrysmod/garrysmod/materials/HUDMaterial/new_compass.vtf" "$translucent" 1 "$ignorez" 1 "$vertexcolor" 1 "$vertexalpha" 1 "$nolod" 1 }[/code]
basetexture needs to relative to your materials folder. [code]"$basetexture" "HUDMaterial/new_compass" [/code] You also don't need the .vtf extension.
Did you get the timer working?
[code]"$basetexture" "D:/Program Files/Valve/Steam/steamapps/storewars123/garrysmod/garrysmod/materials/HUDMaterial/new_compass.vtf" [/code] [img]http://skepticalteacher.files.wordpress.com/2009/08/facepalm.jpg[/img] Did you get the timer working? [editline]rawr[/editline] :ninja:
[QUOTE=sintwins;22043571]Did you get the timer working?[/QUOTE] No, i didn't manage to.
nvm, read thread. [QUOTE]But if its in a derma menu, then the derma needs to be refreshed to update any numbers. [/QUOTE] :ninja:
Yay they work now! thankyou MakeR
No problem.
[QUOTE=HeavyMtl123;22043603]No, i didn't manage to.[/QUOTE] Just update the number in a think hook then it will work.
[QUOTE=sintwin;22043712]Just update the number in a think hook then it will work.[/QUOTE] Well no, the thing is, it doesn't draw the text, it draws "You" and then cuts off.
Hmmm that is strange, is it the same code as before?
Oh I got it working, I forgot to use SizeToContents() Stupid me. But now it doesn't countdown, i'm using a think hook, but it stays at 15 seconds.
Could you post the code? :)
Sure [lua]local spawntime = CurTime() +15 local timeleft = math.Round( spawntime - CurTime()) local RespawnTime = vgui.Create( "DLabel", CharacterCreation ) RespawnTime:SetFont( "BudgetLabel" ) RespawnTime:SizeToContents() RespawnTime:SetPos( 50, 20 ) RespawnTime:SetVisible( true ) hook.Add("Think", "UpdateTextHookName", function() RespawnTime:SetText("You have to wait "..timeleft.." sec to spawn") RespawnTime:SizeToContents() end) [/lua] [editline]06:15PM[/editline] All of that is in a function with some other things such as the main derma panel and DButtons and other DLabels and whatnot
You need to update the timeleft variable in the think hook as well.
Hmmmm, try this although it hasn't been tested and I probably made a huuuuge mistake. [lua] hook.Add("Think", "UpdateTextHookName", function() if !LocalPlayer():Alive() then timeleft = math.Round( spawntime - CurTime()) or 0 else local spawntime = CurTime() +15 end end local RespawnTime = vgui.Create( "DLabel", CharacterCreation ) RespawnTime:SetFont( "BudgetLabel" ) RespawnTime:SizeToContents() RespawnTime:SetPos( 50, 20 ) RespawnTime:SetVisible( true ) RespawnTime:SetText("You have to wait "..timeleft.." sec to spawn") RespawnTime:SizeToContents() end)[/lua]
[code] GarryCompany/gamemode/cl_init.lua:261: ')' expected (to close '(' at line 247) near 'end' ********************************************** ********************************************** ********** COULDN'T LOAD GAMEMODE!! ********** ********************************************** ********************************************** There was a problem opening the gamemode file 'GarryCompany/gamemode/cl_init.lua'[/code] Fomr your code sintwin :(
Try putting the think hook before all of the other derma stuff. [lua]hook.Add("Think", "UpdateTextHookName", function() if timeleft == "" then timeleft = 0 end if !LocalPlayer():Alive() then timeleft = math.Round( spawntime - CurTime()) or 0 else local spawntime = CurTime() +15 end end [/lua]
Hmm [code] Hook 'UpdateTextHookName' Failed: GarryCompany/gamemode/cl_init.lua:257: attempt to concatenate global 'timeleft' (a nil value) [/code]
That is called when you are dead right?
The hook? no. I just need it to go into a derma panel, they don't need to be dead, just make it into the derma panel when it opens.
[QUOTE=HeavyMtl123;22045174]Hmm [code] Hook 'UpdateTextHookName' Failed: GarryCompany/gamemode/cl_init.lua:257: attempt to concatenate global 'timeleft' (a nil value) [/code][/QUOTE] I think it attempted to conatenate timeleft (which was a nil value) on line 257.
Try this. [lua] hook.Add("Think", "UpdateTextHookName", function() if timeleft == "" then timeleft = 0 end if !LocalPlayer():Alive() then timeleft = math.Round( spawntime - CurTime()) or 0 else local spawntime = CurTime() +15 end end [/lua] Anyway this failed, I'll try fix after I have eaten lol.
FYI errors are there to inform you WHAT, WHERE and HOW something is wrong, not just that something is wrong:sigh: [editline]07:59PM[/editline] Mah automerge D:
Did you test it again?
[QUOTE=sintwin;22045412]Did you test it again?[/QUOTE] Yeah, it just keeps destroying the Derma Panel as in removing all the DButtons, DLabels and stuff. [editline]07:40PM[/editline] [lua]function CharacterCreationMenu( ply ) local ply = LocalPlayer() local CharacterCreation = vgui.Create( "DFrame" ) CharacterCreation:SetSize( 600, 600 ) CharacterCreation:Center() CharacterCreation:SetTitle( "[GCompany] Class Selection Menu ||Beta Build 0.1||" ) CharacterCreation:SetVisible( true ) CharacterCreation:SetDraggable( false ) CharacterCreation:ShowCloseButton( false ) CharacterCreation:MakePopup() local background = vgui.Create("DImage", CharacterCreation) background:SetMaterial(Material("DermaMaterials/background_copy.vtf")) background:SetPos(0,20) background:SetSize(CharacterCreation:GetWide(), 580) local NoTeamSelected = vgui.Create( "DLabel", CharacterCreation ) NoTeamSelected:SetText( "Select a team before you can spawn" ) NoTeamSelected:SetFont( "HUDNumber1" ) NoTeamSelected:SizeToContents() NoTeamSelected:SetPos( 30, 450 ) NoTeamSelected:SetVisible( false ) local YourTeam = vgui.Create( "DLabel", CharacterCreation ) YourTeam:SetText( "You have not selected a class" ) YourTeam:SetFont( "Trebuchet24" ) YourTeam:SizeToContents() YourTeam:SetPos( 50, 300 ) local SelectTeam = vgui.Create( "DLabel", CharacterCreation ) SelectTeam:SetText( "Select Your Class" ) SelectTeam:SetFont( "Trebuchet20" ) SelectTeam:SizeToContents() SelectTeam:SetPos( 50, 45 ) local class_assault = vgui.Create( "DButton", CharacterCreation ) class_assault:SetSize( 100, 30 ) class_assault:SetPos( 50, 70 ) class_assault:SetText( "Assault" ) class_assault.DoClick = function() --No function for you end local AssaultDesc = vgui.Create( "DLabel", CharacterCreation ) AssaultDesc:SetText( "Assault utilises: M4A1 and the USP" ) AssaultDesc:SetFont( "Trebuchet18" ) AssaultDesc:SizeToContents() AssaultDesc:SetPos( 180, 79 ) local class_engineer = vgui.Create( "DButton", CharacterCreation ) class_engineer:SetSize( 100, 30 ) class_engineer:SetPos( 50, 120 ) class_engineer:SetText( "Engineer" ) class_engineer.DoClick = function() --No function for you end local EngiDesc = vgui.Create( "DLabel", CharacterCreation ) EngiDesc:SetText( "Engineer utilises: UMP 45 and the Glock 18" ) EngiDesc:SetFont( "Trebuchet18" ) EngiDesc:SizeToContents() EngiDesc:SetPos( 180, 120 ) local class_medic = vgui.Create( "DButton", CharacterCreation ) class_medic:SetSize( 100, 30 ) class_medic:SetPos( 50, 170 ) class_medic:SetText( "Medic" ) class_medic.DoClick = function() --No function for you end local MedicDesc = vgui.Create( "DLabel", CharacterCreation ) MedicDesc:SetText( "Medic utilises: M249 SAW and the FN FiveSeven" ) MedicDesc:SetFont( "Trebuchet18" ) MedicDesc:SizeToContents() MedicDesc:SetPos( 180, 170 ) local class_recon = vgui.Create( "DButton", CharacterCreation ) class_recon:SetSize( 100, 30 ) class_recon:SetPos( 50, 220 ) class_recon:SetText( "Recon" ) class_recon.DoClick = function() --No function for you end local ReconDesc = vgui.Create( "DLabel", CharacterCreation ) ReconDesc:SetText( "Recon utilises: Scout and the USP 45" ) ReconDesc:SetFont( "Trebuchet18" ) ReconDesc:SizeToContents() ReconDesc:SetPos( 180, 220 ) local CloseButton = vgui.Create( "DButton", CharacterCreation ) CloseButton:SetPos( 300, 550 ) CloseButton:SetSize( 150, 25 ) CloseButton:SetText( "Enter Battle" ) CloseButton:SetVisible( true ) CloseButton.DoClick = function() --I'm not giving you the function, get lost end end end usermessage.Hook( "CharacterCreationMenu", CharacterCreationMenu )[/lua] Where would i put the timer in that?
Sorry, you need to Log In to post a reply to this thread.