Jump to content

Triggered serverside event?!


supernovaa

Recommended Posts

Hi guys!

I have problem with one gamemode.

First i started the gamemode, then i want login and register but i cant.

Sorry for my bad English.

Console errors:

restart sg_login 
[18:08:08] restart: Requested by Console 
[18:08:08] restart: Resource restarting... 
[18:08:08] Stopping sg_login 
[18:08:08] Starting sg_login 
[18:08:08] SCRIPT ERROR: sg_login\server.lua:30: ')' expected (to close '(' at line 21) near 'dbQuery' 
[18:08:08] ERROR: Loading script failed: sg_login\server.lua:30: ')' expected (to close '(' at line 21) near 'dbQuery' 
[18:08:08] sg_login restarted successfully 
[18:08:08] ERROR: Client (James) triggered serverside event checkPlayerBanState, but event is not added serverside 
[18:08:16] DENIED: Denied 'James' access to command 'debugscript' 
[18:08:18] ERROR: Client (James) triggered serverside event playerLogin, but event is not added serverside 
[18:08:21] ERROR: Client (James) triggered serverside event playerRegister, but event is not added serverside 
[18:08:25] ERROR: Client (James) triggered serverside event playerRegister, but event is not added serverside 

Script, server.lua:

local mysql = exports.mysql 
local postable = {}
local regisztalhat = true
 
function playerRegister(player, username, password, password2)
    local md5password = md5(password)
    if(password~=password2)then
   
    triggerClientEvent("info",player,"A felhasználónév túl rövid!", "red")
        return
    end
    if(string.len(username)<5)then
        triggerClientEvent("info",player,"A felhasználónév túl rövid!", "red")
        return
    end
    if(string.len(password)<5)then
            triggerClientEvent("info", player, "A jelszó túl rövid!", "red")
        return
    end
        serial = getPlayerSerial(player)
        dbQuery(function(qh, player, username, md5password)
            local a, b, c = dbPoll(qh, 0)
            if b > 0 then
                outputChatBox("Neked már van accountod")
                regisztalhat = false
                return
            end        
        end, {player,username,md5password}, mysql:getConnection(), ("SELECT * FROM characters WHERE charactername='" .. safecharname .. "' AND account='" .. mysql:escape_string(id) .. "' AND cked = 0")
       
        dbQuery(function(qh, player, username, md5password)
            local result, rows, errorMsg = dbPoll(qh, 0)
            if not regisztalhat then return end
            if rows > 0 then
                exports.sg_box:addNotification("Ez a felhasználónév már foglalt!","red")
            else
                local _, id = mysql:query_free("INSERT INTO accounts SET serial = '".. serial .."', username = '"..tostring(username).."', password = '"..tostring(md5password).."'", true)
               
                exports.sg_box:addNotification("Sikeresen regisztráltál!","green")
            end
        end, {player,username,md5password}, mysql:getConnection(), "SELECT * FROM accounts WHERE username = ? LIMIT 1", username)
end
addEvent("playerRegister", true)
addEventHandler("playerRegister", getRootElement(), playerRegister)
 
function playerLogin(player, username, password)
    password = md5(password)
 
       
        local query = mysql:singleQuery("SELECT * FROM accounts WHERE username = ? AND password = ? LIMIT 1", username, password)
        if query then   
 
            --local querys = mysql:singleQuery("SELECT serial FROM accounts WHERE username = ? LIMIT 1", username)
                        outputChatBox("[socialGaming] #FFFFFFSikeres bejelentkezés!",player,169,139,101,true)
                        setElementData(player, "accountID", query.id)
                        acc = getElementData(player, "accountID")
                        CharSelect(acc, player)
                        setElementData(player, "adminlevel", query.admin)
    else
        outputChatBox("[socialGaming] #FFFFFFSikertelen bejelentkezés!",player,177,9,45,true)
    end 
end
addEvent("playerLogin", true)
addEventHandler("playerLogin", getRootElement(), playerLogin)
 
addEvent("createCharacter", true)
addEventHandler("createCharacter", getRootElement(), function(p, nev, kor, suly, magassag, leiras, gender, color)
 
    acc = getElementData(p, "accountID")   
    local qh = dbQuery( mysql:getConnection(), "SELECT `charactername` FROM `karakterek` WHERE `charactername` = ?", tostring(a))
    local result = dbPoll ( qh, -1 )
    local count = 0
    local pw
    u = nil
    if result then
        for _, row in ipairs ( result ) do
            u = string.lower(row["charactername"])
        end
        if u ~= nil then
            exports.sg_box:createSmallNotification(client,"Már van ilyen karakter név, kérlek válassz másikat!", 1)
            return
        end
    end
    dbFree( qh )
    local user = getElementData(client, "username")
    qhh = dbExec( mysql:getConnection(), "INSERT INTO `karakterek` SET `charactername` = ?, `id` = ?, `skin` = 1, `kor` = ?, `suly` = ?, `magassag` = ?, `leiras` = ?, `gender` = ?,`color` = ? ", nev, acc, kor, suly, magassag, leiras, gender, color)
    if qhh then
        CharSelect(acc, p)
    end
end)
 
local postable = {}
 
function CharSelect(acc, source)
    local accid = getElementData(source,"accountID")
    local qh = dbQuery(mysql:getConnection(),"SELECT * FROM karakterek WHERE id = ? LIMIT 1", accid)
    local result, lineNumber = dbPoll ( qh, -1 )
    if(result) then
        if(lineNumber > 0) then
            for _, rows in ipairs( result ) do
                postable = {}
                level = rows["level"]
                xp = rows["xp"]
                jatszottpercek = rows["spentTime"]
                nev = rows["charactername"]
                anev = rows["adminnick"]               
                fraki = rows["faction"]
                frakir = rows["factionrank"]
                factionleader = rows["factionleader"]              
                skin = rows["skin"]
                dutyskin = rows["dutyskin"]            
                induty = rows["inDuty"] 
                kor = rows["kor"]          
                suly = rows["suly"]
                mag = rows["magassag"]
                job = rows["job"]              
                desc = rows["leiras"]
                gender = rows["gender"] 
                health = rows["health"]
                bankmoney = rows["bankmoney"]              
                keszpenz = rows["keszpenz"]            
                money = rows["money"]                  
                color = rows["color"]   
                pajzs = rows["pajzs"]                  
                ehesseg = rows["ehesseg"]                  
                maxvehicles = rows["maxvehicles"]              
                hasznaltkocsislot = rows["hasznaltkocsislot"]              
                premiumPont = rows["premiumPont"]              
                adminduty = rows["adminduty"]                  
                adminlevel = rows["adminlevel"]                
                pozicio = fromJSON(rows["pozicio"])
                postable = {pozicio[1],pozicio[2],pozicio[3],pozicio[4]}
                halal = rows["isDead"]
            end
                setPlayerName(source, string.gsub(nev, " ", "_"))
                setElementData(source, "charactername", nev)
                setElementData(source, "adminduty", 0)
                setElementData(source, "adminnick", anev)              
                spawnPlayer(source, postable[1], postable[2], postable[3], postable[4])
                setElementData(source, "logedin", true)
                setElementData(source, "jatszottpercek", jatszottpercek)
                setElementData(source, "faction", fraki)
                setElementData(source, "factionrank", frakir)   
                setElementData(source, "factionleader", factionleader)                 
                setElementData(source, "age", kor)
                setElementData(source, "gender", gender)
                setElementData(source, "bankmoney", bankmoney)
                setElementData(source, "keszpenz", keszpenz)
                setElementData(source, "adminduty", adminduty)
                setElementData(source, "adminlevel", adminlevel)
                setElementData(source, "premiumPont", premiumPont)
                setElementData(source, "xp", xp)
                setElementData(source, "level", level)
                if halal == 1 then
                    setElementHealth(source, 0)
                else
                    setElementHealth(source, health)
                end
                setElementData(source, "money", money)
                setElementData(source, "color", color)
                setPedArmor(source, pajzs)
                setElementData(source, "weight", suly)
                setElementData(source, "height", mag)
                setElementData(source, "desc", desc)
                setElementData(source, "job:id", job)
                setElementData(source, "ehesseg", ehesseg)                 
                setElementData(source, "maxvehicles", maxvehicles)                 
                setElementData(source, "hasznaltkocsislot", hasznaltkocsislot)                 
                setElementData(source, "normalskin", skin)
                setElementData(source, "dutyskin", dutyskin)
                setElementData(source, "inDuty", induty)
                if getElementData(source, "inDuty") then
                    actualskin =  getElementData(source, "dutyskin")
                else
                    actualskin = getElementData(source, "normalskin")
                end
                setElementModel(source, actualskin)            
--color health  ehesseg pajzs   spentTime   faction factionrank factionleader   maxVeh  maxInt             
                setCameraTarget(source)
                triggerClientEvent(source,"succes", source)
    else
            triggerClientEvent(source,"characterCreation", source)
        end
    end
end
 
 
addEventHandler("onPlayerQuit", getRootElement(), function()
    if getElementData(source, "logedin") then
        savePlayer(source)
    end
end)
 
function savePlayer(p)
    if isElement(p) then
        local x,y,z = getElementPosition(p)
        local rot = getPedRotation(p)
        local dbid = tonumber(getElementData(p, "accountID")) or 0
        local admin = tonumber(getElementData(p, "adminlevel")) or 0
        local position = toJSON({x,y,z,rot})
        local orak = getElementData(p, "jatszottpercek") or 0
        local faction = getElementData(p, "faction") or 0
        local hp = getElementHealth(p)
        local bankmoney = getElementData(p, "bankmoney")
        local keszpenz = getElementData(p, "keszpenz")
        local money = getElementData(p, "money")
        local armor = getPedArmor(p)
        local ehesseg = getElementData(p, "ehesseg")
        local skin = getElementData(p, "normalskin")
        local duty = getElementData(p, "inDuty")
        local dutyskin = getElementData(p, "dutyskin")
        local job = getElementData(p, "job:id")
        local maxvehicles = getElementData(p, "maxvehicles") or 4
        local hasznaltkocsislot = getElementData(p, "hasznaltkocsislot") or 0
        local premiumPont = getElementData(p, "premiumPont") or 0
        local xp = getElementData(p, "xp") or 0
        local level = getElementData(p, "level") or 0
       
        dbExec(mysql:getConnection(), "UPDATE karakterek SET pozicio = ?, spentTime = ?, faction = ?, health = ?, bankmoney = ?, money = ?, pajzs = ?, ehesseg = ?, skin = ?, job = ? WHERE ID = ?", position,  spentTime, faction, hp, bankmoney, money, armor, ehesseg, skin, job,  dbid)
        dbExec(mysql:getConnection(), "UPDATE karakterek SET maxvehicles = ?,hasznaltkocsislot = ?,premiumPont = ?, inDuty = ?, dutyskin = ?, keszpenz = ? WHERE ID = ?", maxvehicles,hasznaltkocsislot,premiumPont, duty, dutyskin,keszpenz,dbid)
        dbExec(mysql:getConnection(), "UPDATE accounts SET admin = ? WHERE ID = ?",admin,xp,level,dbid)
        dbExec(mysql:getConnection(), "UPDATE karakterek SET xp=?,level=? WHERE ID = ?",xp,level,dbid)
       
    end
end
addEvent("savePlayer", true)
addEventHandler("savePlayer", getRootElement(), savePlayer)
 
function saveAllPlayer()
    local count = 0
    for i, p in ipairs(getElementsByType("player")) do
        if (getElementData(p, "logedin") or false) then
            savePlayer(p)
            count = count + 1
        end
    end
    outputDebugString("Ellett mentve "..count.." jatekos adata!")
end
saveAllPlayer()
setTimer(saveAllPlayer, 1000*60*10, 0)
addCommandHandler("saveall",saveAllPlayer)
 
addEvent("checkPlayerBanState", true)
addEventHandler("checkPlayerBanState", getRootElement(),
    function(player)
        local serial = getPlayerSerial(player)
        local query = dbQuery(mysql:getConnection(),"SELECT * FROM banlist WHERE serial=?",serial)
        local qh = dbPoll(query, -1)
        local playerSerial, timeStamp, bannedBy, reason
        if #qh > 0 then
            for k, data in ipairs (qh) do
                outputChatBox("Ok")
                playerSerial = data["serial"]
Link to comment

Okay, im change script.

dbQuery = function(qh, player, username, md5password) 

Warning:

restart sg_login 
[18:54:03] restart: Requested by Console 
[18:54:03] restart: Resource restarting... 
[18:54:03] Stopping sg_login 
[18:54:03] Starting sg_login 
[18:54:03] ERROR: sg_login\server.lua:1: exports: Call to non-running server resource (mysql) [string "?"] 
[18:54:03] INFO: Ellett mentve 0 jatekos adata! 
[18:54:03] sg_login restarted successfully 
[18:54:03] WARNING: sg_login\server.lua:246: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got nil] 
[18:54:03] WARNING: sg_login\server.lua:247: Bad argument @ 'dbPoll' [Expected db-query at argument 1, got boolean] 
[18:54:03] ERROR: sg_login\server.lua:249: attempt to get length of local 'qh' (a boolean value) 
[18:54:21] ERROR: sg_login\server.lua:28: attempt to concatenate a nil value 
[18:54:24] DENIED: Denied 'James' access to command 'debugscript' 
[18:54:25] ERROR: sg_login\server.lua:28: attempt to concatenate a nil value 
[18:54:26] ERROR: sg_login\server.lua:28: attempt to concatenate a nil value 

246 line 
local query = dbQuery(mysql:getConnection(),"SELECT * FROM banlist WHERE serial=?",serial)  
  
247 line  
local qh = dbPoll(query, -1) 
  
249 line  
local playerSerial, timeStamp, bannedBy, reason 
  
28 line 
end, {player,username,md5password}, mysql:getConnection(), ("SELECT * FROM characters WHERE charactername='" .. safecharname .. "' AND account='" .. mysql:escape_string(id) .. "' AND cked = 0") 

Not wokring. :|

Link to comment

Hello dear supernova,

First off, there's a resource called "mysql" not running, that's means it's off not working at all, try to start this resource, and if this resource contains database informations so in this case all db functions who are exist in your script would return false with warning / errors.

Good luck,

Regards,

KariM

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...