I'm tired of searching a way to make this. I need help now >:O
I was trying to make the gamemode auto-changes the map after some minutes.
I tried almost everything, but I failed... The other thing is a Music Player.
This one wasn't that hard, yet, people can't hear it, just the server owner:
[lua]TableRandomSounds = {
Sound("/music/castle_dark.mp3"),
Sound("/music/rose_a.mp3"),
Sound("/music/haunte.mp3"),
Sound("/music/Silent_Haunting.mp3"),
}
local function StartSound()
local snd = table.Random(TableRandomSounds)
surface.PlaySound( snd )
timer.Simple( SoundDuration( snd ), StartSound )
end
function GM:Initialize()
StartSound()
end [/lua]
I'll wait for an answer >:O
[lua]
local MAP_CHANGEMINUTES = 5
local level = "gm_construct"
timer.Create("mapChange",MAP_CHANGEMINUTES * 60,1,function() game.ConsoleCommand("changelevel "..level.."\n") end)[/lua]
Kinda like that.
For your other problem, it's because you're running it on GM:Initialize. If you're not on the server when the gamemode begins, then it won't work. Try using PlayerInitialSpawn instead (it's serverside, mind you).
I'll check this out, but now I need a menu that shows you the time, is it possible to put it on a Derma menu?
Also, how to make a list of maps?
Comeon! No one got an Idea?!
Also, what you said about the music player doesn't work...
Use the InitPostEntity hook rather than Initialize
[QUOTE=|FlapJack|;19014362]Use the InitPostEntity hook rather than Initialize[/QUOTE]
Ok I'll check that out thanks, but what about the menu?
Why dont you try looking up stuff your self on the wiki instead of asking about ever little thing
[QUOTE=*Fish*;19017926]Why dont you try looking up stuff your self on the wiki instead of asking about ever little thing[/QUOTE]
If you are so genius to find even Wiki stuff that isn't written on the Wiki then why don't post them here? :argh:
Not written on the wiki??
[url]http://wiki.garrysmod.com/?title=DFrame.Paint[/url]
I guess you are still trying to print the time left in a menu
I asked [B]how to put it[/B] in a derma menu, not how to make a derma menu.
Well as you cant print a timer directly use [url]http://wiki.garrysmod.com/?title=G.CurTime[/url]
Uhm... tell me if this is right...
[lua]function WhenGameStarts()
GameTimer()
end
function GameTimer()
YourFrame = = vgui.Create( "DFrame" )
YourFrame:SetPos( 200, 200 )
YourFrame:SetSize( 300, 300 )
YourFrame:SetTitle( "Current time: " .. CurTime() .. "\n" )
YourFrame:SetVisible( true )
YourFrame:MakePopup()
function YourFrame:Paint()
surface.SetDrawColor( 0, 0, 0, 255 )
surface.DrawRect( 0, 0, YourFrame:GetWide(), YourFrame:GetTall() )
end
gui.EnableScreenClicker( false )
gui.SetMousePos( ScrW() / 2, ScrH() / 2 )
end
timer.Simple( 3, function()
WhenGameStarts()
GameTimer()
end )[/lua]
Shall I put it in [B]cl_init [/B]? Because I just added it through [B]include[/B]...
:question:
[editline]ahah :P[/editline]
Oh well, I found another way to print the time.
Well, if you found a way to print it on Derma tell me!
I'll ask you guys another thing so I don't have to make a new thread:
I tried to make NPCs count as kill in my Gamemode with this:
[lua]function GM:OnNPCKilled(ent, attacker, inflictor)
if attacker:IsPlayer() and attacker:Team() == TEAM_BLUE then
attacker:AddFrags(1)
self:CheckPlayerScore(attacker)
end
end[/lua]
But it doesn't work :crying:
DLabel or override the DFrame's paint function.
[i]or[/i] if you wanted to do it the way you laid out in the code, set the frame title in a think function.
[lua]function WhenGameStarts()
GameTimer()
end
function GameTimer()
YourFrame = = vgui.Create("DLabel", myParent)
YourFrame:SetText("Time passed: " .. CurTime() .. "\n")
YourFrame:SizeToContents()
gui.EnableScreenClicker( false )
gui.SetMousePos( ScrW() / 2, ScrH() / 2 )
end
timer.Simple( 3, function()
WhenGameStarts()
GameTimer()
end )[/lua] Not working :crying:
Anyway, what about the NPC's kill? :mad:
The NPC kill code looks like it should work. Make sure the player is on TEAM_BLUE.
Also, use timer.Create instead of timer.Simple.
[QUOTE=|FlapJack|;19039227]The NPC kill code looks like it should work. Make sure the player is on TEAM_BLUE.
Also, use timer.Create instead of timer.Simple.[/QUOTE]
The play IS on TEAM_BLUE... yet, it doesn't work...
Come on guys, I just need this :comeback:
Bump.
Come on I need this thing :crying:
[code]
ERROR: GAMEMODE:'OnNPCKilled' Failed: WarSurvivalRevenge/gamemode/init.lua:261: attempt to call method 'CheckPlayerScore' (a nil value)
:1: attempt to call method 'AddNotify' (a nil value)
[/code]
Sorry, you need to Log In to post a reply to this thread.