yes
[editline]08:01PM[/editline]
although you don't need to type "command, arguments"
Now, sintwins, tell us where you would put that file :wink:
YAY. Something actually works. Can you add arguments to a console command? If so how?
BTW thanks for everyones help. I'm slowly learning :D
[QUOTE=Chad Mobile;19533473]Now, sintwins, tell us where you would put that file :wink:[/QUOTE]
lol
[QUOTE=Chad Mobile;19533473]Now, sintwins, tell us where you would put that file :wink:[/QUOTE]
probably in a file called shared.lua in autorun/ along with two blank files
lol I put it in autorun/server :)
[QUOTE=CombineGuru;19533500]probably in a file called shared.lua in autorun/ along with two blank files[/QUOTE]
Haha, I was so waiting for that.
[QUOTE=Chad Mobile;19533559]Haha, I was so waiting for that.[/QUOTE]
I'm learning ok lol. No need to make fun of me. :D Although in retrospect it is pretty funny XD
for arguments you use the arguments input (player, command, arguments). This is a table so you'd use arguments[1] for the first argument and so on.
Is there a way so that say you put in console ("playersay". "sintwins", "hi") and then the player called sintwins says "hi"?
BTW I mean add arguments to the command that you make?
[lua]if PLY.Nick=="sintwins" then
player:ConCommand("say I'm a noob")
else
player:ConCommand("kill")
end
[/lua]
In other words I don't know. Lol.
Lol. But how could you change the palyer's name using an argument to your command?
I don't think you can.
hmmm. How do things like ulx do it then? Like you type "ulx" "adduser" "name" "group"
Script:
[lua]concommand.Add("Blahblah", function(ply, cmd, args)
local Name = args[1] or "(No Name)"
print(Name..", is a noob.")
end)[/lua]
Output:
[code]] Blahblah cow
cow, is a noob.
] Blahblah
(No Name), is a noob.[/code]If you type a name it prints that name with ", is a noob." on it. If you don't enter a name then it'll use "(No Name)" for the name.
Ok, how about adapting that to the other script. Is it possible to make arg[1] be used as the name of the player which says the message and arg[2] to be used as the message? I tried to do this myself and it failed lol.
[lua]
function SinTwins(pl,cmd,args)
for k,v in pairs(player.GetAll()) do
if string.find(v:Name(),args[1]) then
v:ConCommand("say",args[2])
break
end
end
end
concommand.Add("sintwins",SinTwins)
[/lua]
So, you would type:
"sintwins bigdogbikers hi"
Bigdogbikers: hi
Hmm... I don't understand this bit :P
[lua] # if string.find(v:Name(),args[1]) then
# v:ConCommand("say",args[2]) [/lua]
So, my name is Bigdogbikers.
If they type in console: "sintwins bigdogbikers hi"
It runs on each player and let's say, my name is [CLANTAG] Bigdogbikers.
If it finds bigdogbikers in my name, which it did, then it will run the command on me.
So it runs on me, "say hi".
So my player then says "hi".
Ok so string.find looks for a string which is the same as your argument one and searches names? If someone has a name which has the argument in it makes them run the command? What is the syntax of string.find? Thanks
It tries to find the argument in the strings, it's just partial.
The syntax is string.find(string,find)
So like, I want to find "Bigdog" in a player's name.
string.find(pl:Name(),"Bigdog")
If it finds it, it returns true, else returns false.
You could just change a players name then make the player type say hi in the console xD Thats the evil way though
Ok thanks. So the first argument is where to look and the second is what to look for?
No.
The first argument is who to look for and the second is what to say.
Sorry, you need to Log In to post a reply to this thread.