I see people here have extraordinary potential. But I have a serious problem so I ask you to help me
Server
function DeleteChara()
if (getElementData(theElement,"account:charselect:id")) then
local dbid = getElementData(theElement,"account:charselect:id")
local escapedID = exports.mysql:escape_string(dbid)
local result = exports.mysql:query("SELECT * FROM characters WHERE id='" .. dbid .. "'")
local fetch = exports.mysql:fetch_assoc(result)
local query = exports.mysql:query("DELETE * FROM characters WHERE id='" .. dbid .. "'")
if query then
outputChatBox("Successfully deleted this character!", source, 0, 255, 0)
refreshCharacters()
else
outputChatBox("ERROR!", source, 255, 0, 0)
end
end
end
addEvent("accounts:DeleteChara", true)
addEventHandler("accounts:DeleteChara", getRootElement(), DeleteChara)
Client
function closeDelChar()
destroyElement(myWindow)
showCursor(true)
end
function DeleteChara()
triggerServerEvent("accounts:DeleteChara", localPlayer)
end
function delChar()
myWindow = guiCreateWindow ( 0.3, 0.3, 0.3, 0.2, "Information", true )
-- Button Boss
bClose = guiCreateButton(0.550, 0.5, 0.4, 0.2, "No", true, myWindow)
addEventHandler("onClientGUIClick", bClose, closeDelChar)
bAccept = guiCreateButton(0.050, 0.5, 0.4, 0.2, "Yes", true, myWindow)
addEventHandler("onClientGUIClick", bAccept, DeleteChara)
-- Text
lText = guiCreateLabel(0.025, 0.2, 1.0, 0.3, "Are You Sure?\nTo Delete This Character.", true, myWindow)
guiSetFont(lText, "default-bold-small")
guiLabelSetHorizontalAlign(lText, "center", true)
end
addEvent( "delChar", true)
addEventHandler( "delChar", localPlayer, delChar)