Problem with visual information script i am making
7 replies, posted
hello, i return to present to you enougher script that failed in the making. I am making a script that when you do a cmd, then you put your text, say mahcmd "lololol" , it would print to the screenz of all "ADMIN: lololol" . so far, that fails cause when i do mahcmd "lololol" it prints to the middle of my screen "ADMIN: nil "
here is the script so far:
[CODE]function advertising( pl, args )
if pl:IsPlayer() && pl:IsAdmin() then
PrintMessage( HUD_PRINTCENTER, "ADMIN: " ..tostring(args[1]) )
end
end
concommand.Add( "advertisment", advertising)[/CODE]
any ideas?
[code]function advertising( pl, cmd, args )
if pl:IsPlayer() and pl:IsAdmin() then
PrintMessage( HUD_PRINTCENTER, "ADMIN: " ..tostring(args[1]))
end
end
concommand.Add( "advertisment", advertising)[/code]
concommand.Add callbacks take 3 arguments, ply, cmd, arg.
can you explaon the cmd arg to me, i never really understood it, but if you dont want to, can you please point me in the right dierction?
First of all you have to put all the parameters of the function in, you can't skip any. So it would be
local function adversising(pl, cmd, args).
However if that were the only problem then you'd get a different error, from trying to index a string. Are you sure you're giving us all the errors you got.
Are you testing this script by doing advertisment lolol in the console or is it through a chat command. If it's through a chat command then I'd have to know more about the mechanism before I could help you.
[editline]01:39PM[/editline]
[QUOTE=Ningaglio;20209119]can you explaon the cmd arg to me, i never really understood it, but if you dont want to, can you please point me in the right dierction?[/QUOTE]
cmd is just the name of the console command used, in your case it would always be advertisment, however it is required to be included because parameters need to be in order.
its a concommand and it works now, but can you explain to me what the cmd argument does?
[editline]02:41PM[/editline]
edit, nvm, the guy aboce me explained
He told you. It's the name of the command.
so i could do
if cmd = "advertisment" then
blah blah
end
so i could protect my scripts or something?
[QUOTE=Ningaglio;20209176]so i could do
if cmd = "advertisment" then
blah blah
end
so i could protect my scripts or something?[/QUOTE]
There wouldn't be much of a point as the function is likely only called from that console command. You could supply the same function to multiple commands, in which case the cmd argument could be different, however with standard usage this parameter is never used.
If you feel like it you could try this
[lua]for i=65, 90 do
concommand.Add(sting.char(i), print)
end[/lua]
Then enter A-Z in the console.
It will print the player, then the letter you entered, then the table of parameters.
Sorry, you need to Log In to post a reply to this thread.