WASSIm. Posted July 16, 2013 Share Posted July 16, 2013 slm lolad wa romdhankom mabrok. 3andi server fih problem mi5adamch il function hadhoma: dbConnect dbExec dbQuery dbPoll dbFree kol mara yatla3li bi error Link to comment
S4MuEL Posted July 20, 2013 Share Posted July 20, 2013 el topic 3andou 4 jours .. w7atta 7ad la3awnék : p nans7ék témchi ll bord : scripting .. médém l7kéya fiha sql Link to comment
Baseplate Posted July 20, 2013 Share Posted July 20, 2013 ena manefhemech barcha fel SQL heka 3leh majawebtech... Link to comment
Sparrow Posted July 20, 2013 Share Posted July 20, 2013 hhhh, ena adhoukom man5dmch behom jemla, mana3rch ech ynaykou asl Link to comment
Baseplate Posted July 20, 2013 Share Posted July 20, 2013 na3ref, w enti lsenek atwel men zebek. Link to comment
S4MuEL Posted July 21, 2013 Share Posted July 21, 2013 ena manefhemech barcha fel SQL heka 3leh majawebtech... np Link to comment
WASSIm. Posted July 21, 2013 Author Share Posted July 21, 2013 el topic 3andou 4 jours .. w7atta 7ad la3awnék : pnans7ék témchi ll bord : scripting .. médém l7kéya fiha sql ena nji lil honi ken ki yabda 3andi problem moch moham barcha wala 3andi script masro9 hhhh, ena adhoukom man5dmch behom jemla, mana3rch ech ynaykou asl hadhokma kima executeSQLQuery ma yalzmek tast3ml il dbConnect wa hadhi yast3mlouha chi iconncti 3ala file sqlite wala server mysql a3awka tawa ar9a il exmple balahi tnajam trigli hadhi ? a3ika mafihach db Datebase query failed: no such table: user_data attempt to index local 'gangresult' (a boolean value) function firstTime() executeSQLQuery("CREATE TABLE IF NOT EXISTS newgangdb (gangname TEXT, money NUMERIC, hometext TEXT, inviteperm NUMERIC, motdperm NUMERIC, kickperm NUMERIC, levelperm NUMERIC, warnperm NUMERIC, depositperm NUMERIC, withdrawperm NUMERIC, deleteperm NUMERIC);") end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), firstTime) function gangCreate(player, commandname, gangname, ...) if arg.n == 0 and gangname then local playeraccount = getPlayerAccount(player) local gangresult = executeSQLQuery ( "SELECT `gang` FROM `user_data` WHERE `username` = ?", playeraccount ) local isingang = gangresult[1].gang if ( isingang == "false" ) then local existingGangsWithName = executeSQLQuery("SELECT * FROM `newgangdb` WHERE `gangname` = ?", gangname) if not existingGangsWithName[1] then executeSQLQuery("INSERT INTO newgangdb VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", gangname, 0, "Default home screen text, change me using the button below!", 5, 5, 5, 5, 5, 0, 5, 5) executeSQLQuery("UPDATE `user_data` SET `gang`=? WHERE `username`=?", gangname, playeraccount ) local dbName = "newgang_" .. gangname .. "_members" executeSQLQuery("CREATE TABLE ? (accountname TEXT, lastname TEXT, lastlogin NUMERIC, warnings NUMERIC, level NUMERIC)", dbName ) local realTime = getRealTime() local timestamp = realTime.year + 1900 .. "-" .. realTime.month + 1 .. "-" .. realTime.monthday executeSQLQuery("INSERT INTO ? VALUES(?, ?, ?, ?, ?)", dbName, getAccountName(playerAccount), getPlayerName(player), timestamp, 0, 5) setAccountData(playerAccount, "gang", gangname) outputChatBox("**INFO: "..getPlayerName(player).." is now in "..gangname.." **") outputChatBox("Gang successfully created. Use /gang for gangpanel.", player, 0, 255, 0) else outputChatBox("A gang with this name already exists.", player, 255, 0, 0) end else outputChatBox("You must leave your current gang to create a new one.", player, 255, 0, 0) end else outputChatBox("Invalid arguments. Gang name can't contain spaces.", player, 255, 0, 0) end end addCommandHandler("create", gangCreate) function gangPanel(player) local playeraccount = getPlayerAccount(player) local gangresult = executeSQLQuery ( "SELECT `gang` FROM `user_data` WHERE `username` = ?", playeraccount ) local isingang = gangresult[1].gang if isingang then triggerClientEvent(player, "displayPanel", player) populateGangPanel(player) else outputChatBox("* INFO: You are not in a Gang type /create to create a gang *",player,255,0,0) end end addCommandHandler("gang", gangPanel) addCommandHandler("squad", gangPanel) addCommandHandler("company", gangPanel) function populateGangPanel(player) --local playerAccount = getPlayerAccount(player) --local gangname = getAccountData(playerAccount, "gang") local playeraccount = getPlayerAccount(player) local gangnameresult = executeSQLQuery ( "SELECT `gang` FROM `user_data` WHERE `username` = ?", playeraccount ) local gangname = gangnameresult[1].gang local dbName = "newgang_" .. gangname .. "_members" local ganginfo = executeSQLQuery("SELECT * FROM `newgangdb` WHERE `gangname` = ?", gangname) local memberinfo = executeSQLQuery("SELECT * FROM ?", dbName) triggerClientEvent(player, "populatePanel", player, ganginfo[1], memberinfo, getAccountName(getPlayerAccount(player))) end function getPlayerLevel(player) local playeraccount = getPlayerAccount(player) local gangnameresult = executeSQLQuery ( "SELECT `gang` FROM `user_data` WHERE `username` = ?", playeraccount ) local gangname = gangnameresult[1].gang if gangname then local dbName = "newgang_" .. gangname .. "_members" local playerinfo = executeSQLQuery("SELECT * FROM ? WHERE `accountname` = ?", dbName, playerAccountName) return playerinfo[1]["level"] else return false end end function getPlayerGang(player) local playeraccount = getPlayerAccount(player) local gangnameresult = executeSQLQuery ( "SELECT `gang` FROM `user_data` WHERE `username` = ?", playeraccount ) local gangname = gangnameresult[1].gang return gangname end function getGangInfo(gangname) local ganginfo = executeSQLQuery("SELECT * FROM `newgangdb` WHERE `gangname` = ?", gangname) if ganginfo[1] then return ganginfo[1] else return false end end -- ALL THE HANDLER FUNCTIONS ARE HERE! function saveMOTD(motd) if getPlayerGang(source) then local ganginfo = getGangInfo(getPlayerGang(source)) local playerlevel = getPlayerLevel(source) if playerlevel >= tonumber(ganginfo['motdperm']) then executeSQLQuery("UPDATE `newgangdb` SET `hometext` = ? WHERE `gangname` = ?",motd, getPlayerGang(source)) populateGangPanel(source) end end end addEvent("_saveMOTD", true) addEventHandler("_saveMOTD", getRootElement(), saveMOTD) function levelPlayer(accountname) if getPlayerGang(source) then local ganginfo = getGangInfo(getPlayerGang(source)) local playerlevel = getPlayerLevel(source) if playerlevel >= tonumber(ganginfo['levelperm']) then local dbName = "newgang_" .. ganginfo['gangname'] .. "_members" local playerTo = executeSQLQuery("SELECT * FROM ? WHERE `accountname`=?", dbName, accountname) if playerTo[1] then if playerlevel > (tonumber(playerTo[1]['level']) + 1) and tonumber(playerTo[1]['level']) < 5 then local newlevel = tonumber(playerTo[1]['level']) + 1 executeSQLQuery("UPDATE ? SET `level` = ? WHERE `accountname` = ?", dbName, newlevel, accountname) populateGangPanel(source) else triggerClientEvent(source, "errorDisplay", source, "Error: You can't touch players equal to/over your level.") end else triggerClientEvent(source, "errorDisplay", source, "Error: Can not find player.") populateGangPanel(source) end end end end addEvent("_levelPlayer", true) addEventHandler("_levelPlayer", getRootElement(), levelPlayer) function unlevelPlayer(accountname) if getPlayerGang(source) then local ganginfo = getGangInfo(getPlayerGang(source)) local playerlevel = getPlayerLevel(source) if playerlevel >= tonumber(ganginfo['levelperm']) then local dbName = "newgang_" .. ganginfo['gangname'] .. "_members" local playerTo = executeSQLQuery("SELECT * FROM ? WHERE `accountname`=?", dbName, accountname) if playerTo[1] then if playerlevel > tonumber(playerTo[1]['level']) and tonumber(playerTo[1]['level']) > 0 then local newlevel = tonumber(playerTo[1]['level']) - 1 executeSQLQuery("UPDATE ? SET `level` = ? WHERE `accountname` = ?", dbName, newlevel, accountname) populateGangPanel(source) else triggerClientEvent(source, "errorDisplay", source, "Error: You can't touch players equal to/over your level.") end else triggerClientEvent(source, "errorDisplay", source, "Error: Can not find player.") populateGangPanel(source) end end end end addEvent("_unlevelPlayer", true) addEventHandler("_unlevelPlayer", getRootElement(), unlevelPlayer) function warnPlayer(accountname) if getPlayerGang(source) then local ganginfo = getGangInfo(getPlayerGang(source)) local playerlevel = getPlayerLevel(source) if playerlevel >= tonumber(ganginfo['levelperm']) then local dbName = "newgang_" .. ganginfo['gangname'] .. "_members" local playerTo = executeSQLQuery("SELECT * FROM ? WHERE `accountname`=?", dbName, accountname) if playerTo[1] then if playerlevel > tonumber(playerTo[1]['level']) and tonumber(playerTo[1]['warnings']) < 5 then local newwarn = tonumber(playerTo[1]['warnings']) + 1 executeSQLQuery("UPDATE ? SET `warnings` = ? WHERE `accountname` = ?", dbName, newwarn, accountname) populateGangPanel(source) else triggerClientEvent(source, "errorDisplay", source, "Error: You can't touch players equal to/over your level.") end else triggerClientEvent(source, "errorDisplay", source, "Error: Can not find player.") populateGangPanel(source) end end end end addEvent("_warnPlayer", true) addEventHandler("_warnPlayer", getRootElement(), warnPlayer) function unwarnPlayer(accountname) if getPlayerGang(source) then local ganginfo = getGangInfo(getPlayerGang(source)) local playerlevel = getPlayerLevel(source) if playerlevel >= tonumber(ganginfo['levelperm']) then local dbName = "newgang_" .. ganginfo['gangname'] .. "_members" local playerTo = executeSQLQuery("SELECT * FROM ? WHERE `accountname`=?", dbName, accountname) if playerTo[1] then if playerlevel > (tonumber(playerTo[1]['level'])) and tonumber(playerTo[1]['warnings']) > 0 then local newwarn = tonumber(playerTo[1]['warnings']) - 1 executeSQLQuery("UPDATE ? SET `warnings` = ? WHERE `accountname` = ?", dbName, newwarn, accountname) populateGangPanel(source) else triggerClientEvent(source, "errorDisplay", source, "Error: You can't touch players equal to/over your level.") end else triggerClientEvent(source, "errorDisplay", source, "Error: Can not find player.") populateGangPanel(source) end end end end addEvent("_unwarnPlayer", true) addEventHandler("_unwarnPlayer", getRootElement(), unwarnPlayer) function depositMoney(money) if tonumber(money) > 0 then if getPlayerGang(source) then local ganginfo = getGangInfo(getPlayerGang(source)) local playerlevel = getPlayerLevel(source) if playerlevel >= tonumber(ganginfo['depositperm']) then local newmoney = tonumber(ganginfo['money']) + tonumber(money) if getPlayerMoney(source) >= tonumber(money) then executeSQLQuery("UPDATE `newgangdb` SET `money` = ? WHERE `gangname` = ?", newmoney, getPlayerGang(source)) takePlayerMoney(source, tonumber(money)) populateGangPanel(source) else triggerClientEvent(source, "errorDisplay", source, "Error: You don't have enough money.") populateGangPanel(source) end end end end end addEvent("_depositMoney", true) addEventHandler("_depositMoney", getRootElement(), depositMoney) function withdrawMoney(money) if tonumber(money) > 0 then if getPlayerGang(source) then local ganginfo = getGangInfo(getPlayerGang(source)) local playerlevel = getPlayerLevel(source) if playerlevel >= tonumber(ganginfo['withdrawperm']) then local newmoney = tonumber(ganginfo['money']) - tonumber(money) if tonumber(ganginfo['money']) >= tonumber(money) then executeSQLQuery("UPDATE `newgangdb` SET `money` = ? WHERE `gangname` = ?", newmoney, getPlayerGang(source)) givePlayerMoney(source, tonumber(money)) populateGangPanel(source) Link to comment
Sparrow Posted July 21, 2013 Share Posted July 21, 2013 line 9: local gangresult = executeSQLQuery ( "SELECT `gang` FROM `user_data` WHERE `username` = ?", playeraccount ) el table 'user_data' mahouch mawjoud fel registry.db Link to comment
WASSIm. Posted July 22, 2013 Author Share Posted July 22, 2013 line 9: local gangresult = executeSQLQuery ( "SELECT `gang` FROM `user_data` WHERE `username` = ?", playeraccount ) el table 'user_data' mahouch mawjoud fel registry.db balahi tnajam ta3mlheli ? 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