I'm really new to coding Garry's Mod, so I'm working on simple things at the moment. As a test, I thought that I'd try & create a name-changing script. I looked up some hooks to see which one I would use, then I found some code on the Wiki. I based my code off of the code on the wiki as a test, and this is what I got:
[CODE]local ShouldPrint = 0
hook.Add("Think","NameChange",PrintWordsOne)
function PrintWordsOne ()
if (CurTime() >= ShouldPrint) then
LocalPlayer():PrintMessage(HUD_PRINTTALK,"ONE!")
ShouldPrint = CurTime() + 4
end
if (CurTime() >= ShouldPrint) then
LocalPlayer():PrintMessage(HUD_PRINTTALK,"TWO!")
ShouldPrint = CurTime() + 8
end
end[/CODE]
Now, I know this code is incorrect, but what I am trying to do is make it print "ONE!" to chat, then 4 seconds later, print "TWO!" to the chat.
P.S. I'm not looking for anyone to code anything for me! I know that is not what this section is for. I'm just hoping someone in this section can help me see what I'm doing wrong. Thanks.
Here's what I'd do for a simple count-print:
[LUA]
local num_strs = { "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE" }
local count = 0
local delay = 4
local num_counts = 9
timer.Create( "CountUp", delay, num_counts, function()
count = count + 1
print( num_strs[count] )
end )
[/LUA]
[QUOTE=CallMePyro;45249613]Here's what I'd do for a simple count-print:
[LUA]
local num_strs = { "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE" }
local count = 0
local delay = 4
local num_counts = 9
timer.Create( "CountUp", delay, num_counts, function()
count = count + 1
print( num_strs[count] )
end )
[/LUA][/QUOTE]
Alright man, thanks for all of the help! Much appreciated!
Sorry, you need to Log In to post a reply to this thread.