FSXTim Posted June 27, 2012 Share Posted June 27, 2012 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
Jaysds1 Posted June 28, 2012 Share Posted June 28, 2012 try kicking the player instead. kickPlayer Link to comment
FSXTim Posted June 28, 2012 Author Share Posted June 28, 2012 (edited) 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 June 28, 2012 by Guest Link to comment
Jaysds1 Posted June 28, 2012 Share Posted June 28, 2012 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
FSXTim Posted June 28, 2012 Author Share Posted June 28, 2012 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
Jaysds1 Posted June 28, 2012 Share Posted June 28, 2012 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
Anderl Posted June 28, 2012 Share Posted June 28, 2012 The player did not join the server yet so you can not kick him. Link to comment
qaisjp Posted June 28, 2012 Share Posted June 28, 2012 Don't do kickPlayer! Use cancelEvent, show MySQL_GetString function pls. Link to comment
Anderl Posted June 28, 2012 Share Posted June 28, 2012 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
qaisjp Posted June 28, 2012 Share Posted June 28, 2012 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
FSXTim Posted June 28, 2012 Author Share Posted June 28, 2012 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. Greets Link to comment
qaisjp Posted June 28, 2012 Share Posted June 28, 2012 I DID CHANGE. I removed the "Like" you don't need like. Link to comment
FSXTim Posted June 28, 2012 Author Share Posted June 28, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now