Jump to content

event is not canceled


FSXTim

Recommended Posts

Hello,

although I set 'Bann' in the database to 10, the event is not canceled.

function bannCheck (nick, ip, username, serial) 
    local bt = tonumber(MySQL_GetString("Bann", "user_data", "Name LIKE '"..nick.."'")) 
    if bt then 
        bool = not (bt == 0) 
    end 
    if bool then 
        if bt < 0 then 
            MySQL_DelRow ("Bann", "user_data", "Name LIKE '"..nick.."'") 
        elseif bt > 0 then 
            cancelEvent(true, "Du bist gebannt!") 
        end 
    end 
end 
addEventHandler("onPlayerConnect", getRootElement(), bannCheck) 

Greets

Link to comment

Thanks for the answer, but no I have another problem.

The DebugString sais 'Test', indifferent what 'Bann' is. It can be 0, 5 or 10 (line 13).

The DebugString sais '0', although 'Bann' is '15' (line 6).

function MySQL_GetString(feldN, tableN, bedingung) 
    local result = mysql_query(sqlcon, "SELECT "..feldN.." FROM "..tableN.." WHERE Username='"..mysql_escape_string(sqlcon, bedingung).."';") 
    if (not result) then 
        outputDebugString(mysql_error(sqlcon)) 
    else 
        outputDebugString(mysql_num_rows(result)) 
        if(mysql_num_rows(result) > 0) then 
           local ds = mysql_fetch_assoc(result) 
           local savename = feldN 
           mysql_free_result(result) 
           return ds[feldN] 
        else 
           outputDebugString("Test!") 
           mysql_free_result(result) 
           return false 
        end 
    end 
end 

What do I have to do to fix it?

Greets

Edited by Guest
Link to comment

When is this "MySQL_GetString" function triggered?

Anyways, try this:

function MySQL_GetString(feldN, tableN, bedingung) 
    local result = mysql_query(sqlcon, "SELECT '"..feldN.."' FROM '"..tableN.."' WHERE Username='"..mysql_escape_string(sqlcon, bedingung).."'") 
    if (not result) then 
        outputDebugString(mysql_error(sqlcon)) 
    else 
        outputDebugString(mysql_num_rows(result)) 
        if(mysql_num_rows(result) > 0) then 
           local ds = mysql_fetch_assoc(result) 
           local savename = feldN 
           mysql_free_result(result) 
           return ds[feldN] 
        else 
           outputDebugString("Test!") 
           mysql_free_result(result) 
           return false 
        end 
    end 
end 

Link to comment

Thanks, I will test it in few hours. I have to go.

Triggered:

function bannCheck (nick, ip, username, serial) 
    local bt = tonumber(MySQL_GetString("Bann", "user_data", "Name LIKE '"..nick.."'")) 
    if bt then 
        if bt > 0 then 
            cancelEvent(true, "Du bist gebannt!") 
        end  
    end 
end 
addEventHandler("onPlayerConnect", getRootElement(), bannCheck) 

Greets

Link to comment

ok, btw, try this instead of that script:

function bannCheck (nick, ip, username, serial) 
    local bt = tonumber(MySQL_GetString("Bann", "user_data", "Name LIKE '"..nick.."'")) 
    if bt then 
        if bt > 0 then 
            kickPlayer(source,root,"Du bist gebannt!") 
        end  
    end 
end 
addEventHandler("onPlayerConnect", getRootElement(), bannCheck) 

Link to comment
Thanks for the answer, but no I have another problem.

The DebugString sais 'Test', indifferent what 'Bann' is. It can be 0, 5 or 10 (line 13).

The DebugString sais '0', although 'Bann' is '15' (line 6).

function MySQL_GetString(feldN, tableN, bedingung) 
    local result = mysql_query(sqlcon, "SELECT "..feldN.." FROM "..tableN.." WHERE Username='"..mysql_escape_string(sqlcon, bedingung).."';") 
    if (not result) then 
        outputDebugString(mysql_error(sqlcon)) 
    else 
        outputDebugString(mysql_num_rows(result)) 
        if(mysql_num_rows(result) > 0) then 
           local ds = mysql_fetch_assoc(result) 
           local savename = feldN 
           mysql_free_result(result) 
           return ds[feldN] 
        else 
           outputDebugString("Test!")Â  Â  Â   
           mysql_free_result(result) 
           return false 
        end 
    end 
end 

What do I have to do to fix it?

Greets

Link to comment
function bannCheck (nick, ip, username, serial) 
    local bt = tonumber(MySQL_GetString("Bann", "user_data", "'"..nick.."'")) 
    if bt then 
        if bt > 0 then 
            cancelEvent(true, "Du bist gebannt!") 
        end  
    end 
end 
addEventHandler("onPlayerConnect", getRootElement(), bannCheck) 

try this

Link to comment
function bannCheck (nick, ip, username, serial) 
    local bt = tonumber(MySQL_GetString("Bann", "user_data", "'"..nick.."'")) 
    if bt then 
        if bt > 0 then 
            cancelEvent(true, "Du bist gebannt!") 
        end  
    end 
end 
addEventHandler("onPlayerConnect", getRootElement(), bannCheck) 

try this

Dude, you didn't change anything!

When is this "MySQL_GetString" function triggered?

Anyways, try this:

function MySQL_GetString(feldN, tableN, bedingung) 
    local result = mysql_query(sqlcon, "SELECT '"..feldN.."' FROM '"..tableN.."' WHERE Username='"..mysql_escape_string(sqlcon, bedingung).."'") 
    if (not result) then 
        outputDebugString(mysql_error(sqlcon)) 
    else 
        outputDebugString(mysql_num_rows(result)) 
        if(mysql_num_rows(result) > 0) then 
           local ds = mysql_fetch_assoc(result) 
           local savename = feldN 
           mysql_free_result(result) 
           return ds[feldN] 
        else 
           outputDebugString("Test!") 
           mysql_free_result(result) 
           return false 
        end 
    end 
end 

You also didn't change anything. :shock:

Greets

Link to comment

Everything doesn't work, but I found a solution.

I had to change this line

local bt = tonumber(MySQL_GetString("Bann", "user_data", '"..nick"')) 

to

local bt = tonumber(MySQL_GetString("Bann", "user_data", nick)) 

But thanks at all!

Greets

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