Jump to content

SinaAmp

Members
  • Posts

    94
  • Joined

  • Last visited

Everything posted by SinaAmp

  1. hello guys i want to use this library but when i use fore example this: dbify.mysql.table.isValid(tableName, callback(result, arguments) print(tostring(result)) print(toJSON(arguments)) end, ...) i got expected ) error
  2. How i can get the player account name in custom event? everything i try i got nil errors
  3. Test this: commands "jumpc" and "cancelj" function jumpKey() if not isPedInVehicle(localPlayer) then return end local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle and getVehicleController(vehicle) == localPlayer then local vehType = getVehicleType(vehicle) if vehType == "Plane" or vehType == "Helicopter" then return end local sx, sy, sz = getElementVelocity(vehicle) setElementVelocity(vehicle, sx, sy, sz + 2) end end addCommandHandler("jumpc",jumpKey) function cjumpKey() if not isPedInVehicle(localPlayer) then return end local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle and getVehicleController(vehicle) == localPlayer then local vehType = getVehicleType(vehicle) if vehType == "Plane" or vehType == "Helicopter" then return end local sx, sy, sz = getElementVelocity(vehicle) local px, py, pz = getElementPosition(vehicle) setElementPosition(vehicle,px,py,35.33) end end addCommandHandler("cancelj",cjumpKey)
  4. try this: function jumpKey() if not isPedInVehicle(localPlayer) then return end local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle and getVehicleController(vehicle) == localPlayer then local vehType = getVehicleType(vehicle) if vehType == "Plane" or vehType == "Helicopter" then return end local sx, sy, sz = getElementVelocity(vehicle) setElementVelocity(vehicle, sx, sy, sz + 0.33) end end addCommandHandler("jumpc",jumpKey)
  5. im little bit confused to be honest this is out of my lua abilitys i need somone to complete this so i can learn the way
  6. sorry i wasted your time @IIYAMAthank you for help addEventHandler("onPlayerResourceStart", root, function(hungerandthirst) if loadedResource == resource then triggerClientEvent(source, "onGetData", resourceRoot,PHunger) end end) @Burak5312 bro can you complete this part?
  7. edited server side: but i got this error: server triggered client side event but event is not added
  8. i got this error repeatly Database result uncollected after 5 minutes. [Query: SELECT Hunger,Thirst FROM stats WHERE Account IN ( NULL, )]
  9. why i need to get hunger and thirst in 'checkhunger' function when i got them from 'afterlogin' function?
  10. sorry @IIYAMA i can't understand why should i use triggerClientEvent in server side when i use your library and calc hunger and thirst in server side i dont know how to get my processed hunger and thirst from server side please look at this: server: client:
  11. @IIYAMA i tryed to do this method can you please review my code i commented near the lines i had problem [ -- this ] server: function AccDatacallback(AccData, player, account, AccName) local result = dbPoll( AccData, 0 ) if(result) then if(#result > 0) then for _,row in ipairs(result) do local Hunger = row["Hunger"] local Thirst = row["Thirst"] break end end end end function afterlogin (_,Acc) local AccName = getAccountName(Acc) dbQuery(AccDatacallback,{source, account, AccName},db,"SELECT Hunger,Thirst FROM stats WHERE Account=?", AccName) end addEventHandler ("onPlayerLogin",root, afterlogin) -- function to send hunger and thirst to client for process function sendhsdata (_, Acc, Hunger ,Thirst) -- ***this*** local AccName = getAccountName(Acc) local hsdata = dbPoll(dbQuery(db,"SELECT Hunger,Thirst FROM stats WHERE Account=?", AccName), -1) local Hunger = hsdata["Hunger"] -- ***this*** local Thirst = hsdata["Thirst"] -- ***this*** end addEvent( "onSendData", true ) -- ***this*** addEventHandler( "onSendData", root, sendhsdata) -- ***this*** -- Data saving function function saveAccountData (player) local playerAccount = getPlayerAccount(player) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local AccName = getAccountName(playerAccount) local Hungers = triggerClientEvent(player, "onSendPData", playersource, PHunger) -- ***this*** local Thirsts = triggerClientEvent(player, "onSendPData", playersource, PThirst) -- ***this*** dbExec(db,"UPDATE stats SET Hunger=?, Thirst=? WHERE Account=?",Hungers, Thirsts, AccName) end addEventHandler ( 'onPlayerQuit', root, function ( ) saveAccountData(source) end ) client: function checkHunger(PHunger) local Hunger = triggerServerEvent("onSendData", resourceRoot, Hunger) -- ***this*** if Hunger and Hunger >= 0 then PHunger = Hunger - 1 -- ***this*** 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) addEvent( "onSendPHData", true ) -- ***this*** addEventHandler( "onSendPHData", localPlayer, checkHunger ) -- ***this*** function onClientPlayerSpawn() setElementData(source, "Hunger", 100) end addEventHandler("onClientPlayerSpawn", root, onClientPlayerSpawn) function checkThirst(PThirst) -- ***this*** local Thirst = triggerServerEvent("onSendData", resourceRoot, Thirst) -- ***this*** if Thirst and Thirst >= 0 then PThirst = Thirst - 1 -- ***this*** 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) addEvent( "onSendPTData", true ) -- ***this*** addEventHandler( "onSendPTData", localPlayer, checkThirst ) -- ***this*** function onClientPlayerSpawn() setElementData(source, "Thirst", 100) end addEventHandler("onClientPlayerSpawn", root, onClientPlayerSpawn)
  12. @IIYAMA sorry for late response i think my way of creating hunger and thirst system with get/setelementdata is complatly wrong and that cause of performance issues in future may i use only triggerevents and a variable to process
  13. Thank you @IIYAMA I get element data from client side which is static for setting up timer Isn't that cause of the problem?
  14. sorry @IIYAMA but i still got dbExec failed; (1205) Lock wait timeout exceeded; try restarting transaction i had 15 dbexec in my resources. 3 of them must work after player logout when i decrease them (dbexec's) by stop one of the resources. after that i hadn't this issue but when 3 of them work's together i got that error aslo i added the callback for all of my dbquerys maybe that's for timing issue in my hunger and thirst system i think in this code dbexec doesn't get data from Hungers and thirsts variables
  15. For this line: if AccData and #AccData > 0 then return end i got this error: attempt to get length of local 'AccData' (a userdata value)
  16. nothing changed still got that error my issue is server freeze but i cant understand whats going on in dbpool
  17. i solved the problem with using callback for must of them but some of them when i use callback get attempt to call global ' ' nil value like this code:
  18. oh i found whats wrong i had too many update requests after onplayerquit in another resources after i stoped another resources with db update in their code my problem was solved but i need to use db update in my another resources thank you bro maybe @IIYAMA can help
×
×
  • Create New...