ULX

Author Topic: Admin sounds, tools and other code chat.  (Read 55161 times)

0 Members and 5 Guests are viewing this topic.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #90 on: April 30, 2008, 06:15:21 PM »
Now I'm having a problem with concommand.Add

I typed this ingame.
Code: [Select]
AddRule "Test"

and got this in server console.
Code: [Select]
autorun/Ajoin.lua:48: attempt to concatenate local 'args' (a table value)
This is Line:48
Code: [Select]
if string.find( Rules, "<li>" ..args, 1, true ) then
==EDIT==
Got it :D
Code: [Select]
function AddRule( ply, command, RuleA )
Rules = file.Read( "Umotd/rules.txt" )
if ply:IsValid() then
if ply:IsAdmin() then
Rule = table.concat(RuleA)
if string.find( Rules, "<li>" ..Rule, 1, true ) then
Rules = Rules
else
Rules = Rules.. "<li>" ..Rule
file.Write( "Umotd/rules.txt", Rules )
end
else

end
else
print("Can't execute from console \n")
end
end
concommand.Add( "AddRule", AddRule )
« Last Edit: April 30, 2008, 07:55:13 PM by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #91 on: May 01, 2008, 05:41:00 PM »
Code: [Select]
Unknown command: AddRule
Code: [Select]
Unknown command: RemoveRuleErrors above.

Code: [Select]
Rules = file.Read( "Umotd/rulest.txt" )
RulesT = util.KeyValuesToTable( Rules )
for k,v in pairs( RulesT.rules ) do
RulesT.rules[tonumber(k)]=v
end
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules, " ") )
function AddRule( ply, command, RuleA )
if ply:IsValid() then
if ply:IsAdmin() then
Rule = table.concat(RuleA)
if string.find( table.concat(RulesT.rules), "<li>" ..Rule, 1, true ) then
Msg("Rule already exists \n")
else
table.insert( RulesT.rules, "<li>" ..Rule )
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules, " ") )
file.Write( "Umotd/rulest.txt", util.TableToKeyValues(RulesT.rules))
end
else

end
else
Msg("Can't execute from console \n")
end
end
concommand.Add( "AddRule", AddRule )
function RemoveRule( ply, command, RuleB )
if ply:IsValid() then
if ply:IsAdmin() then
RuleN = table.concat(RuleB)
if tonumber(RuleN) < table.Count(RulesT.rules)+1 && tonumber(RuleN) > 1 then
table.remove( RulesT.rules, RuleN )
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules, " ") )
file.Write( "Umotd/rulest.txt", util.TableToKeyValues(RulesT.rules))
else
Msg("Couldn't find the rule mentioned \n")
end
else

end
else
Msg("Can't run from console \n")
end
end
concommand.Add( "RemoveRule", RemoveRule )

rulest.txt below

Code: [Select]
"Out"
{
"1" "<ol>"
"2" "<li>Test2"
"3" "<li>Test5"
"4" "<li>Test6"
}

BTW I'm trying to make it handle the table like Uteam does with the Uteam.txt file in the data folder, so my rulest.txt should look like this below, but the rulest.txt was written by the script.


Code: [Select]
"Out"
{
     "rules"
     {
     "1" "<ol>"
     "2" "<li>Test2"
     "3" "<li>Test5"
     "4" "<li>Test6"
     }
}
« Last Edit: May 02, 2008, 01:50:37 PM by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #92 on: May 02, 2008, 02:16:10 PM »
Not Setting RulesT for somereason.

Code: [Select]
if SERVER then
timer.Create( RulesTimer, 1, 0, SetRules )
function SetRules()
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
end
function AddRule( ply, command, RuleA )
if ply:IsValid() then
if ply:IsAdmin() then
Rule = table.concat(RuleA)
if  table.HasValue(RulesT, "<li>" ..Rule) then
Msg("Rule already exists \n")
else
table.insert( RulesT, "<li>" ..Rule )
file.Write("Umotd/rulest.txt", ULib.makeKeyValues(RulesT))
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
file.Write( "Umotd/rules2.txt", table.concat(RulesT, " ") )
end
else

end
else
Msg("Can't execute from console \n")
end
end
concommand.Add( "AddRule", AddRule )
Msg("p4")
function RemoveRule( ply, command, RuleB )
if ply:IsValid() then
if ply:IsAdmin() then
RuleN = table.concat(RuleB)
if tonumber(RuleN) < table.Count(RulesT)+1 && tonumber(RuleN) > 1 then
table.remove( RulesT, (tonumber(RuleN)+1) )
file.Write("Umotd/rulest.txt", ULib.makeKeyValues(RulesT))
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
file.Write( "Umotd/rules2.txt", table.concat(RulesT, " ") )
else
Msg("Couldn't find the rule # mentioned \n")
end
else

end
else
Msg("Can't run from console \n")
end
end
concommand.Add( "RemoveRule", RemoveRule )
Msg("p5")
else
Msg("Not Server, Ending Script")
timer.Destroy( RulesTimer )
end

My rulest.txt
Code: [Select]
"1" "<ol>"
"2" "<li>Test1"
"3" "<li>Test2"
"4" "<li>Test3"
"5" "<li>Test4"
« Last Edit: May 03, 2008, 08:54:05 AM by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #93 on: May 04, 2008, 08:51:18 PM »
No one see anything wrong I guess?
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #94 on: May 10, 2008, 08:55:01 PM »
Ok, after looking through the console I found the problem.

Code: [Select]
autorun/Rules.lua:2: attempt to index global 'ULib' (a nil value)
======== Installing Table (De)Serialiser Module | ver: 1.4 ========
///////////////////////////////
//      Ulysses Library      //
///////////////////////////////
// Loading...                //
//  shared/defines.lua       //
//  server/hook.lua          //
//  server/gamemode_hooks.lua//
//  shared/misc.lua          //
//  shared/util.lua          //
//  shared/table.lua         //
//  shared/player.lua        //
//  server/player.lua        //
//  shared/messages.lua      //
//  shared/concommand.lua    //
//  server/concommand.lua    //
//  server/util.lua          //
//  shared/sh_ucl.lua        //
//  server/ucl.lua           //
//  server/phys.lua          //
//  server/player_ext.lua    //
//  server/entity_ext.lua    //
// Load Complete!            //
///////////////////////////////
[ULIB] Loading SHARED module: ulx_init.lua
///////////////////////////////
//       ULX Admin Mod       //
///////////////////////////////
// Loading...                //
//  sh_defines.lua           //
//  lib.lua                  //
//  base.lua                 //
//  log.lua                  //
//  MODULE: chat.lua         //
//  MODULE: fun.lua          //
//  MODULE: menus.lua        //
//  MODULE: rcon.lua         //
//  MODULE: slots.lua        //
//  MODULE: teleport.lua     //
//  MODULE: toolmode.lua     //
//  MODULE: user.lua         //
//  MODULE: util.lua         //
//  MODULE: vote.lua         //
//  MODULE: votemap.lua      //
//  MODULE: Umotd_helper.lua //
//  MODULE: userhelp.lua     //
//  end.lua                  //
// Load Complete!            //
///////////////////////////////
[ULIB] Loading SHARED module: umotd_init.lua
///////////////////////////////
//    Ulysses MOTD Revived   //
//        Version 2.A6       //
///////////////////////////////
// Umotd Loaded. Thanks!     //
///////////////////////////////

Code: [Select]
if SERVER then
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
function AddRule( ply, command, RuleA )
if ply:IsValid() then
if ply:IsAdmin() then
Rule = table.concat(RuleA)
if  table.HasValue(RulesT.rules, "<li>" ..Rule) then
Msg("Rule already exists \n")
else
table.insert( RulesT.rules, "<li>" ..Rule )
file.Write("Umotd/rulest.txt", ULib.makeKeyValues(RulesT))
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules, " ") )
end
else

end
else
Msg("Can't execute from console \n")
end
end
concommand.Add( "AddRule", AddRule )
function RemoveRule( ply, command, RuleB )
if ply:IsValid() then
if ply:IsAdmin() then
RuleN = table.concat(RuleB)
if tonumber(RuleN) < table.Count(RulesT.rules)+1 && tonumber(RuleN) > 1 then
table.remove( RulesT.rules, (tonumber(RuleN)+1) )
file.Write("Umotd/rulest.txt", ULib.makeKeyValues(RulesT))
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules, " ") )
else
Msg("Couldn't find the rule # mentioned \n")
end
else

end
else
Msg("Can't run from console \n")
end
end
concommand.Add( "RemoveRule", RemoveRule )
else
Msg("Not Server, Ending Script")
end

Is there a way to make it so that my script doesn't run until after ULib has been loaded?
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Admin sounds, tools and other code chat.
« Reply #95 on: May 10, 2008, 09:02:55 PM »
Quick dirty way .. place your script in lua/ULib/modules (or better as an addon, virtually ... addons/<yourscriptfoldername>/lua/ULib/modules/)

Best practice way .. place your script in lua/<yourscriptfoldername>/blah.lua (again, addons are recommended)
Then place an init in ULib/modules/ that loads.

Take a look at how Umotd loads from the addons.. it places an init file in an addons virtual ULib's modules folder.
« Last Edit: May 10, 2008, 09:04:59 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #96 on: May 11, 2008, 12:22:22 AM »
I got it all worked out. Here's the script. Btw I used it in addon format :D

Code: [Select]
if SERVER then
Msg("////////////////////////\n")
Msg("//      Ajoin         // \n")
Msg("////////////////////////\n")
Msg("//  Rules.lua Loaded  // \n")
Msg("//  Setting Rules     // \n")
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
for k,v in pairs( RulesT.rules ) do
RulesT.rules[tonumber(k)]=v
end
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules," "))
Msg("//  Rules Set       // \n")
Msg("////////////////////////\n")
function AddRule( ply, command, RuleA )
if ply:IsValid() then
if ply:IsAdmin() then
Rule = table.concat(RuleA)
if  table.HasValue(RulesT.rules,  "<li>" ..Rule) then
ULib.tsay(ply,"Rule Already Exist",false)
else
table.insert( RulesT.rules,"<li>" ..Rule )
file.Write("Umotd/rulest.txt", ULib.makeKeyValues(RulesT))
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules," "))

end
else

end
else
Msg("Can't execute from console \n")
end
end
concommand.Add( "AddRule", AddRule )
function RemoveRule( ply, command, RuleB )
if ply:IsValid() then
if ply:IsAdmin() then
RuleN = (tonumber(table.concat(RuleB)))
if RuleN <= table.Count(RulesT.rules) && RuleN > 1 then
table.remove( RulesT.rules, (RuleN) )
file.Write("Umotd/rulest.txt", ULib.makeKeyValues(RulesT))
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules," "))
else
if RuleN == 1 then
table.remove( RulesT.rules, 2 )
file.Write("Umotd/rulest.txt", ULib.makeKeyValues(RulesT))
RulesT = (ULib.parseKeyValues( file.Read("Umotd/rulest.txt")))
file.Write( "Umotd/rules2.txt", table.concat(RulesT.rules," "))
else
ULib.tsay(ply,"Couldn't find Rule " ..RuleN.. "\nplease check !rules and try again.",false)
end
end
else

end
else
Msg("Can't run from console \n")
end
end
concommand.Add( "RemoveRule", RemoveRule )
else
Msg("Not Server, Ending Script")
end

==EDIT==
With the help of Megiddo
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #97 on: May 14, 2008, 05:21:17 PM »
Now, I'm trying to make an afk module. I am having some difficulties though.It's not working at all all. I'm not even getting Msg(view_old).


Code: [Select]
function ajoin_afk()
for _,ply in pairs(player.GetAll()) do
function afk()
old_time = 1
local afk_status = nil
if ply:IsValid() then
view_old = ply:EyeAngles( )
old_time = tonumber(CurTime())
Msg(view_old)
end
end
function afk_check()
if tonumber(CurTime()) > (CurTime() + 10) then
if view_old == ply:EyeAngles() then
local afk_status = "AFK"
Msg("AFK SET")
end
end
if afk_status == "AFK" then
Msg("AFK")
game.ConsoleCommand("say Player " ..ply:Nick().. " Is AFK \n")
end
end
end
end
hook.Add("Think", "Afk_Check", afk_check)
« Last Edit: May 14, 2008, 06:22:47 PM by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #98 on: May 18, 2008, 06:22:05 AM »
New Code, still nothing. The only change here, is that I change it to ply.._afk_status because before I only had one variable for all the  players in the server. The code still doesn't work sadly enough. It's not even printing the messages past the start of the function.

Code: [Select]
Msg("////////////////////\n")
Msg("//  Module:AFK    //\n")
Msg("////////////////////\n")
function ajoin_afk()
for _,ply in pairs(player.GetAll()) do
function afk()
old_time = 1
if ply:IsValid() then
view_old = ply:EyeAngles( )
old_time = tonumber(CurTime())
Msg(view_old)
end
end
function afk_check()
if tonumber(CurTime()) > (CurTime() + 10) then
if view_old == ply:EyeAngles() then
ply:Nick()_afk_status = "AFK"
Msg("AFK SET")
else
ply:Nick()_afk_status = "ACTIVE"
Msg("Active Set")
end
end
if ply:Nick().."afk_status" == "AFK" then
Msg("AFK")
game.ConsoleCommand("say Player " ..ply:Nick().. " Is AFK \n")
end
end
end
end
hook.Add("Think", "Afk_Check", afk_check)
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given