This will allow you to register players onto your SMF forums from in-game.
[lua]require(“mysqloo”)
require(“cryptopp”)
local db = mysqloo.connect(“localhost”, username, pw, “smf”, 3306)
db:connect()
function iPly.SMF_register (username, password, email)
local username = iA.filter(username)
if (not email) or (string.len(email)<4) then email = "invalid" end
register_vars = {
memberName = "'" .. username .. "'",
realName= "'" .. username .. "'",
emailAddress= "'" .. (email or "") .. "'",
passwd= "'" .. string.lower(crypto.sha1(string.lower(username) .. password)) .. "'",
passwordSalt= "'" .. string.sub(string.lower(crypto.md5(tostring(math.random(0,2147483647)))), 0, 4) .. "'",
posts= '0',
dateRegistered= tostring(os.time()),
is_activated= '1',
personalText= "''",
pm_email_notify= '1',
ID_THEME= '0',
ID_POST_GROUP= '4',
lngfile= "''",
buddy_list= "''",
pm_ignore_list= "''",
messageLabels= "''",
websiteTitle= "''",
websiteUrl= "''",
location= "''",
ICQ= "''",
AIM= "''",
YIM= "''",
MSN= "''",
timeFormat= "''",
signature= "''",
avatar= "''",
usertitle= "''",
memberIP= "''",
memberIP2= "''",
secretQuestion= "''",
secretAnswer= "''",
validation_code= "''",
additionalGroups= "''",
smileySet= "''",
--passwordSalt= "''",
}
local function keys(tbl)
local out = {}
for k,v in pairs(tbl) do
table.insert(out, k)
end
return out
end
local function itable(tbl)
local out = {}
for _,v in pairs(keys(tbl)) do
table.insert(out, tbl[v])
end
return out
end
local id
local query = "INSERT INTO smf_members (" .. string.Implode(', ', keys(register_vars)) .. ") VALUES (" .. string.Implode(', ', itable(register_vars)) .. ')'
local q1 = db:query(query)
q1.onError = function(q, err) print ("MYSQLOO ERROR iPly.SMF_register: " .. err) return end
q1:start()
local q2 = db:query("UPDATE smf_settings SET value = value + 1 WHERE variable = 'totalMembers' LIMIT 1")
q2.onError = function(q, err) print ("MYSQLOO ERROR iPly.SMF_register_totalmembers: " .. err) return end
q2:start()
--[[tmysql.query("REPLACE INTO members (variable, value) VALUES ('latestMember', " .. id .. "), ('latestRealName', '" .. username .. "')", function(res, stat, err)
if stat == 0 then print ("TMYSQL ERROR iPly.SMF_register_latestmember: " .. err) return end
end)]]
end
concommand.Add(“testregister”, function(ply, cmd, args)
if not iA.isOwner(ply) then return end
for k,v in pairs(args) do
args[k] = iA.filter(v)
end
iPly.SMF_register(args[1], args[2], args[3])
end)[/lua]
My question:
Recently Serverchecker hasn’t really been cutting it. I’m not sure if I am the only one having this issue, but since about two weeks ago, the server would frequently double, triple, or quadruple restart in intervals of 90 seconds or whatever I have the “Startup time” variable set to. This is not tolerable because it can lose many players after a server crash.
A .bat file also doesn’t cut it, because sometimes SRCDS hangs instead of crashing, which the .bat file won’t detect. If you’re wondering why my server crashes so often, it is because it is a build server.
What I’m looking for is someone able to program in a different language (maybe C++?) that can make a server checker. It wouldn’t need to be real nice, just something that can detect when the server is offline and restart it. I’m not exactly sure how one pings a gameserver, but I could also use other mechanisms, maybe with gm_socks. I’d learn C++ myself but it’s very difficult to get started and I’d rather finish working on the gamemode I am working on.
If someone can help me code a server restarter script, that works well, I will even pay you $20 if it works, $30 if it is easy to use.