βurak
Members-
Posts
370 -
Joined
-
Last visited
-
Days Won
21
Everything posted by βurak
-
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
-
Can you show the meta.xml and is there any other script running besides this script? If so, you can try turning them off.
-
I tested your code now, it works perfectly no errors creating teams seamlessly and puts player in props team
-
I don't see any problem in your code maybe you can check meta.xml make sure the file is on the server side
-
your welcome ?
-
in fact, you can only add it once when the player is a new registration, you don't need to do it this way. local SetData = dbExec(db,"INSERT INTO stats (ID,Account) VALUES (?, ?)",ID, AccName) you can do something like this to avoid multiple column records but I'm not sure it will work function getpaccount (_,account) local AccName = getAccountName(account) local AccData = dbPoll(dbQuery(db,"SELECT * FROM stats WHERE Account=? LIMIT 1", AccName), -1) -- search for a column in the database for this account if(AccData) then if(#AccData > 0) then return end -- do not continue if there is any record end --if there is no such record then save it to the database local ID = getFreeID() local SetData = dbExec(db,"INSERT INTO stats (ID,Account) VALUES (?, ?)",ID, AccName) end addEventHandler("onPlayerLogin",root, getpaccount)