Ok i dont see this make any logic.
[CODE]function WEPMenu ( ply, text, public )
if ( string.sub( text, 1, 8) == "!blue" ) then
ply:SetTeam( 1 )
RunConsoleCommand ("kill")
end
return text
end
hook.Add( "PlayerSay", "WEPMenu", WEPMenu)
function WEPMenu1 ( ply, text, public )
if ( string.sub( text, 1, 6) == "!red" ) then
ply:SetTeam( 2 )
RunConsoleCommand ("kill")
end
return text
end
hook.Add( "PlayerSay", "WEPMenu1", WEPMenu1)[/CODE]
The !red doesnt want to work while !blue does wtf?
Any help?
I am surprised it works given you execute kill con command on the server. Use ply:Kill()
[editline]8th October 2013[/editline]
Also, !red is not 6 characters long, it is 4. And !blue is 5, not 8.
RunConsoleCommand is can be used serverside like i do.
Even if it can, it probably will kill everyone on the server, so do as I said or provide proof of contrary.
Idk about that :)
Why ask for help if you're going to dispute the answer
pretty sure they can also bypass the kill thing, using alias.
Probably got this wrong, But its worth a shot.
[CODE]
local ply = LocalPlayer()
function WEPMenu ( ply, text, public )
if ( string.sub( text, 1, 5) == "!blue" ) then
ply:SetTeam( 1 )
ply:RunConsoleCommand ("kill")
end
return text
end
hook.Add( "PlayerSay", "WEPMenu", WEPMenu)
function WEPMenu1 ( ply, text, public )
if ( string.sub( text, 1, 4) == "!red" ) then
ply:SetTeam( 2 )
ply:RunConsoleCommand ("kill")
end
return text
end
hook.Add( "PlayerSay", "WEPMenu1", WEPMenu1)[/CODE]
ply:ConCommand( "single string command" ) is the client-side equivalent of RunConsoleCommand().
[QUOTE=Internet1001;42455078]ply:ConCommand( "single string command" ) is the client-side equivalent of RunConsoleCommand().[/QUOTE]
ply:ConCommand( "my cmd" ) is the serverside equivalent of clientside function RunConsoleCommand("my","cmd").
Every time I try to help someone...
IRZilla had a good chat module
[lua]
module( "chatcommand", package.seeall )
local Commands = {}
function Add( name, func )
Commands[ name ] = func
end
function Call( name, pl, args )
local func = Commands[ name ]
if (func) then
local b, res = pcall( func, pl, name, args )
if (!b) then
Commands[ name ] = nil
ErrorNoHalt( res )
return false
end
return true
end
end
function FindPlayer( name )
for _, ply in pairs( player.GetAll() ) do
if (string.find( ply:Nick(), name ) || (name == ply:Nick())) then return ply end
end
end
local function PlayerSay( ply, text, toall)
local first = string.sub( text, 1, 1 )
if (first == "/") then
local str = string.sub( text, 2 )
local args = string.Explode( " ", str )
local com = args[1]
table.remove( args, 1 )
local b = Call( com, ply, args )
if (b) then return "" end
end
end
hook.Add( "PlayerSay", "CHATCOMMANDS", PlayerSay )
[/lua]
[QUOTE=Robotboy655;42455208]ply:ConCommand( "my cmd" ) is the serverside equivalent of clientside function RunConsoleCommand("my","cmd").[/QUOTE]
Thanks, I learn something new everyday :),
Not related to the quote.
Instead of him copying and pasting its better to play around with it, That way you learn something for the future.
Depends. I like to read other people code. I learn how lua works doing that and see how functions can be used
[QUOTE=Snorlaxs;42455666]Depends. I like to read other people code. I learn how lua works doing that and see how functions can be used[/QUOTE]
Thats how i started, It really works well until it gets to the more complicated code
Lol. I been coding for 2 months. Doing very less abd small things. Made a scorestreak system. Just need client side menu and the streaks
[editline]8th October 2013[/editline]
[QUOTE=AIX-Who;42455048]Probably got this wrong, But its worth a shot.
[CODE]
local ply = LocalPlayer()
function WEPMenu ( ply, text, public )
if ( string.sub( text, 1, 5) == "!blue" ) then
ply:SetTeam( 1 )
ply:RunConsoleCommand ("kill")
end
return text
end
hook.Add( "PlayerSay", "WEPMenu", WEPMenu)
function WEPMenu1 ( ply, text, public )
if ( string.sub( text, 1, 4) == "!red" ) then
ply:SetTeam( 2 )
ply:RunConsoleCommand ("kill")
end
return text
end
hook.Add( "PlayerSay", "WEPMenu1", WEPMenu1)[/CODE][/QUOTE] function ( ply ). It works like a local. As i know it only knows ply and pl
Sorry, you need to Log In to post a reply to this thread.