myonlake Posted January 5, 2012 Share Posted January 5, 2012 (edited) Hello there, I am trying to make a script that kills the player, creates a pedestrian on it and deletes the database entry from the database (deletes character fully). SQL connection works fine, but debug says the problem is in the query, help? function characterkill(player, cmd, names) if hasObjectPermissionTo(player, "command.ban") then if names then local other, name = exports.players:getFromName(player, names) if other then connect = mysql_connect("host", "user", "pass", "db") if not connect then outputDebugString("Unable to connect to the MySQL server.") else if mysql_query(connect, "DELETE FROM characters WHERE characterName = " .. name) then local x, y, z = getElementPosition(other) local skin = getElementModel(other) local ped = createPed(skin, x, y, z) setElementHealth(other, 0) killPed(ped) setElementFrozen(ped, true) setElementFrozen(other, true) setElementAlpha(other, 0) outputChatBox(name .. " has been character killed.", player, 220, 220, 0, false) outputChatBox(name .. " has been character killed - meaning that your character is now fully dead and removed.", other, 220, 220, 0, false) setTimer(redirectPlayer, 5000, 1, other, ip, "22004") else outputChatBox("SQL error happened, report at Mantis.", player, 255, 0, 0, false) end end else outputChatBox("No player found.", player, 255, 0, 0, false) end else outputChatBox("Syntax: /ck [player]", player, 255, 255, 255, false) end end end addCommandHandler("ck", characterkill) Edited May 30, 2019 by myonlake Link to comment
Kenix Posted January 5, 2012 Share Posted January 5, 2012 (edited) Try function characterkill(player, cmd, names) if hasObjectPermissionTo(player, "command.ban") then if names then local other, name = exports.players:getFromName(player, names) if other then connect = mysql_connect("host", "user", "pass", "db") if not connect then outputDebugString("Unable to connect to the MySQL server.") else if mysql_query( connect, "DELETE FROM characters WHERE characterName = '" .. name.."'" ) then local x, y, z = getElementPosition(other) local skin = getElementModel(other) local ped = createPed(skin, x, y, z) setElementHealth(other, 0) killPed(ped) setElementFrozen(ped, true) setElementFrozen(other, true) setElementAlpha(other, 0) outputChatBox(name .. " has been character killed.", player, 220, 220, 0, false) outputChatBox(name .. " has been character killed - meaning that your character is now fully dead and removed.", other, 220, 220, 0, false) setTimer(redirectPlayer, 5000, 1, other, ip, "22004") else outputChatBox("SQL error happened, report at Mantis.", player, 255, 0, 0, false) end end else outputChatBox("No player found.", player, 255, 0, 0, false) end else outputChatBox("Syntax: /ck [player]", player, 255, 255, 255, false) end end end addCommandHandler("ck", characterkill) You can also check problem with function mysql_error. And show what debug write. Edited January 5, 2012 by Guest 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