Wananazo Posted June 7, 2023 Share Posted June 7, 2023 watching a tutorial I achieved this by comparing it with another script, I really don't know if it turned out well I would like to know what I would add to the clientside here I leave the clientside so that they can add it to me and indicate the function to be able to understand it thanks Serverside function maletero(estado, playerSource, vehicle, item, qntd) if estado == "guardar" then if GiveAndTakeAndGetItem("get", playerSource, item) >= qntd then if not isTimer(acao[playerSource]) then acao[playerSource] = setTimer(function() end, 1300, 1) setPedAnimation(playerSource, "POLICE", "CopTraf_Away", 1300, true, false, false, false, _, true) setTimer(function() PlaySound3D(playerSource, "trash", 20) GiveAndTakeAndGetItem("take", playerSource, item, qntd) exports._infobox:addNotification(playerSource, "Guardaste "..qntd.."x '"..realName[item][1].."'", "success") local name = getPlayerName(playerSource) local id = getElementData(playerSource, "ID") or "N/A" exports["[MOD]Logs"]:CreateLog("[INVENTARIO]\nJugador: "..name.." ["..id.."]\nItem: "..item.."\nCantidad: "..qntd.."\nVehículo: "..getVehicleName(vehicle).."\nAcción: "..estado) for _, players in pairs(getElementsByType("player")) do if players ~= playerSource then local x, y, z = getElementPosition(playerSource) local x2, y2, z2 = getElementPosition(players) if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) <= 30 then local name = getPlayerName(playerSource) local id = getElementData(playerSource, "ID") or "N/A" outputChatBox("[INFO]:#FFFFFF El jugador #FFFF00"..name.."#FFFFFF ("..id..") guardó "..qntd.."x '"..realName[item][1].."' en el maletero del vehículo cercano a ti.", players, 30, 144, 255, true) end end end if not bau[vehicle] then bau[vehicle] = {} end if bau[vehicle][item] then bau[vehicle][item][1] = bau[vehicle][item][1] + tonumber(qntd) else bau[vehicle][item] = {} bau[vehicle][item][1] = tonumber(qntd) end end, 1300, 1) end else exports._infobox:addNotification(playerSource, "No posees la cantidad indicada de este item", "error") end elseif estado == "pegar" then if bau[vehicle] then if bau[vehicle][item] then if bau[vehicle][item][1] >= qntd then if GiveAndTakeAndGetItem("give", playerSource, item, qntd) then bau[vehicle][item][1] = bau[vehicle][item][1] - qntd if bau[vehicle][item][1] <= 0 then bau[vehicle][item] = nil end exports._infobox:addNotification(playerSource, "Tomaste "..qntd.."x '"..realName[item][1].."' del maletero del vehículo", "success") local name = getPlayerName(playerSource) local id = getElementData(playerSource, "ID") or "N/A" exports["[MOD]Logs"]:CreateLog("[INVENTARIO]\nJugador: "..name.." ["..id.."]\nItem: "..item.."\nCantidad: "..qntd.."\nVehículo: "..getVehicleName(vehicle).."\nAcción: "..estado) for _, players in pairs(getElementsByType("player")) do if players ~= playerSource then local x, y, z = getElementPosition(playerSource) local x2, y2, z2 = getElementPosition(players) if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) <= 30 then local name = getPlayerName(playerSource) local id = getElementData(playerSource, "ID") or "N/A" outputChatBox("[INFO]:#FFFFFF El jugador #FFFF00"..name.."#FFFFFF ("..id..") tomó "..qntd.."x '"..realName[item][1].."' del maletero de un vehículo cercano a ti.", players, 30, 144, 255, true) end end end else exports._infobox:addNotification(playerSource, "No tienes capacidad en la mochila para tomar este item", "error") end else exports._infobox:addNotification(playerSource, "El maletero del vehículo no posee la cantidad indicada de este item", "error") end else exports._infobox:addNotification(playerSource, "El maletero del vehículo no posee este item", "error") end else exports._infobox:addNotification(playerSource, "El vehículo no tiene maletero", "error") end end end addEvent("maletero", true) addEventHandler("maletero", resourceRoot, maletero) Clientside: function maletero(estado, playerSource, vehicle, item, qntd) if estado == "guardar" then if GiveAndTakeAndGetItem("get", playerSource, item) >= qntd then if not isTimer(acao[playerSource]) then acao[playerSource] = setTimer(function() end, 1300, 1) setPedAnimation(playerSource, "POLICE", "CopTraf_Away", 1300, true, false, false, false, _, true) setTimer(function() PlaySound3D(playerSource, "trash", 20) GiveAndTakeAndGetItem("take", playerSource, item, qntd) exports._infobox:addNotification(playerSource, "Guardaste "..qntd.."x '"..realName[item][1].."'", "success") local name = getPlayerName(playerSource) local id = getElementData(playerSource, "ID") or "N/A" exports["[MOD]Logs"]:CreateLog("[INVENTARIO]\nJugador: "..name.." ["..id.."]\nItem: "..item.."\nCantidad: "..qntd.."\nVehículo: "..getVehicleName(vehicle).."\nAcción: "..estado) for _, players in pairs(getElementsByType("player")) do if players ~= playerSource then local x, y, z = getElementPosition(playerSource) local x2, y2, z2 = getElementPosition(players) if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) <= 30 then local name = getPlayerName(playerSource) local id = getElementData(playerSource, "ID") or "N/A" outputChatBox("[INFO]:#FFFFFF El jugador #FFFF00"..name.."#FFFFFF ("..id..") guardó "..qntd.."x '"..realName[item][1].."' en el maletero del vehículo cercano a ti.", players, 30, 144, 255, true) end end end if not bau[vehicle] then bau[vehicle] = {} end if bau[vehicle][item] then bau[vehicle][item][1] = bau[vehicle][item][1] + tonumber(qntd) else bau[vehicle][item] = {} bau[vehicle][item][1] = tonumber(qntd) end end, 1300, 1) end else exports._infobox:addNotification(playerSource, "No posees la cantidad indicada de este item", "error") end elseif estado == "pegar" then if bau[vehicle] then if bau[vehicle][item] then if bau[vehicle][item][1] >= qntd then if GiveAndTakeAndGetItem("give", playerSource, item, qntd) then bau[vehicle][item][1] = bau[vehicle][item][1] - qntd if bau[vehicle][item][1] <= 0 then bau[vehicle][item] = nil end exports._infobox:addNotification(playerSource, "Tomaste "..qntd.."x '"..realName[item][1].."' del maletero del vehículo", "success") local name = getPlayerName(playerSource) local id = getElementData(playerSource, "ID") or "N/A" exports["[MOD]Logs"]:CreateLog("[INVENTARIO]\nJugador: "..name.." ["..id.."]\nItem: "..item.."\nCantidad: "..qntd.."\nVehículo: "..getVehicleName(vehicle).."\nAcción: "..estado) for _, players in pairs(getElementsByType("player")) do if players ~= playerSource then local x, y, z = getElementPosition(playerSource) local x2, y2, z2 = getElementPosition(players) if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) <= 30 then local name = getPlayerName(playerSource) local id = getElementData(playerSource, "ID") or "N/A" outputChatBox("[INFO]:#FFFFFF El jugador #FFFF00"..name.."#FFFFFF ("..id..") tomó "..qntd.."x '"..realName[item][1].."' del maletero de un vehículo cercano a ti.", players, 30, 144, 255, true) end end end else exports._infobox:addNotification(playerSource, "No tienes capacidad en la mochila para tomar este item", "error") end else exports._infobox:addNotification(playerSource, "El maletero del vehículo no posee la cantidad indicada de este item", "error") end else exports._infobox:addNotification(playerSource, "El maletero del vehículo no posee este item", "error") end else exports._infobox:addNotification(playerSource, "El vehículo no tiene maletero", "error") end end end addEvent("maletero", true) addEventHandler("maletero", resourceRoot, maletero) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now