Cant get it to work

i am making a simple advert system and i cant get it to work, i put it in autorun and it doesnt run. i made a command and it doesnt recognise the command. this is my code so far:

– this is so that we can display what we want–
function advert1()
lua_run PrintMessage( HUD_PRINTTALK, “Welcome To The GmodSector Public Server” )
end

function advert2()
lua_run PrintMessage( HUD_PRINTTALK, “Be Pleasant To The Admins” )
end

– this is to put a recuring delay on it–

timer.Create( “advert2_delay”, 60, 0, delay2() )
advert2()
end

timer.Create( “advert1_delay”, 45, 0, delay1() )
advert1()
end

– lets make a command to start the delays –

concommand.Add( “start_delay1”, delay1 )
concommand.Add( “start_delay2”, delay2 )

can anyone help?

EDIT: i did put the spaces in thefinctions and stuff but they dont show up on the forum


(User was banned for this post ("Undescriptive thread title" - mahalis))

You have a very odd sense of how Lua works, my friend.

Here is MY version of your advert system.
(Using [lua] tags will maintain proper formatting in your code. )

[lua]
timer.Create( “advert_luarun”, 60, 0, function( pl )

pl:PrintMessage( HUD_PRINTTALK, "You should not call 'lua_run' as a function, it is a console command." )

end, pl )
[/lua]
Output:
Prints the message every minute.

Your code looks very nonsensical and strange. For a start, you don’t use timers like that. You’d use them like this:

[lua]
function WhatMyTimerDoes()
PrintMessage(HUD_PRINTTALK, “Rabbits are cool”)
end

timer.Create(“RabbitTimer”, 60, 0, WhatMyTimerDoes)
[/lua]

So when you put the name of the timer don’t put the brackets after it, you just want to give the function to the timer, not run it.

And if you want to put a console command in a script you need to put RunConsoleCommand (if you want the server to run it) or ply:ConCommand (if you want to make a player run the command). But lua_run is blocked on RunConsoleCommand anyway. Just run the lua directly.

Also put your code in lua tags. eg [noparse][lua] print(“haha I’m using Lua on an internet forum”) [/lua][/noparse] and it’ll preserve all the indentation.

Hey OP, you should take a look at GAS, It may be what you are after.

thx, but i kinda wanted to do it myself. oh well. thx anyways :slight_smile: