So I know im an noob at lua. Im trying to make so the command rp_title is admin only and it changes the title of who the admin is looking at.
Old code
[CODE]-- Set Title
concommand.Add( "rp_title", function( ply, cmd, args )
local title = table.concat( args, " " )
CAKE.SetCharField( ply, "title", title )
ply:SetNWString("title", title)
end)[/CODE]
New Code
[CODE]-- Set Title
concommand.Add( "rp_title", function( ply, cmd, args )
local target = CAKE.FindPlayer( args[1] )
local title = table.concat( args[2], " " )
if( target and target:IsValid() and target:IsTiraPlayer() ) then
CAKE.SetCharField( target, "title", title )
ply:SetNWString("title", title)
CAKE.SendChat( ply, ..target:Nick() .. " title is now " .. title .. ".")
else
CAKE.SendChat( ply , "Cannot find target")
end
end)[/CODE]
[code]
concommand.Add( "rp_title", function( ply, cmd, args )
if !ply:IsAdmin() then return end
...
[/code]
Also, you don't need "if target and target:IsValid()" if you just use "if IsValid(target)"
Sorry, you need to Log In to post a reply to this thread.