Jump to content

thund3rbird23

Members
  • Posts

    129
  • Joined

  • Last visited

Everything posted by thund3rbird23

  1. Thank you. So I can reference later to the cells with randomCell[1] , randomCell[2] etc...? Always pick the second cell {219.84390258789, 108.5353012085, 1000.9569702148, 180} local randomCell = cells[int][dim][rnd] setElementPosition(player, randomCell[1], randomCell[2], randomCell[3]) setElementRotation(player, 0, 0, randomCell[4]) setElementDimension(player, dim) setElementInterior(player, int) setElementData(player, "char.arrested", arrestText) removePedFromVehicle(player)
  2. Ok, I fixed it by changing the if dim ~= 0 then to the dimension where I am (174). Now getting this error: attempt to get length of field '?' (a nil value) For this: local rnd = math.random(1, #cells[dim]) The full function code, where is the error is: function dropPlayerToTheCell(player, time, reason, bail, bailPrice, arrestedBy) local arrestText = time .. "/" .. reason .. "/" .. tostring(bail) .. "/" .. bailPrice .. "/" .. arrestedBy arrestedPlayers[player] = { ["timer"] = setTimer(unjailPlayer, time * 60000, 1, player), ["time"] = time, ["reason"] = reason, ["bail"] = {bail, bailPrice}, ["arrestedBy"] = arrestedBy, } local dim = getElementDimension(player) if not cells[dim] then dim = defaultCells end local int = getElementInterior(player) if int == 0 then int = defaultInt end local rnd = math.random(1, #cells[dim]) -- here is the error setElementPosition(player, cells[dim][rnd][1], cells[dim][rnd][2], cells[dim][rnd][3]) setElementRotation(player, 0, 0, cells[dim][rnd][4]) setElementDimension(player, dim) setElementInterior(player, int) setElementData(player, "char.arrested", arrestText) removePedFromVehicle(player) print(cells[dim][rnd][1] .. " " .. cells[dim][rnd][2] .. " " .. cells[dim][rnd][3] .. " " .. dim .. " " .. int) end defaultCells = 174 defaultInt = 10 cells = { --[Int ID] = {{Cellák pos}} [10] = {215.36199951172, 108.91190338135, 1000.9522705078, 180}, [10] = {219.84390258789, 108.5353012085, 1000.9569702148, 180}, [10] = {223.37170410156, 107.92459869385, 1000.8811035156, 180}, [10] = {227.17649841309, 107.85209655762, 1000.6198120117, 180}, }
  3. local dim = getElementDimension(localPlayer) if dim ~= 0 then local px, py, pz = getElementPosition(localPlayer) if not (getDistanceBetweenPoints3D(arrestPoints[dim][1], arrestPoints[dim][2], arrestPoints[dim][3], px, py, pz) <= 7) then -- here is the error exports.s_alert:showAlert("error", "Nem vagy letartóztatási hely közelében.") return end end arrestPoints: arrestPoints = { --[Int ID] = {X, Y, Z} [10] = {215.72779846191, 115.77359771729, 1000.2130737305}, [10] = {219.50369262695, 115.5871963501, 1000.0123291016}, [10] = {223.50689697266, 115.81269836426, 1000.3059082031}, [10] = {227.45030212402, 115.83280181885, 1000.3964233398}, }
  4. if args[1] == "success" then if minigameData.successEvent then triggerEvent(minigameData.successEvent, localPlayer) end else if minigameData.failEvent then triggerEvent(minigameData.failEvent, localPlayer) end end Maybe that?
  5. What do you mean sending it with the triggerClientEvent? everything in client side. Except the s_medicS:healPlayer function function healPlayer(playerElement) if isElement(playerElement) then setElementHealth(playerElement, 100) setElementData(playerElement, "isPlayerDeath", false) setElementData(playerElement, "bulletDamages", false) setElementData(playerElement, "bloodLevel", 100) setElementData(playerElement, "deathReason", false) setElementData(playerElement, "customDeath", false) end end
  6. Okay, so the minigame function not contains the target player. function startMinigame(gameType, successEvent, failEvent, ...) stopMinigame() local args = {...} minigameData = {} if gameType == "buttons" then minigameData.buttons = {} minigameData.spawnedButtons = 0 minigameData.renderTarget = dxCreateRenderTarget(622, 55, true) minigameData.RobotoFont = dxCreateFont("files/Roboto.ttf", 12, false, "antialiased") minigameData.speed = args[1] or 0.15 minigameData.endSpeed = (args[2] or 0.2) - minigameData.speed minigameData.density = args[3] or 105 minigameData.maxButtonNum = args[4] or 75 minigameData.interpolateSpeedSet = false minigameData.currentBtn = false minigameData.btnInKey = false minigameData.failCount = 0 minigameData.successCount = 0 minigameData.lastRing = false minigameData.spawnNextButtonTimer = setTimer(spawnNextButton, 2000, 1) elseif gameType == "balance" then minigameData.difficulty = args[1] or 1 minigameData.accelerationMultipler = 0.5 minigameData.startGame = getTickCount() + 1000 minigameData.direction = false minigameData.lastKey = false minigameData.currentX = 10 minigameData.acceleration = 0.3 minigameData.endGameTime = args[2] or 10000 if math.random(10) <= 5 then minigameData.currentX = minigameData.currentX * -1 minigameData.acceleration = minigameData.acceleration * -1 end end if successEvent then minigameData.successEvent = successEvent end if failEvent then minigameData.failEvent = failEvent end minigameState = gameType end Example: startMinigame("balance", "successPlayerHelpup", "failedPlayerHelpup", 1, 10000) So, how can I add the targer player arg?
  7. No. I'm triggering the function from another client.Lua: triggerEvent("s_medicC:playerHeal", sourcePlayer, sourcePlayer) That's triggering this: addEvent("s_medicC:playerHeal", true) addEventHandler("s_medicC:playerHeal", getRootElement(), function (sourcePlayer) if sourcePlayer then if not isPedDead(sourcePlayer) then exports.s_minigames:startMinigame("balance", "healSuccess", "healFailed", 1, 10000) else outputChatBox("The player is dead.") end end end) So if the player is not dead, then start's a minigame. If the minigame is success then I triggering this server event: registerEvent("healSuccess", root, function(sourcePlayer) triggerServerEvent("s_medicS:healPlayer", sourcePlayer, sourcePlayer) -- already tried thePlayer, targetPlayer, player, sourcePlayer none of them working end)
  8. The "registerEvent" is: function registerEvent(event, element, xfunction) addEvent(event, true) addEventHandler(event, element, xfunction) end
  9. Why can't find the player? --- client --- registerEvent("healSuccess", root, function(player) triggerServerEvent("s_medicS:healPlayer", player, player) end) --- server --- registerEvent("s_medicS:healPlayer", root, function(targetPlayer) healPlayer(targetPlayer) end) healPlayer function: function healPlayer(playerElement) if isElement(playerElement) then setElementHealth(playerElement, 100) setElementData(playerElement, "isPlayerDeath", false) setElementData(playerElement, "bulletDamages", false) setElementData(playerElement, "bloodLevel", 100) setElementData(playerElement, "deathReason", false) setElementData(playerElement, "customDeath", false) end end
  10. I want to do that if I click to the safe(2332) object then showing up the safe's inventory. With the player and the vehicle element's are working. if itemsTableState == "player" then tabStartX = drawCategoryTab(tabStartX, tabStartY, "main", "bag", "Bag") tabStartX = drawCategoryTab(tabStartX + sizeForTabs, tabStartY, "keys", "key", "Keys") tabStartX = drawCategoryTab(tabStartX + sizeForTabs, tabStartY, "papers", "wallet", "Papers") elseif itemsTableState == "vehicle" then tabStartX = drawCategoryTab(tabStartX, tabStartY, "main", "vehicle", "Trunk") elseif itemsTableState == "object" then tabStartX = drawCategoryTab(tabStartX, tabStartY, "main", "safe", "Safe") end
  11. I don't know but if I debug for k, v in ipairs(getElementsByType("player")) do iprint(k,v) then only showing the first connected player's id and name not the target's id&name (who is called). Is this okay?
  12. No. Check this out: function addItemEx(sourceElement, dbID, slot, itemId, amount, data1, data2, data3) itemsTable[sourceElement][slot] = {} itemsTable[sourceElement][slot].dbID = dbID itemsTable[sourceElement][slot].slot = slot itemsTable[sourceElement][slot].itemId = itemId itemsTable[sourceElement][slot].amount = amount itemsTable[sourceElement][slot].data1 = data1 itemsTable[sourceElement][slot].data2 = data2 itemsTable[sourceElement][slot].data3 = data3 itemsTable[sourceElement][slot].inUse = false itemsTable[sourceElement][slot].locked = false end function giveItem(sourceElement, itemId, amount, data1, data2, data3) addItem(sourceElement, itemId, amount, false, data1, data2, data3) end function addItem(sourceElement, itemId, amount, slotId, data1, data2, data3) if isElement(sourceElement) and itemId and amount then itemId = tonumber(itemId) amount = tonumber(amount) if not itemsTable[sourceElement] then itemsTable[sourceElement] = {} end if not slotId then slotId = findEmptySlot(sourceElement, itemId) elseif tonumber(slotId) then if itemsTable[sourceElement][slotId] then slotId = findEmptySlot(sourceElement, itemId) end end if slotId then local ownerType = getElementType(sourceElement) local ownerId = getElementDatabaseId(sourceElement) if tonumber(ownerId) then itemsTable[sourceElement][slotId] = {} itemsTable[sourceElement][slotId].locked = true dbQuery( function (qh, sourceElement) if isElement(sourceElement) then local result = dbPoll(qh, 0, true)[2][1][1] if result then addItemEx(sourceElement, result.dbID, result.slot, result.itemId, result.amount, result.data1, result.data2, result.data3) triggerItemEvent(sourceElement, "addItem", getElementType(sourceElement), result) end end end, {sourceElement}, connection, "INSERT INTO items (itemId, slot, amount, data1, data2, data3, ownerType, ownerId) VALUES (?,?,?,?,?,?,?,?); SELECT * FROM items ORDER BY dbID DESC LIMIT 1", itemId, slotId, amount, data1, data2, data3, ownerType, ownerId ) return true else return false end else return false end else return false end end addEvent("addItem", true) addEventHandler("addItem", getRootElement(), addItem) I mean the value is the itemstable data1. But how can I reference in the phone's code? this is in the inventory server code.
  13. giveItem looks like: exports.s_inventory:giveItem(playerSource, 43, 1, tonumber(phoneID)) player,itemid,amount,value This is works, adding a phone and sets the value to the random generated number which saved in the database. I must specify the item id after v, otherwise always says "Number doesn't found". But if I specify the item id then always rings my phone no matter what number was typed. if v and number and exports.s_inventory:hasItem(v, 43, tonumber(number)) then The debug says: "elem:player[Jeff] "234434" so my name and the number which I typed. Maybe the error is in the callTargetInServer function? I commented that function too before.
  14. I need to check if the player have an item with itemID = 43 and with value = number but yes I think too that the syntax is wrong. I give the phone to the players with: exports.s_inventory:giveItem(playerSource, 43, 1, tonumber(phoneID)) and the hasItem function is: function hasItem(sourceElement, itemId) if itemsTable[sourceElement] then for k, v in pairs(itemsTable[sourceElement]) do if v.itemId == itemId then return v end end end return false end So how can I check if the player have the item with the itemid 43 and with the value = number?
  15. Ok, so if I debug the number in the callMember function then it's correct because that display the number which I dialing. But if I debug the targetPlayer in the callTargetInServer function then always shows me (Jeff) as player "elem:player[Jeff]" when I type any number. So what? I don't understand targetPlayer = callMember(number) iprint(targetPlayer) --- callMember function --- function callMember(number) for k, v in ipairs(getElementsByType("player")) do if v and number and exports.s_inventory:hasItem(v, 43, number) then if (getElementData(v, "inCall")) then return "inCall" else return v end end end return false end
  16. That's "showMenu" trigger is for calling others not for displaying the ads. But I fixed it so now we can see each others ad. But what about the calling? function callTargetInServer(playerSource, number, playerNumber) if number then targetPlayer = callMember(number) if targetPlayer ~= false and targetPlayer ~= "inCall" then triggerClientEvent(targetPlayer, "showMenu", targetPlayer, playerNumber, 6, playerSource, number) triggerClientEvent(playerSource, "showMenu", playerSource, number, 7, targetPlayer, playerNumber) triggerClientEvent(targetPlayer, "showSound", targetPlayer) exports.s_chat:sendLocalDoAction(targetPlayer, " 's phone ringing") elseif targetPlayer == "inCall" then outputChatBox("#D64541[Error] #ffffffThis number already in a call!", playerSource,255,255,255,true) else outputChatBox("#D64541[Error] #ffffffNumber doesn't found", playerSource,255,255,255,true) end end end addEvent("callTargetInServer", true) addEventHandler("callTargetInServer", getRootElement(), callTargetInServer) This is picks a random player in the server and calls him instead of the entered number... showMenu function in client side: function showMenu(number, menuid, playerSource, actualPhoneID) if menuid and number then triggerServerEvent("getPhoneDataFromServer", localPlayer, localPlayer, actualPhoneID) numberCall = number menu = menuid setElementData(playerSource, "inCall", true) showPhone = true inCallMember = playerSource end end addEvent("showMenu", true) addEventHandler("showMenu", getRootElement(), showMenu) getPhoneDataFromServer function in server side: function getPhoneDataFromServer(playerSource, phoneID) if tonumber(phoneID) then local checkID = dbPoll(dbQuery(connection, "SELECT * FROM phones WHERE number = ?", tonumber(phoneID)), -1) if (checkID) then for k, v in ipairs(checkID) do setElementData(playerSource, "musicID", v["music"]) triggerClientEvent(playerSource, "getPhoneDataToClient", playerSource, v["wallpaper"], v["music"], v["battery"]) end end end end addEvent("getPhoneDataFromServer", true) addEventHandler("getPhoneDataFromServer", getRootElement(), getPhoneDataFromServer) getPhoneDataToClient in client side: function getPhoneDataToClient(wallpaper, music, battery) wallPaperID = wallpaper musicID = music batteryState = battery loadedPhoneInterFace = true end addEvent("getPhoneDataToClient", true) addEventHandler("getPhoneDataToClient", getRootElement(), getPhoneDataToClient)
  17. Can you help me a bit more please? Almost everything works fine, except the "callTargetInServer" and the "onClientCallAd" functions. function callTargetInServer(playerSource, number, playerNumber) if number then targetPlayer = callMember(number) if targetPlayer ~= false and targetPlayer ~= "inCall" then triggerClientEvent(targetPlayer, "showMenu", targetPlayer, playerNumber, 6, playerSource, number) triggerClientEvent(playerSource, "showMenu", playerSource, number, 7, targetPlayer, playerNumber) triggerClientEvent(targetPlayer, "showSound", targetPlayer) exports.s_chat:sendLocalDoAction(targetPlayer, " 's phone ringing") elseif targetPlayer == "inCall" then outputChatBox("#D64541[Error] #ffffffThis number already in a call!", playerSource,255,255,255,true) else outputChatBox("#D64541[Error] #ffffffNumber doesn't found", playerSource,255,255,255,true) end end end addEvent("callTargetInServer", true) addEventHandler("callTargetInServer", getRootElement(), callTargetInServer) This is always call one player if more players in the server. If I'm alone then always calls me and if I put fake number then doing the same. function onClientCallAd(player, ad, ara, numberCall) local amout = math.ceil(ara) setElementData(player, "char:check", true) local money = getElementData(player,"char.Money") if(money<amout)then outputChatBox("You don't have enough money!", player, 255,0,0) return end setElementData(player,"char.Money",getElementData(player,"char.Money") - amout) for index , value in ipairs (getElementsByType("player")) do if (getElementData(value, "loggedin") and not getElementData(value, "char:check")) or player == value then outputChatBox ("#66ff66 AD: #ffcc00" ..ad.. " ((" ..getPlayerName(player):gsub("_", " ") .. "))",value,0, 233, 58,true) outputChatBox ("#66ff66 Contact: #ffcc00" .. numberCall,value,0, 233, 58,true) end end end addEvent("onClientCallForAdData", true ) addEventHandler("onClientCallForAdData", getRootElement(), onClientCallAd) The players doesn't see each others ad only their own ads.
  18. I used this code about 2 months ago and works fine, now I get error: attempt to compare number with table (on line 7) why? function loadAllGate() gates = {} local queryHandler = dbQuery(connection, "SELECT * FROM gates") local result, num, errorMsg = dbPoll(queryHandler, 10) if result > 0 then for key, row in ipairs(result) do local gateId = tonumber(row["id"]) gates[key] = {} gates[key]["sqlId"] = gateId gates[key]["modelId"] = tonumber(row["modelId"]) gates[key]["lockState"] = true gates[key]["defaultState"] = fromJSON(row["defaultState"]) gates[key]["changeState"] = fromJSON(row["changeState"]) gates[key]["createRotation"] = fromJSON(row["createRotation"]) gates[key]["IndDim"] = fromJSON(row["IndDim"]) gates[key]["gate"] = createObject(gates[key]["modelId"], gates[key]["defaultState"][1], gates[key]["defaultState"][2], gates[key]["defaultState"][3], gates[key]["defaultState"][4], gates[key]["defaultState"][5], gates[key]["defaultState"][6]) setElementRotation(gates[key]["gate"], gates[key]["createRotation"][1], gates[key]["createRotation"][2], gates[key]["createRotation"][3]) setElementInterior(gates[key]["gate"], gates[key]["IndDim"][1]) setElementDimension(gates[key]["gate"], gates[key]["IndDim"][2]) end end outputDebugString(#gates .. " gate(s) loaded") end addEventHandler("onResourceStart", resourceRoot, loadAllGate)
  19. Umm yes. So the situation is the following, I want to call the showPhoneFunction and set the itemValue to the item.data1 (this is from server side)
  20. and the call function returns the same as exports.
  21. Yes, I make the call after the resource has been started. I think the call code is wrong but don't know why. addEvent("useItem", true) addEventHandler("useItem", getRootElement(), function(dbID, use) if isElement(source) and dbID then local item = false for k, v in pairs(itemsTable[source]) do if v.dbID == dbID then item = v break end end if item then local playerInterior = getElementInterior(source) local playerDimension = getElementDimension(source) local itemId = item.itemId if itemId == 71 if use then exports["s_phone"]:showPhoneFunction()
×
×
  • Create New...