Jump to content

SinaAmp

Members
  • Posts

    94
  • Joined

  • Last visited

Everything posted by SinaAmp

  1. after disconnecting from server i got these errors i think it's for wrog argument for onplayerquit: line 55: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got string 'Quit'] line 59: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] line 60: Bad argument @ 'getElementData' [Expected element at argument 1, got string 'Quit'] line 61: Bad argument @ 'getElementData' [Expected element at argument 1, got string 'Quit'] these top issues fixed bu i still got this error after quit from server: dbExec failed; (1205) Lock wait timeout exceeded; try restarting transaction
  2. hello i think more of the sql tutorials here is outdated if you want to create database you can use xammp or mysql workspace also you must read wiki this parts
  3. @IIYAMA @The_GTA i think it's impossible to complete this metode with set and get elemnt isn'n better to use one variable instead of using get,set element?
  4. every thing works fine till i quit the server i got dbExec failed; (1205) Lock wait timeout exceeded; try restarting transaction my thirst works fine but Hunger is still stuck at 100
  5. i got expected end at line 87 for line 37 after this error added that missing end and i got another error dbexec failed and i got another error in my client side code attemt to compare nil with number my client code: function checkHunger() local hunger = tonumber(getElementData(localPlayer, "hunger")) if hunger and hunger > 0 then setElementData(localPlayer, "hunger", hunger - 1) end if hunger <= 20 then outputChatBox("You need to feed as fast as possible.", 255, 0, 0) playSoundFrontEnd(40) end if hunger == 0 then if not isPedDead(localPlayer) then local hp = getElementHealth(localPlayer) setElementHealth(localPlayer, hp - 30) end end end setTimer(checkHunger, 60000, 0) -- configure a time function onClientPlayerSpawn() setElementData(source, "hunger", 100) end addEventHandler("onClientPlayerSpawn", root, onClientPlayerSpawn) function checkThirst() local Thirst = tonumber(getElementData(localPlayer, "Thirst")) if Thirst and Thirst > 0 then setElementData(localPlayer, "Thirst", Thirst - 1) end if Thirst <= 20 then outputChatBox("You need to drink something as fast as possible.", 255, 0, 0) playSoundFrontEnd(40) end if Thirst == 0 then if not isPedDead(localPlayer) then local hp = getElementHealth(localPlayer) setElementHealth(localPlayer, hp - 30) end end end setTimer(checkThirst, 60000, 0) -- configure a time function onClientPlayerSpawn() setElementData(source, "Thirst", 100) end addEventHandler("onClientPlayerSpawn", root, onClientPlayerSpawn)
  6. i got this error: sourceS.lua:59: Bad argument @ 'getAccountName' [Expected account at argument 1, got nil]
  7. i edited the code but i got this two errors: 1- attempt to index field '?' (a nil value) 2- Bad argument @ 'getAccountName' [Expected account at argument 1, got nil] please review my code @Burak5312 i commented the error line
  8. hello guys i working on hunger and thirst system. i can save and get data with get and setaccountdata but when i try to change the saving way to mysql i got errors here is my script: also i have clinet side script but that not needed
  9. hello bro @Burak5312 again me ? i want to save player health after player quit but nothing change in database function phealth (_,account) local AccName = getAccountName(account) local playerhealth = getElementHealth(source) dbExec(db,"UPDATE stats SET Health=? WHERE Account=?",playerhealth, AccName) end addEventHandler("onplayerQuit", root, phealth)
  10. i know but that store a negative number in database that might be like this in takemoney cmd condition: targetMoney = amount - targetMoney
  11. @Burak5312 thank you bro but in this line of code i think we need to subtract amount from targetmoney. isn't it? targetMoney = targetMoney - amount
  12. @Burak5312can you give me a final edit? cuse i added your script and amount not saved in database
  13. do you mean clculate that in dbexec parameter? @Derbo thank you bro @Burak5312 i fixed that before: but i want to change money of the offline players and now i working on that
  14. thank you @Derbo but im searching for the way to change offline players money too in database
  15. Hello guys I want to give and take money from a specific player and update database data for that player using command i wrote my script but that give money only to me here is my script: function moneyCmd(player, commandName, AccName, amount) if(getElementType(player) ~= "player") then return end pacc = getPlayerAccount (player) AccName = getAccountName (pacc) if isObjectInACLGroup ("user."..AccName, aclGetGroup ( "Moderator" ) ) then -- the shared logic if commandName == "givemoney" then amount = tonumber(amount) if tostring(AccName) and amount then local PMoney = givePlayerMoney(player, amount) dbExec(db,"UPDATE stats SET Money=? WHERE Account=?",PMoney,AccName) else outputChatBox("[usage] /givemoney [playername] [amount]", player) end else if commandName == "takemoney" then amount = tonumber(amount) if tostring(AccName) and amount then takePlayerMoney(player, amount) dbExec(db,"UPDATE stats SET Money=? WHERE Account=?",PMoney,AccName) else outputChatBox("[usage] /takemoney [playername] [amount]", player) end else outputChatBox("kolan ridi", player) end end else outputChatBox("You aren't able to use this command", player) end end addCommandHandler("givemoney", moneyCmd); addCommandHandler("takemoney", moneyCmd);
  16. thank you bro also i worked on another way and that worked too but not trust able ? function getpaccount (_,account) local AccName = getAccountName(account) local AccData = dbPoll(dbQuery(db,"SELECT ID,Account FROM stats"), -1) if(isGuestAccount(account)) then return end if (AccData) then if not getAccountData(account, "FirstTime") then setAccountData(account, "FirstTime", true) local ID = getFreeID() local SetData = dbExec(db,"INSERT INTO stats (ID,Account) VALUES (?, ?)",ID, AccName) else return end end end addEventHandler("onPlayerLogin",root, getpaccount)
  17. hello guys again I'd like to save player account names in the database only once and prevent duplicate new rows, but when I try to compare player account names with saved names in the database, I get "attempt to index field '?/ nil value" I know I don't have any data in the database that causes this error, but I want to prevent the player who saved his data before from adding new row again function getpaccount (_,account) local AccName = getAccountName(account) local AccData = dbPoll(dbQuery(db,"SELECT ID,Account FROM stats"), -1) if(isGuestAccount(account)) then return end if (AccData) then if (AccData[2].Account == tostring(AccName)) then return false else local ID = getFreeID() local SetData = dbExec(db,"INSERT INTO stats (ID,Account) VALUES (?, ?)",ID, AccName) end end end addEventHandler("onPlayerLogin",root, getpaccount) @Burak5312
  18. hi send your connection script
  19. @IIYAMA Thank you I mean database table
  20. thank you for help bro @IIYAMA do you know is it better to create table for every resource Separately or set most of the data's in one table for performance?
  21. Thank you @IIYAMA for explinition isn't my script is to much? i want to add more markers but i need to copy paste this code for every marker
×
×
  • Create New...