Anubhav Posted October 6, 2014 Posted October 6, 2014 (edited) addCommandHandler("gostaff", function(plr) local staffName = dbPoll(dbQuery(adminDB, "SELECT * FROM staffList WHERE staff=?", getAccountName(getPlayerAccount(plr))), -1) if (not (#staffName == 0)) then local staffNamer = dbPoll(dbQuery(adminDB, "SELECT * FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))), -1) if #staffNamer ~= 0 then dbExec(adminDB, "DELETE FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))) end local acc, x, y, z, skin, dim, inte = getAccountName(getPlayerAccount(plr)), getElementPosition(plr), getElementModel(plr), getElementDimension(plr), getElementInterior(plr) local r, g, b = getTeamColor(getTeamFromName("Army")) setPlayerNametagColor(plr, r, g, b) setPlayerTeam(plr, getTeamFromName("Army")) setElementModel(plr, 217) setElementData(plr, "isPlayerStaff", true) setElementData(plr, "Occupation", "Staff") outputChatBox("You're now on duty!", plr, 225, 225, 225) exports.killmessages:outputMessage(getPlayerName(plr).." is now on-staff-duty!", root, 0, 255, 0) local t = getTeamName(getPlayerTeam(plr)) dbExec(adminDB, "INSERT INTO adminSaver VALUES(?,?,?,?,?,?,?,?)", acc, x, y, z, skin, dim, inte, tostring(t)) else return end end ) I used this no errors. Now I select it again. addCommandHandler("offduty", function(plr) if getElementData(plr, "isPlayerStaff") then local answer = dbPoll(dbQuery(adminDB,"SELECT * FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))), -1) if #answer ~= 0 then fadeCamera( plr, false, 1.0, 0, 0, 0 ) setTimer(fadeCamera, 5000, 1, plr, true ) for k,v in ipairs(answer) do setTimer(spawnPlayer, 5000, 1, plr, v.x, v.y, v.z, 0, v.skin, 0, 0, getTeamFromName(v.teamName or nil) ) end outputChatBox("Now you are off-duty!", plr) exports.killmessages:outputMessage(getPlayerName(plr).." is now off-staff-duty!", root, 0, 255, 0) setElementData(plr, "isPlayerStaff", false) dbExec(adminDB, "DELETE FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))) end end end ) No errors, keeps spawning me at same position even If I take another and use /gostaff! Help! Edited October 7, 2014 by Guest
DeVo Posted October 6, 2014 Posted October 6, 2014 addCommandHandler("offduty", function(plr) if getElementData(plr, "isPlayerStaff") then local answer = dbPoll(dbQuery(adminDB,"SELECT * FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))), -1) if #answer ~= 0 then fadeCamera( plr, false, 1.0, 0, 0, 0 ) setTimer(fadeCamera, 5000, 1, plr, true ) for k,v in ipairs(answer) do setTimer(setElementPosition, 5000, 1, plr, tonumber(v.x), tonumber(v.y), tonumber(v.z) ) setElementModel(plr, tonumber(v.skin) ) setPlayerTeam(plr,getTeamFromName(tostring(v.teamName) or nil)) end outputChatBox("Now you are off-duty!", plr) exports.killmessages:outputMessage(getPlayerName(plr).." is now off-duty staff!", root, 0, 255, 0) setElementData(plr, "isPlayerStaff", false) dbExec(adminDB, "DELETE FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))) end end end )
xXMADEXx Posted October 6, 2014 Posted October 6, 2014 You got the syntax wrong for inserting. dbExec(adminDB, "INSERT INTO adminSaver VALUES(?,?,?,?,?,?,?,?)", acc, x, y, z, skin, dim, inte, tostring(t)) It should be something like this: dbExec(adminDB, "INSERT INTO adminSaver (acc, x, y, z, skin, dim, inte, team) VALUES(?,?,?,?,?,?,?,?)", acc, x, y, z, skin, dim, inte, tostring(t)) (I don't know what your column names are so you'll probably need to rename them.) And also make sure that adminDB is defined.
Anubhav Posted October 7, 2014 Author Posted October 7, 2014 None is helping? What happend no SQL masters? Sad to hear this. I realy need to solve it out fast! There is none who can support me in SQL? Help help!
pa3ck Posted October 7, 2014 Posted October 7, 2014 You got the syntax wrong for inserting. dbExec(adminDB, "INSERT INTO adminSaver VALUES(?,?,?,?,?,?,?,?)", acc, x, y, z, skin, dim, inte, tostring(t)) It should be something like this: dbExec(adminDB, "INSERT INTO adminSaver (acc, x, y, z, skin, dim, inte, team) VALUES(?,?,?,?,?,?,?,?)", acc, x, y, z, skin, dim, inte, tostring(t)) (I don't know what your column names are so you'll probably need to rename them.) And also make sure that adminDB is defined. I think you should actually use "UPDATE" instead of trying to "INSERT" it again...
Anubhav Posted October 7, 2014 Author Posted October 7, 2014 I already delete it! addCommandHandler("gostaff", function(plr) local staffName = dbPoll(dbQuery(adminDB, "SELECT * FROM staffList WHERE staff=?", getAccountName(getPlayerAccount(plr))), -1) if (not (#staffName == 0)) then local staffNamer = dbPoll(dbQuery(adminDB, "SELECT * FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))), -1) if #staffNamer ~= 0 then dbExec(adminDB, "DELETE FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))) end local acc, x, y, z, skin, dim, inte = getAccountName(getPlayerAccount(plr)), getElementPosition(plr), getElementModel(plr), getElementDimension(plr), getElementInterior(plr) local r, g, b = getTeamColor(getTeamFromName("Army")) setPlayerNametagColor(plr, r, g, b) setPlayerTeam(plr, getTeamFromName("Army")) setElementModel(plr, 217) setElementData(plr, "isPlayerStaff", true) setElementData(plr, "Occupation", "Staff") outputChatBox("You're now on duty!", plr, 225, 225, 225) exports.killmessages:outputMessage(getPlayerName(plr).." is now on-staff-duty!", root, 0, 255, 0) local t = getTeamName(getPlayerTeam(plr)) dbExec(adminDB, "INSERT INTO adminSaver (acc, x, y, z, skin, dimension, interior, teamName) VALUES(?,?,?,?,?,?,?,?)", tostring(acc), tonumber(x), tonumber(y), tonumber(z), tonumber(skin), tonumber(dim), tonumber(inte), tostring(t)) else return end end ) addCommandHandler("offduty", function(plr) if getElementData(plr, "isPlayerStaff") then local answer = dbPoll(dbQuery(adminDB,"SELECT * FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))), -1) if #answer ~= 0 then fadeCamera( plr, false, 1.0, 0, 0, 0 ) setTimer(fadeCamera, 5000, 1, plr, true ) for k,v in ipairs(answer) do setTimer(setElementPosition, 5000, 1, plr, tonumber(v.x), tonumber(v.y), tonumber(v.z) ) setElementModel(plr, tonumber(v.skin) ) setPlayerTeam(plr,getTeamFromName(tostring(v.teamName) or nil)) end outputChatBox("Now you are off-duty!", plr) exports.killmessages:outputMessage(getPlayerName(plr).." is now off-duty staff!", root, 0, 255, 0) setElementData(plr, "isPlayerStaff", false) dbExec(adminDB, "DELETE FROM adminSaver WHERE acc=?", getAccountName(getPlayerAccount(plr))) end end end )
pa3ck Posted October 7, 2014 Posted October 7, 2014 Ah yea, I see it now. It doesn`t get saved, right? That`s your problem? ( You probably checked your table, I assume... )
Anubhav Posted October 7, 2014 Author Posted October 7, 2014 Nothing gets saved! X,Y,Z spawning at one position everytime~!
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