Jump to content

Register script


Recommended Posts

Hi i have a problem with my script so it works :

function selfOnCon () 
local name = getPlayerName (source) 
local player = getPlayerFromName (name) 
local ip = getPlayerIP (source) 
local serial = getPlayerSerial (source) 
            local query = dbQuery ( handler2, "SELECT * FROM userdata WHERE Name=?",name )  
                result , numrows, errmsg = dbPoll (query, -1)  
            local row = result[1]  
        if row then  
            triggerClientEvent (source, "onPlayerGuiLogin", source,name) 
            elseif not row then 
                        local query = dbQuery ( handler2, "SELECT * FROM userdata WHERE Serial=?",serial )  
                result , numrows, errmsg = dbPoll (query, -1)  
            local row = result[1]  
        if not row then  
            triggerClientEvent (source, "onPlayerGuiRegister", source,name) 
        else 
            kickPlayer (player, "Console", "Du hast bereits einen Account!") 
end 
end 
end 
addEventHandler ("onPlayerJoin", getRootElement(), selfOnCon) 

but it wouldn work so:

function selfOnCon () 
local name = getPlayerName (source) 
local player = getPlayerFromName (name) 
local ip = getPlayerIP (source) 
local serial = getPlayerSerial (source) 
if  (ifnameexists(pname) == true) then 
            triggerClientEvent (source, "onPlayerGuiLogin", source,name) 
        elseif (ifnameexists(pname) == false) then 
if (ifserialexists(serial) == false) then 
            triggerClientEvent (source, "onPlayerGuiRegister", source,name) 
        else 
            kickPlayer (player, "Console", "Du hast bereits einen Account!") 
end 
end 
end 
addEventHandler ("onPlayerJoin", getRootElement(), selfOnCon) 
  
  
function ifnameexists (pname) 
                        local query = dbQuery ( handler2, "SELECT * FROM userdata WHERE Name=?",pname )  
                        result , numrows, errmsg = dbPoll (query, -1)  
                        local row = result[1]  
                        if row then  
                        return true 
                        else 
                        return false 
end 
end 
  
function ifserialexists (serial) 
                        local query = dbQuery ( handler2, "SELECT * FROM userdata WHERE Serial=?",serial )  
                        result , numrows, errmsg = dbPoll (query, -1)  
                        local row = result[1]  
                        if row then  
                        return true 
                        else 
                        return false  
end  
end 

By the second script i will be kicked although when im logging in with the original name and serial with who are in mysql?

Link to comment

'pname' Isn't defined.

function selfOnCon () 
local name = getPlayerName (source) 
local player = getPlayerFromName (name) 
local ip = getPlayerIP (source) 
local serial = getPlayerSerial (source) 
if  (ifnameexists(name) == true) then 
            triggerClientEvent (source, "onPlayerGuiLogin", source,name) 
        elseif (ifnameexists(name) == false) then 
if (ifserialexists(serial) == false) then 
            triggerClientEvent (source, "onPlayerGuiRegister", source,name) 
        else 
            kickPlayer (player, "Console", "Du hast bereits einen Account!") 
end 
end 
end 
addEventHandler ("onPlayerJoin", getRootElement(), selfOnCon) 
  
  
function ifnameexists (pname) 
                        local query = dbQuery ( handler2, "SELECT * FROM userdata WHERE Name=?",pname ) 
                        result , numrows, errmsg = dbPoll (query, -1) 
                        local row = result[1] 
                        if row then 
                        return true 
                        else 
                        return false 
end 
end 
  
function ifserialexists (serial) 
                        local query = dbQuery ( handler2, "SELECT * FROM userdata WHERE Serial=?",serial ) 
                        result , numrows, errmsg = dbPoll (query, -1) 
                        local row = result[1] 
                        if row then 
                        return true 
                        else 
                        return false 
end 
end 

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