Jump to content

SinaAmp

Members
  • Posts

    94
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

SinaAmp's Achievements

Punk-@ss B*tch

Punk-@ss B*tch (12/54)

18

Reputation

  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
×
×
  • Create New...