Jump to content

Enju12

Recommended Posts

agroupTitles = {}
aperTitles = {}
con = dbConnect("sqlite", ":/registry.db")
function isPlayerManager(plr)
if getElementData(plr,"admin.number") > 2 then 
return true
 end
return false
end

function loadgTitles()
dbExec(con, "CREATE TABLE IF NOT EXISTS groupTitles ('group', 'text')")
dbExec(con, "CREATE TABLE IF NOT EXISTS perTitles ('account', 'text')")
    dbQuery(makeTitles, {}, con, "SELECT * FROM groupTitles")
	dbQuery(makpeTitles, {}, con, "SELECT * FROM perTitles")
end
addEventHandler("onResourceStart", resourceRoot, loadgTitles)

function makeTitles(titleQuery)
    groupTitles = dbPoll(titleQuery, 222222)
    for i, titleData in ipairs(groupTitles) do
        if (titleData) then
		local num = #groupTitles + 1
            groupTitles[num] = { titleData["group"], titleData["text"] }
			outputDebugString("1")
        end
    end
end
function makpeTitles(perQuery)
    perTitles = dbPoll(perQuery, 222222)
    for i, perData in ipairs(perTitles) do
        if (perData) then
		local num = #perTitles + 1
            perTitles[num] = { perData["account"], perData["text"] }
			outputDebugString("2")
        end
    end
end


function specials ()
local bool = exports.CIGcrimboss:isPlayerBoss(client)
triggerClientEvent("CIGCustomTitles.unlockBoss",client,bool)
end
addEvent("CIGCustomTitles.getData", true)
addEventHandler("CIGCustomTitles.getData", root, specials)

function save ()
local ct = getElementData(source,"ct")
setAccountData(getPlayerAccount(source),"ctitle",ct)
local r = getElementData(source,"r2")
setAccountData(getPlayerAccount(source),"rrgb",r)
local g = getElementData(source,"g2")
setAccountData(getPlayerAccount(source),"grgb",g)
local b = getElementData(source,"b2")
setAccountData(getPlayerAccount(source),"brgb",b)
end
addEventHandler("onPlayerQuit",root,save)
addEventHandler("onPlayerLogout",root,save)

function save2 (_,acc)
local ct = tostring(getAccountData(acc,"ctitle"))
setElementData(source,"ct",ct)
local rr = tostring(getAccountData(acc,"rrgb"))
setElementData(source,"r2",rr)
local bb = tostring(getAccountData(acc,"brgb"))
setElementData(source,"b2",bb)
local gg = tostring(getAccountData(acc,"grgb"))
setElementData(source,"g2",gg)
local name = getAccountName(acc)
triggerClientEvent(source,"CIGcustomTitles.addTitles",source,name)
end
addEventHandler("onPlayerLogin",root,save2)


function onplayerlo ()
local acc = getAccountName(getPlayerAccount(client))
for i, col in ipairs(agroupTitles) do
local thename = col[1]
if thename == getElementData(client,"g") then
triggerClientEvent(client,"CIGcustomTitles.addATitle",client,col[2])
outputDebugString("4")
end

end
end
addEvent("CIGcustomTitles.checkGroup",true)
addEventHandler("CIGcustomTitles.checkGroup",root,onplayerlo)


function onplayerl ()
local acc = getAccountName(getPlayerAccount(client))
for i, col in ipairs(aperTitles) do
local thename = col[1]
if thename == acc then
triggerClientEvent(client,"CIGcustomTitles.addATitle",client,col[2])
outputDebugString("5")
end

end
end
addEvent("CIGcustomTitles.checkTitle",true)
addEventHandler("CIGcustomTitles.checkTitle",root,onplayerl)

 

Link to comment

oh my god...
 

groupTitles = dbPoll(titleQuery, 222222)
  • queryHandle: A query handle previously returned from dbQuery

timeout: How many milliseconds to wait for a result. Use 0 for an instant response (which may return nil). Use -1 to wait until a result is ready. Note: A wait here will freeze the entire server just like the executeSQL* functions

Script maximum wait in load:
 

#define HOOK_MAXIMUM_TIME 5000

// Above max time?
if (pLuaMain->m_FunctionEnterTimer.Get() > HOOK_MAXIMUM_TIME)
{
	// Print it in the console
	CLogger::ErrorPrintf("Infinite/too long execution (%s)", pLuaMain->GetScriptName());

    SString strAbortInf = "Aborting; infinite running script in ";
    strAbortInf += pLuaMain->GetScriptName();

    // Error out
    lua_pushstring(luaVM, strAbortInf);
    lua_error(luaVM);
}


 

Edited by XaskeL
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...