General > Developers Corner
Ulib/ULX function overriding (and now Hooks too) - MySQL
EraYaN:
Thanks for the help but maybe you could help me with some lua.
--- Code: ---function erayan.doCheckGroup(name, inherit_from, displayname, can_target)
if not erayan.database.state == 0 then
notifyerror( 'SQL Connection not open.' )
return false
else
if inherit_from == nil then
inherit_from = ''
end
if can_target == nil then
can_target = ''
end
local queryText = erayan.queries['select_group']:format(name,erayan.config.server)
print( 'EraYaN: ','Query',queryText)
local query = erayan.database:query(queryText)
if (query) then
query.onFailure = erayan.checkGroupOnFailure
query.onSuccess = erayan.checkGroupOnSuccess
query.onData = erayan.checkGroupOnData
query.name = name
query.inherit_from = inherit_from
query.displayname = displayname
query.can_target = can_target
query:start()
print( 'EraYaN: ','-----------------------Checking Group-----------------------')
else
table.insert(erayan.database.pending, {queryText})
CheckStatus()
print( 'EraYaN: ','-----------------------Check Group Query Pending-----------------------')
end
end
end
function erayan.checkGroupOnFailure(self, err)
notifyerror( 'SQL Check Group Fail ', err )
end
function erayan.checkGroupOnSuccess()
print( 'EraYaN: ', '-----------------------Checked Group----------------------- ')
end
function erayan.checkGroupOnData(self, datarow)
print( 'EraYaN: ','-----------------------Recieved Group Data----------------------- ')
print( 'EraYaN: ','DataRow', datarow['Hits'])
print( 'EraYaN: ',type(datarow['Hits']),datarow['Hits'])
if datarow['Hits'] == "0" then
print( 'EraYaN: ','-----------------------Adding group...----------------------- ')
erayan.doAddGroup( self.name, self.inherit_from, self.displayname, self.can_target )
else
print( 'EraYaN: ','-----------------------Updating group...----------------------- ')
erayan.doUpdateGroup( datarow['ulibGroupID'], self.inherit_from, self.displayname, self.can_target )
end
end
--- End code ---
it runs the first function (as it should) and prints
--- Code: ---EraYaN: Query <query here>
EraYaN: -----------------------Checking Group-----------------------
--- End code ---
it works on my users so I dont get why it doesn't call the callbacks
EDIT: the queries are ok they run fine in MySQL workbench
EDIT2: checked again, queries run but callbacks aren't called
Megiddo:
You'll have to share how you're hooking those functions.
EraYaN:
So i'm digging my old topic to the top again because of the following:
I want to load bans from mysql.
But what function is actually used to load the bans uLib.refreshBans()? I've overridden that one but no avail.
EDIT: I fixed it for now by just rerunning the function not as nice tho. and still not making the bans in effect.
EDIT2: the server doesn't seem to execute callback when no one's connected, thats a problem because what is the first player to join is banned?
EDIT3: I tried to hook a console command (bot) to Initialize but it returns: "Error, bad server command bot"
Code:
--- Code: ---function wakeUpWithBot()
game.ConsoleCommand( "bot" ) -- Execute after done loading bans
timer.Create("EraYaNRemoveBot", 10, 1, function() for k, v in pairs(player.GetBots()) do Msg( ULib.queueFunctionCall( game.ConsoleCommand, ("kickid %i"):format(v:UserID()) ) ) end end)
end
hook.Add("Initialize", "EraYaNWakeUpWithBot", wakeUpWithBot)--InitPostEntity gives same error
--- End code ---
some where here.. Any hook called then?
http://erayan.eu/jing/right_there.png
Navigation
[0] Message Index
[*] Previous page
Go to full version