
βurak
Members-
Posts
375 -
Joined
-
Last visited
-
Days Won
22
Everything posted by βurak
-
I'm not sure but can you remove LIMIT 1 for hunger? local AccData = dbPoll(dbQuery(db,"SELECT Hunger,Thirst FROM stats WHERE Account=? LIMIT 1", AccName), -1) local AccData = dbPoll(dbQuery(db,"SELECT Hunger,Thirst FROM stats WHERE Account=?", AccName), -1)
-
can you try this again what's the problem on the client side? addEventHandler ("onPlayerLogin",root,function(_,Acc) local AccName = getAccountName(Acc) local AccData = dbPoll(dbQuery(db,"SELECT Hunger,Thirst FROM stats WHERE Account=? LIMIT 1", AccName), -1) if(AccData) then if(#AccData > 0) then for _,row in ipairs(AccData) do setElementData (source,"hunger",row["Hunger"]) setElementData(source, "Thirst", row["Thirst"]) break end end end end) function loadAccountData(player) local playerAccount = getPlayerAccount(player) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local AccName = getAccountName(playerAccount) local AccData = dbPoll(dbQuery(db,"SELECT Hunger,Thirst FROM stats WHERE Account=? LIMIT 1", AccName), -1) if(AccData) then if(#AccData > 0) then for _,row in ipairs(AccData) do setElementData (player,"hunger",row["Hunger"]) setElementData(player, "Thirst", row["Thirst"]) break end end end end function saveAccountData (player) local playerAccount = getPlayerAccount(player) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local AccName = getAccountName(playerAccount) local Hungers = getElementData (player,"hunger") local Thirsts = getElementData (player,"Thirst") dbExec(db,"UPDATE stats SET Hunger=?, Thirst=? WHERE Account=?",Hungers, Thirsts, AccName) end addEventHandler ( 'onPlayerQuit', root, function ( ) saveAccountData(source) end ) addEventHandler( "onResourceStart", resourceRoot, function( ) for _, plr in pairs( getElementsByType("player")) do loadAccountData(plr) end end) addEventHandler ("onResourceStop", resourceRoot, function() for index,players in ipairs(getElementsByType("player")) do saveAccountData(players) end end)
-
edited code
-
can you try this addEventHandler ("onPlayerLogin",root,function(_,Acc) local AccName = getAccountName(Acc) local AccData = dbPoll(dbQuery(db,"SELECT Hunger,Thirst FROM stats WHERE Account=? LIMIT 1", AccName), -1) if(AccData) then if(#AccData > 0) then for _,row in ipairs(AccData) do setElementData (source,"hunger",row["Hunger"]) setElementData(source, "Thirst", row["Thirst"]) break end end end end) function loadAccountData(player) local playerAccount = getPlayerAccount(player) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local AccName = getAccountName(playerAccount) local AccData = dbPoll(dbQuery(db,"SELECT Hunger,Thirst FROM stats WHERE Account=? LIMIT 1", AccName), -1) if(AccData) then if(#AccData > 0) then for _,row in ipairs(AccData) do setElementData (player,"hunger",row["Hunger"]) setElementData(player, "Thirst", row["Thirst"]) break end end end function saveAccountData (player) local playerAccount = getPlayerAccount(player) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local AccName = getAccountName(playerAccount) local Hungers = getElementData (player,"hunger") local Thirsts = getElementData (player,"Thirst") dbExec(db,"UPDATE stats SET Hunger=?, Thirst=? WHERE Account=?",Hungers, Thirsts, AccName) end addEventHandler ( 'onPlayerQuit', root, function ( ) saveAccountData(source) end ) addEventHandler( "onResourceStart", resourceRoot, function( ) for _, plr in pairs( getElementsByType("player")) do loadAccountData(plr) end end) addEventHandler ("onResourceStop", resourceRoot, function() for index,players in ipairs(getElementsByType("player")) do saveAccountData(players) end end)
-
You can use the previous examples for this, add 2 more rows to the database and get the information with select queries. You can use the update command to change it.
-
can you try this function tpTienda1( player, key, keyState ) setCameraTarget ( player ) fadeCamera(player, false) ------fade camera in black setElementInterior( player, 18 ) setElementPosition( player, -30.906, -90.749, 1003.547 ) setTimer(function(player) if(isElement(player)) then fadeCamera(player, true) --Turn off completely after 2 seconds end end, 2000, 1, player) unbindKey (player, "f", "down", tpTienda1) --triggerClientEvent(player, "camaranormal", player) --actually no need this end
-
Do you want to send data from client side to server side? Or do you want to trigger the event on the server side and load the player's data?
-
this issue will not work if done before spawning player using spawnPlayer function so make sure the player spawn example: addEventHandler("onPlayerJoin", root, function() setElementModel(source, 10) --will not work because the player did not spawn spawnPlayer(source, 0, 0, 3) end ) addEventHandler("onPlayerJoin", root, function() spawnPlayer(source, 0, 0, 3) setElementModel(source, 10) --it will work end )
-
no problem ?
-
function phealth () -- onPlayerQuit event does not keep accounts local playerAccount = getPlayerAccount(source) if (playerAccount) then if(isGuestAccount(playerAccount)) then return end -- if guest account don't continue end local AccName = getAccountName(playerAccount) local playerhealth = getElementHealth(source) dbExec(db,"UPDATE stats SET Health=? WHERE Account=?",playerhealth, AccName) end addEventHandler("onPlayerQuit", root, phealth) --there is a typo here
-
okey your welcome ?
-
Does this player work even though he has money? this can happen if the amount you entered is more than the player's money maybe you can add control like this if(targetMoney - amount < 0) then return end
-
yes, this is what you need to do for the takemoney command, it will subtract the amount from the player's current money
-
Can you try this, sorry for the messy codes, the forum is breaking it function moneyCmd(player, commandName, AccName, amount) --if(getElementType(player) ~= "player") then return end -- not need this --pacc = getPlayerAccount (player) -- You assign your own account to the accName variable --AccName = getAccountName (pacc) -- try remove this local targetAccount = getAccount(AccName) -- get account from AccName if not (targetAccount) then return outputChatBox("There is no such account in the database.", player) end --Check if there is an account named accName, if not, don't continue if isObjectInACLGroup ("user."..AccName, aclGetGroup ( "Moderator" ) ) then -- the shared logic local targetMoney local MoneyData = dbPoll(dbQuery(db,"SELECT Money FROM stats WHERE Account=? LIMIT 1",AccName), -1) if(MoneyData) then if(#MoneyData > 0) then for _,row in ipairs(MoneyData) do targetMoney = row["Money"] -- get player money amount from database break end end end if commandName == "givemoney" then amount = tonumber(amount) if tostring(AccName) and amount then targetMoney = targetMoney + amount -- addition with amount dbExec(db,"UPDATE stats SET Money=? WHERE Account=?", targetMoney,AccName) else outputChatBox("[usage] /givemoney [playername] [amount]", player) end else if commandName == "takemoney" then amount = tonumber(amount) if tostring(AccName) and amount then targetMoney = targetMoney - amount -- subtraction with amount dbExec(db,"UPDATE stats SET Money=? WHERE Account=?", targetMoney,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);
-
givePlayerMoney(v, amount) local playermoney = getPlayerMoney(player) takePlayerMoney(v, amount) remove codes like this because this only applies to players that exist on the server if you want to do it from the database just sql query is enough
-
I'm not sure but can you test this code the problem might be that you assign your own account to your AccName variable in the first place function moneyCmd(player, commandName, AccName, amount) --if(getElementType(player) ~= "player") then return end -- not need this --pacc = getPlayerAccount (player) -- You assign your own account to the accName variable --AccName = getAccountName (pacc) -- try remove this local targetAccount = getAccount(AccName) -- get account from AccName if not (targetAccount) then return outputChatBox("There is no such account in the database.", player) end --Check if there is an account named accName, if not, don't continue 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);
-
Create an event on the server side to change the player's skin addEvent("setPlayerSkin", true) addEventHandler("setPlayerSkin", root, function(ID) setElementModel(source, ID) end ) then call it with triggerServerEvent this can be inside the btnSeleccionar event You don't need to delete the setElementModel function on the client side for this, just trigger it on the server side after the player selects the final skin triggerServerEvent("setPlayerSkin", localPlayer, tablaSkinsHombre[currentTableID])
-
setElementDimension( getLocalPlayer(), 0) setElementInterior( getLocalPlayer(), 0) Can you try to transfer these codes to the server side, it can be inside the descongelar event. Apart from this, there may be other codes that you did not show here, I did not see a problem in the codes you sent.
-
where spawnPlayer function is used after players choose skin
-
Where are the player spawn codes? can you add it please?
-
there doesn't seem to be a problem here, everything seems correct are you sure there is a problem here? by the way, make sure to use setPlayerMoney on server side because it doesn't work on client side wiki: Note: Using this function client side (not recommended) will not change a players money server side. addEventHandler("onClientGUIClick", btnSeleccionar, function() showCursor(false) guiSetVisible(ventanaElegirSkinsM, false) setElementPosition ( getLocalPlayer(), 1742.9543457031,-1862.6853027344,13.575992584229) setElementDimension( getLocalPlayer(), 0) setElementRotation( getLocalPlayer(), -0, 0, 357.78338623047) setElementInterior( getLocalPlayer(), 0) triggerServerEvent("descongelar", getLocalPlayer(), localPlayer) setPlayerMoney(2500) -- <-- this
-
As I said, the codes are working fine for me, you are doing something wrong, maybe you can try to remove the cache=false part for the server, if it doesn't happen again, I don't know.
-
In which file are these codes stored client, server, shared? if shared just write them on server side and try to delete the oop line