Ulysses

General => Developers Corner => Topic started by: Livaco on March 24, 2015, 02:35:03 PM

Title: AWarn Doesent Work?
Post by: Livaco on March 24, 2015, 02:35:03 PM
Fixed NO Longer Needed
Title: Re: AWarn Doesent Work?
Post by: Caustic Soda-Senpai on March 24, 2015, 05:15:31 PM
I'm going to ask the obvious question: Did you restart your server?
Title: Re: AWarn Doesent Work?
Post by: Livaco on March 24, 2015, 05:22:16 PM
Yes I typed in the console restart
Title: Re: AWarn Doesent Work?
Post by: MrPresident on March 24, 2015, 05:46:14 PM
It doesn't work in Single Player.
The error in your console indicates that you tested this in SinglePlayer.

You need to run this on a server for it to work.
Title: Re: AWarn Doesent Work?
Post by: Livaco on March 25, 2015, 12:55:36 AM
I've got the minge bots addon and I'm spawning them in on a local
Title: Re: AWarn Doesent Work?
Post by: Caustic Soda-Senpai on March 25, 2015, 01:03:43 AM
It doesn't work in Single Player.

You need to run this on a server for it to work.

Spawning bots in singleplayer doesn't cut it.
Title: Re: AWarn Doesent Work?
Post by: Livaco on March 25, 2015, 01:12:54 AM
no its a local server im trying it on -_-
Title: Re: AWarn Doesent Work?
Post by: Livaco on March 25, 2015, 01:14:19 AM
If U Need I Can Give U The Code
Title: Re: AWarn Doesent Work?
Post by: MrPresident on March 25, 2015, 11:14:47 AM
I'm more interested in any error messages you get. Paste here anything from your console after you try to issue a warning.
Title: Re: AWarn Doesent Work?
Post by: Livaco on March 26, 2015, 05:38:45 AM
Heres The Consle Code

Code: [Select]
Initial walk and run speeds fetched.
Walk Speed: 250
Run Speed: 500
[Aid15 :)|2|STEAM_0:0:56797092] Lua Error:

[ERROR] addons/ulx/lua/ulx/modules/sh/chat.lua:306: unexpected symbol near '2.'
  1. unknown - addons/ulx/lua/ulx/modules/sh/chat.lua:0

Spawning textscreens...
DLL_MessageEnd:  Refusing to send user message TextMsg of 256 bytes to client, user message size limit is 255 bytes
Requesting texture value from var "$basetexture" which is not a texture value (material: trails/tube)
Requesting texture value from var "$basetexture" which is not a texture value (material: trails/tube)
] bot
Player Bot01 has joined the game
DLL_MessageEnd:  Refusing to send user message TextMsg of 256 bytes to client, user message size limit is 255 bytes
Client "Bot01" spawned in server (BOT)<BOT>.
Requesting texture value from var "$basetexture" which is not a texture value (material: pp/copy)
DLL_MessageEnd:  Refusing to send user message TextMsg of 256 bytes to client, user message size limit is 255 bytes
Title: Re: AWarn Doesent Work?
Post by: Caustic Soda-Senpai on March 26, 2015, 01:16:30 PM
Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/sh/chat.lua:306: unexpected symbol near '2.'
  1. unknown - addons/ulx/lua/ulx/modules/sh/chat.lua:0

That is an error that needs to be fixed...
Title: Re: AWarn Doesent Work?
Post by: MrPresident on March 26, 2015, 03:04:53 PM
Nothing in that is related to AWarn.
Title: Re: AWarn Doesent Work?
Post by: Caustic Soda-Senpai on March 26, 2015, 05:06:44 PM
I'm aware that it's not related to AWarn, I'm stating its an error that needs to be fixed. I should have specified that it was an error not related to AWarn.
Title: Re: AWarn Doesent Work?
Post by: MrPresident on March 26, 2015, 10:12:36 PM
and I was responding to Livaco's post, not yours. He created this thread to try and get me to help him 'fix' AWarn2 on his server, but has yet to produce any kind of information to allow me to do so.
Title: Re: AWarn Doesent Work?
Post by: Livaco on March 27, 2015, 01:35:51 AM
Heres The Code Of awarn_sqlite.lua, If U Need More Just Tell Me

Code: [Select]
local PlayerMeta = FindMetaTable("Player")

function awarn_tbl_exist()
if sql.TableExists("awarn_warnings") then
ServerLog( "AWarn: Warning Table Exists\n" )
else
local query = "CREATE TABLE awarn_warnings ( pid INTEGER PRIMARY KEY AUTOINCREMENT, unique_id varchar(255), admin varchar(255), reason text, date varchar(255) )"
result = sql.Query(query)
ServerLog( "AWarn: Creating Warning Table...\n" )
if sql.TableExists("awarn_warnings") then
ServerLog( "AWarn: Warning Table created sucessfully.\n" )
else
ServerLog( "AWarn: Trouble creating the Warning Table\n" )
ServerLog( "AWarn: " .. sql.LastError( result ).."\n" )
end
end

if sql.TableExists("awarn_playerdata") then
ServerLog( "AWarn: Player Data Table Exists\n" )
else
local query = "CREATE TABLE awarn_playerdata ( unique_id varchar(255), warnings INTEGER, lastwarn varchar(255) )"
result = sql.Query(query)
ServerLog( "AWarn: Creating Player Data Table...\n" )
if sql.TableExists("awarn_playerdata") then
ServerLog( "AWarn: Player Data Table created sucessfully.\n" )
else
ServerLog( "AWarn: Trouble creating the Player Data Table\n" )
ServerLog( "AWarn: " .. sql.LastError( result ).. "\n" )
end
end

if sql.TableExists("awarn_serverdata") then
ServerLog( "AWarn: Server Data Table Exists\n" )
else
local query = "CREATE TABLE awarn_serverdata ( key TEXT, val INTEGER )"
result = sql.Query(query)
ServerLog( "AWarn: Creating Server Data Table...\n" )
if sql.TableExists("awarn_serverdata") then
ServerLog( "AWarn: Server Data Table created sucessfully.\n" )
else
ServerLog( "AWarn: Trouble creating the Server Data Table\n" )
ServerLog( "AWarn: " .. sql.LastError( result ).. "\n" )
end
end
end


function awarn_reloadtables()
if sql.TableExists("awarn_warnings") then
local query = "DROP TABLE awarn_warnings"
result = sql.Query(query)
end
if sql.TableExists("awarn_playerdata") then
local query = "DROP TABLE awarn_playerdata"
result = sql.Query(query)
end
awarn_tbl_exist()
end

function awarn_saveservervalue( key, val )
--print( key .. " " .. val )
local query = "SELECT * FROM awarn_serverdata WHERE key='" .. key .. "'"
result = sql.QueryRow(query)

--PrintTable(result)

if not result then
local query = "INSERT INTO awarn_serverdata VALUES ( '" ..key.. "', '" .. val .. "' )"
result = sql.Query(query)
SetGlobalInt( key, val )
net.Start("AWarnChatMessage") net.WriteTable({ Color(60,60,60), "[", Color(30,90,150), "AWarn", Color(60,60,60), "] ", Color(255,255,255), "Value ", Color(0,0,0), "(" .. key .. ") ", Color(255,255,255), "has been set to ", Color(0,0,0), "(" .. val .. ")" }) net.Broadcast()
if not result then
ServerLog( "AWarn: Server Setting (" .. key .. ") set to " .. val .. "\n")
else
ServerLog( "AWarn: Problem setting value for (" .. key .. ")\n")
ServerLog( "AWarn: " .. sql.LastError( result ).. "\n" )
end
else
local query = "UPDATE awarn_serverdata SET val='" .. val .. "' WHERE key='" ..key.. "'"
result = sql.Query(query)
SetGlobalInt( key, val )
net.Start("AWarnChatMessage") net.WriteTable({ Color(60,60,60), "[", Color(30,90,150), "AWarn", Color(60,60,60), "] ", Color(255,255,255), "Value ", Color(0,0,0), "(" .. key .. ") ", Color(255,255,255), "has been set to ", Color(0,0,0), "(" .. val .. ")" }) net.Broadcast()
if not result then
ServerLog( "AWarn: Server Setting (" .. key .. ") set to " .. val .. "\n")
else
ServerLog( "AWarn: Problem setting value for (" .. key .. ")\n")
ServerLog( "AWarn: " .. sql.LastError( result ).. "\n" )
end
end
end


function awarn_setserverdefaultvalues()

for k, v in pairs( AWarn.DefaultValues ) do
local query = "SELECT * FROM awarn_serverdata WHERE key='" .. k .. "'"
result = sql.QueryRow(query)

if result then
awarn_saveservervalue( k, result.val )
else
awarn_saveservervalue( k, v )
end
end

end
hook.Add( "InitPostEntity", "AWarn_SetServerDefaults", awarn_setserverdefaultvalues )

function awarn_addwarning( uid, reason, admin )
reason = sql.SQLStr( reason )
admin = sql.SQLStr( admin )
date = os.date()
local query = "INSERT INTO awarn_warnings VALUES (NULL, '" ..uid.. "', " ..admin.. ", " ..reason.. ", '" ..date.. "')"
--print(query)
result = sql.Query(query)
end

function awarn_incwarnings( ply )
local uid = ply:SteamID64()

local query = "SELECT warnings FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

local wnum = 0

if not result then
wnum = 1
local query = "INSERT INTO awarn_playerdata VALUES ( '" ..uid.. "', '" .. wnum .. "', '" .. os.time() .."' )"
result = sql.Query(query)
else
wnum = tonumber(result.warnings) + 1
local query = "UPDATE awarn_playerdata SET warnings='" .. wnum .. "', lastwarn='" .. os.time() .."' WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)
end

awarn_checkkickban( ply )
awarn_decaywarns( ply )
end

function awarn_incwarningsid( uid )

local query = "SELECT warnings FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

local wnum = 0

if not result then
wnum = 1
local query = "INSERT INTO awarn_playerdata VALUES ( '" ..uid.. "', '" .. wnum .. "', '" .. os.time() .."' )"
result = sql.Query(query)
else
wnum = tonumber(result.warnings) + 1
local query = "UPDATE awarn_playerdata SET warnings='" .. wnum .. "', lastwarn='" .. os.time() .."' WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)
end

end

function awarn_decwarnings( ply, admin )
local uid = ply:SteamID64()

local query = "SELECT warnings FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

local wnum = 0

if not result then
if admin then AWSendMessage(admin, "AWarn: This player has no warnings on record") end
else
if tonumber(result.warnings) > 0 then
wnum = tonumber(result.warnings) - 1
local query = "UPDATE awarn_playerdata SET warnings='" .. wnum .. "', lastwarn='" .. os.time() .."' WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)
            AWSendMessage( admin, "AWarn: Reduced " .. ply:Nick() .. "'s active warnings by 1!")
else
if admin then AWSendMessage(admin, "AWarn: This player has 0 active warnings already") end
end
end
end

function awarn_decwarningsid( uid, admin )

local query = "SELECT warnings FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

local wnum = 0

if not result then
if admin then AWSendMessage(admin, "AWarn: This player has no warnings on record") end
else
if tonumber(result.warnings) > 0 then
wnum = tonumber(result.warnings) - 1
local query = "UPDATE awarn_playerdata SET warnings='" .. wnum .. "', lastwarn='" .. os.time() .."' WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)
            AWSendMessage( admin, "AWarn: Reduced " .. tostring(uid) .. "'s active warnings by 1!")
else
if admin then AWSendMessage(admin, "AWarn: This player has 0 active warnings already") end
end
end
end

function awarn_setwarnings( ply, num )
local uid = ply:SteamID64()

local query = "SELECT warnings FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

local wnum = 0

if not result then
local query = "INSERT INTO awarn_playerdata VALUES ( '" ..uid.. "', '" .. num .. "', '" .. os.time() .."' )"
result = sql.Query(query)
else
local query = "UPDATE awarn_playerdata SET warnings='" .. num .. "' WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)
end
end

function awarn_delwarnings( ply, admin )
local uid = ply:SteamID64()

local query = "SELECT warnings FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

if not result then
AWSendMessage(admin, "AWarn: This player has no warnings on record")
else
local query = "DELETE FROM awarn_playerdata WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)

local query = "DELETE FROM awarn_warnings WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)

AWSendMessage(admin, "AWarn: Cleared all warnings for player: " .. ply:Nick() )
end
end

function awarn_delwarnings( ply, admin )
local uid = ply:SteamID64()

local query = "SELECT warnings FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

if not result then
AWSendMessage(admin, "AWarn: This player has no warnings on record")
else
local query = "DELETE FROM awarn_playerdata WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)

local query = "DELETE FROM awarn_warnings WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)

AWSendMessage(admin, "AWarn: Cleared all warnings for player: " .. ply:Nick() )
end
end

function awarn_delwarningsid( uid, admin )

local query = "SELECT warnings FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

if not result then
AWSendMessage(admin, "AWarn: This player has no warnings on record")
else
local query = "DELETE FROM awarn_playerdata WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)

local query = "DELETE FROM awarn_warnings WHERE unique_id='" ..uid.. "'"
result = sql.Query(query)

AWSendMessage(admin, "AWarn: Cleared all warnings for player: " .. tostring(uid) )
end
end

function awarn_delsinglewarning( admin, warningid )

local query = "SELECT * FROM awarn_warnings WHERE pid=" .. warningid
result = sql.QueryRow(query)

if not result then
AWSendMessage(admin, "AWarn: Record for this warning ID not found")
return
end

local query = "DELETE FROM awarn_warnings WHERE pid=" .. warningid
result = sql.Query( query )

end

function awarn_getwarnings( ply )
local uid = ply:SteamID64()

local query = "SELECT warnings FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

local wnum = 0

if not result then
wnum = 0
else
wnum = result.warnings
end


return tonumber(wnum)
end

function awarn_getlastwarn( ply )
local uid = ply:SteamID64()

local query = "SELECT lastwarn FROM awarn_playerdata WHERE unique_id='" .. uid .. "'"
result = sql.QueryRow(query)

local lastwarn = "NONE"

if not result then
lastwarn = "NONE"
else
lastwarn = result.lastwarn
end

return tostring(lastwarn)
end

function awarn_sendwarnings( ply, target_ply )
local uid = target_ply:SteamID64()
local warns = awarn_getwarnings( target_ply )

local query = "SELECT * FROM awarn_warnings WHERE unique_id='" .. uid .. "'"
result = sql.Query(query)

--print(warns)
if result then
net.Start("SendPlayerWarns")
net.WriteTable( result )
net.WriteInt( warns, 32 )
net.Send( ply )
else
result = {}
net.Start("SendPlayerWarns")
net.WriteTable( result )
net.WriteInt( warns, 32 )
net.Send( ply )
end
end

function awarn_gettotalwarnings( ply )
local uid = ply:SteamID64()
local query = "SELECT * FROM awarn_warnings WHERE unique_id='" .. uid .. "'"
result = sql.Query( query )

if result then
return #result
else
return 0
end
end

function awarn_sendownwarnings( ply, target_ply )
local uid = ply:SteamID64()
local warns = awarn_getwarnings( ply )

local query = "SELECT * FROM awarn_warnings WHERE unique_id='" .. uid .. "'"
result = sql.Query(query)

--print(warns)
if result then
net.Start("SendOwnWarns")
net.WriteTable( result )
net.WriteInt( warns, 32 )
net.Send( ply )
else
result = {}
net.Start("SendOwnWarns")
net.WriteTable( result )
net.WriteInt( warns, 32 )
net.Send( ply )
end
end
Title: Re: AWarn Doesent Work?
Post by: Livaco on March 27, 2015, 06:12:34 AM
That is an error that needs to be fixed...
Il Fix That If I Can see The Problem
Title: Re: AWarn Doesent Work?
Post by: Livaco on March 27, 2015, 08:24:29 AM
Il Fix That If I Can see The Problem
I Cant Fix It xD
Just Tell Me If I Need To Give U Something Cuz This Is A Real Problem This Not Working
Title: Re: AWarn Doesent Work?
Post by: Caustic Soda-Senpai on March 27, 2015, 04:16:42 PM
The problem I pointed out, as Mr President said, is unrelated to AWarn itself. If you really need help regarding AWarn, post any errors regarding AWarn here
Title: Re: AWarn Doesent Work?
Post by: MrPresident on March 27, 2015, 08:10:14 PM
Posting the code from an addon I wrote isn't going to help me fix it on your server.
I need you to post any errors you get when starting up the server. Also any errors or messages you receive in console after trying to warn someone.
Title: Re: AWarn Doesent Work?
Post by: Livaco on March 28, 2015, 05:54:07 AM
Posting the code from an addon I wrote isn't going to help me fix it on your server.
I need you to post any errors you get when starting up the server. Also any errors or messages you receive in console after trying to warn someone.
Theres None I Gave U The Entire Consle After I Tried And Warned Someone
Title: Re: AWarn Doesent Work?
Post by: JamminR on March 28, 2015, 07:46:14 AM
Livaco, next time you post an error, copy paste the entire console to/from clipboard in text format, don't just take a video of it.
At the LEAST, take a screenshot and post it as a picture.
I think you've got bigger problems than just Awarn not working. I personally wouldn't know how to fix it, but you have many consolle errors where all your addons aren't loading.

MrPresident, I took liberty and pity on Livaco and made this screenshot of his error from his video.
Looking at his video he's got a full screen of 'can't load, bad addon, removing' errors before that point. I included one of what it looks like.



Title: Re: AWarn Doesent Work?
Post by: MrPresident on March 28, 2015, 01:57:32 PM
That error would occur if you try and use AWarn in single player since you can't get the 64bit or regular steamid of a player in single player.

I'm afraid there's nothing really I can do to help him at this point, since he isn't even willing to help me help him.