Jump to content

BenceDev

Members
  • Posts

    53
  • Joined

  • Last visited

Everything posted by BenceDev

  1. Hi again! so i fixed a endJob error, but the getElementWithinColShape is give me a same error. ERROR: fs_teamS\vehSpawners.lua:22: attempt to call global 'getElementWithinColShape' (a nil value) I fixed it getElementWithinColShape that not writted perfect perfect is: getElementsWithinColShape
  2. Hii I wanna to create a vehicle on player element data and the player doesnt can spawn another vehicle or same for multiple times, but the player killed or player vehicle destroyed delete the vehicle from player element data and he can after respawn did spawn another vehicle or same vehicle recently This script with marker So, i have a problem. I got 2 error when i go into the spawn marker. Errors here: ERROR: fs_teamS\client.lua:16: attempt to index global 'endJob' (a nil value) ERROR: fs_teamS\vehSpawners.lua:22: attempt to call global 'getElementWithinColShape' (a nil value) Client Side: addEventHandler("onClientVehicleEnter", root, function(thePlayer, seat) if(source == getElementData(localPlayer, "jobVehicle")) then if(seat == 0) then if not (endJob[1]) then endJob[1] = createMarker(1920.9970703125, -2627.3212890625, 13.5, "cylinder", 2, 100, 0, 0, 90) endJob[2] = createBlip(1920.9970703125, -2627.3212890625, 13.546875, 55, 1, 0, 0, 0, 255) end end end end ) addEventHandler("onClientMarkerHit", resourceRoot, function(hitElement, mDim) if (mDim) then if (source == endJob[1]) then destroyElement(jobVehicle) triggerServerEvent("endJob", resourceRoot, localPlayer) destroyElement(endJob[1]) destroyElement(endJob[2]) end end end ) Server Side: for i, player in ipairs(getElementsByType("player")) do setElementData(player, "jobVehicle", false) end local vehicleSpots = { [1] = {1943.8193359375, -2642.0595703125, 13.546875, createColCuboid(1940.8193359375, -2642.0595703125, 12.7, 6.6, 7, 5)}, [2] = {1944.220703125, -2631.931640625, 13.546875, createColCuboid(1940.220703125, -2631.931640625, 12.7, 6.6, 7, 5)}, } local jobMarker = createMarker(1935.9091796875, -2654.40234375, 13.5, "cylinder", 1.5, 0, 0, 100, 90) local deliveryVehicles = {468} addEventHandler("onMarkerHit", resourceRoot, function(hitElement, mDim) if (mDim) then if(source == jobMarker) then if(getElementType(hitElement) == "player") then if not (getElementData(hitElement, "jobVehicle")) then local isVehicle = false for i, spot in pairs(vehicleSpots) do local vehicleInSpot = getElementWithinColShape(spot[4], "vehicle") if not(#vehicleInSpot > 0) then local jobVehicle = createVehicle(deliveryVehicles[math.random(1)], spot[1], spot[2], spot[3]) setElementData(hitElement, "jobVehicle", jobVehicle) outputChatBox("#b4a996 Siker!", player, 0, 0, 0, true) isVehicle = true break end end if not (isVehicle) then outputChatBox("#fd5c63 Siker de, nincs hely!", player, 0, 0, 0, true) end else outputChatBox("#f48924Már van járműved!", player, 0, 0, 0, true) end end end end end ) addEvent("endJob", true) addEventHandler("endJob", resourceRoot, function(player) if(player == client) then local vehicle = getPedOccupiedVehicle(client) if (vehicle) then if (vehicle == getElementData(client, "jobVehicle")) then destroyElement(vehicle) setElementData(client, "jobVehicle", false) end end end end )
  3. I tried it, but i got error, but the trailer is got created. debugscript says: ERROR: an_trailersystem\server.lua:77: table index is nil server side: function getNearestTrailer(player,distance) local lastMinDis = distance-0.0001 local nearestTrailer = false local px,py,pz = getElementPosition(player) local pint = getElementInterior(player) local pdim = getElementDimension(player) for _,v in pairs(getElementsByType("vehicle")) do local vint,vdim = getElementInterior(v),getElementDimension(v) if vint == pint and vdim == pdim then local vx,vy,vz = getElementPosition(v) local dis = getDistanceBetweenPoints3D(px,py,pz,vx,vy,vz) if dis < distance then if dis < lastMinDis and getVehicleType(v) == "Trailer" then lastMinDis = dis nearestTrailer = v end end end end return nearestTrailer end function hookTrailer(player,commandName) local vehicle = getPedOccupiedVehicle ( player ) if vehicle then local x,y,z = getElementPosition( vehicle ) local rx,ry,rz = getElementRotation ( vehicle ) local trailer = getNearestTrailer(player, 2000) if trailer then attachTrailerToVehicle ( vehicle, trailer ) outputChatBox("Pótkocsit sikeresen felcsatoltad", player, 0, 255, 0) else outputChatBox("Nem található pótkocsi a közeledben!", player, 255, 0, 0) end else outputChatBox("Járműben kell ülnöd ehez!", player, 255, 0, 0) end end function unhookTrailer(player, key, keyState) local theVehicle = getPedOccupiedVehicle ( player ) if theVehicle then local x,y,z = getElementPosition( theVehicle ) local rx,ry,rz = getElementRotation ( theVehicle ) local trailer = getNearestTrailer(player, 5000) if trailer then detachTrailerFromVehicle ( theVehicle, trailer ) outputChatBox("Pótkocsit sikeresen lecsatoltad!", player, 0, 255, 0, false) else outputChatBox("Nem található pótkocsi a közeledben!", player, 255, 0, 0, false) end else outputChatBox("Járműben kell ülnöd ehez!", player, 255, 0, 0, false) end end addEventHandler("onResourceStart", resourceRoot, function() local players = getElementsByType("player") for i = 1, #players do local player = players[i] bindKey(player, "F3", "down", hookTrailer) bindKey(player, "F4", "down", unhookTrailer) end end) addEventHandler("onPlayerJoin", root, function() bindKey(player, "F3", "down", hookTrailer) bindKey(player, "F4", "down", unhookTrailer) end) -- just a table trailers = {} -- use this when creating the trailer trailer = createVehicle ( 435, 2201.9609375, -2271.4736328125, 13.5625) trailers[player] = false -- use this when you press the key trailers[source] = true function detachTrailer(theTruck) if trailers[trailer] == false then --detachTrailerFromVehicle(theTruck, source) --detach the newly attached trailer -- Immediate detatchment of the trailer through cancel event or this method doesn't seem to work so requires a timer: setTimer(detachTrailer2, 50, 1, theTruck, source) end end addEventHandler("onTrailerAttach", getRootElement(), detachTrailer) function detachTrailer2(theVehicle, trailer) if (isElement(theVehicle) and isElement(trailer)) then detachTrailerFromVehicle(theVehicle, trailer) end end
  4. Update: I try it but i got error. debugscript 3 says: ERROR: Loading script failed: an_trailersystem\server.lua:94: 'end' expected (to close 'function' at line 82) near '<eof>'
  5. Okay i try it Update: So i tried it, but when i attach the trailer with bind, after i attach the trailer is immediately get deattached, after attached and again deattach and this is go loop. How can i fix this issue?
  6. Hi, i want to disable default automatic trailer attach, but i can attach from bind(bind attach done) so is this posibile to disable or i forget this idea.
  7. ok i try it ok that's work fine thx @Burak5312
  8. Hi, again I created a skin shop, so i click buy skin has been buyed and skin changed. that's work fine, but i have skin from skin shop(example: 284) and i click again buy dont change and buy again skin, and say "You already purchased this skin!". Debugscript 3 say: WARNING: an_safezoneSkinShop\client.lua:91: Bad argument @ 'getElementModel' [Expected element at argument 1, got nil] Client side: local skinWindow1 = guiCreateWindow(0.22, 0.22, 0.57, 0.61, "Skin Shop", true) guiWindowSetSizable(skinWindow1, false) guiSetVisible(skinWindow1,false) local skinText0 = guiCreateLabel(0.85, 0.95, 0.15, 0.05, "Press F4 for close panel", true, skinWindow1) local skinText1 = guiCreateLabel(-0.40, 0.10, 1, 1, "Deafult\nPrice: 0$", true, skinWindow1) local skinText2 = guiCreateLabel(-0.30, 0.10, 1, 1, "Deafult2\nPrice: 0$", true, skinWindow1) local skinText3 = guiCreateLabel(-0.20, 0.10, 1, 1, "Ranger\nPrice: 500$", true, skinWindow1) local skinText4 = guiCreateLabel(-0.10, 0.10, 1, 1, "Delta\nPrice: 825$", true, skinWindow1) local skinText5 = guiCreateLabel(0, 0.10, 1, 1, "Special Ops\nPrice: 925$", true, skinWindow1) local skinText6 = guiCreateLabel(0.10, 0.10, 1, 1, "Special Ops\nPrice: 1025$", true, skinWindow1) local skinPayButton1 = guiCreateButton(0.075, 0.17, 0.05, 0.05, "Buy", true, skinWindow1) local skinPayButton2 = guiCreateButton(0.175, 0.17, 0.05, 0.05, "Buy", true, skinWindow1) local skinPayButton3 = guiCreateButton(0.275, 0.17, 0.05, 0.05, "Buy", true, skinWindow1) local skinPayButton4 = guiCreateButton(0.375, 0.17, 0.05, 0.05, "Buy", true, skinWindow1) local skinPayButton5 = guiCreateButton(0.475, 0.17, 0.05, 0.05, "Buy", true, skinWindow1) local skinPayButton6 = guiCreateButton(0.575, 0.17, 0.05, 0.05, "Buy", true, skinWindow1) guiSetFont(skinText0, 'clear-normal') guiLabelSetHorizontalAlign(skinText0, "center", false) guiSetFont(skinText1, 'clear-normal') guiLabelSetHorizontalAlign(skinText1, "center", false) guiSetFont(skinText2, 'clear-normal') guiLabelSetHorizontalAlign(skinText2, "center", false) guiSetFont(skinText3, 'clear-normal') guiLabelSetHorizontalAlign(skinText3, "center", false) guiSetFont(skinText4, 'clear-normal') guiLabelSetHorizontalAlign(skinText4, "center", false) guiSetFont(skinText5, 'clear-normal') guiLabelSetHorizontalAlign(skinText5, "center", false) guiSetFont(skinText6, 'clear-normal') guiLabelSetHorizontalAlign(skinText6, "center", false) addEvent("showSkinGUI",true) addEventHandler("showSkinGUI",getRootElement(), function () if ( guiGetVisible(skinWindow1) == false ) then guiSetVisible(skinWindow1,true) guiLabelSetColor (skinText0, 237, 121, 2) guiSetProperty (skinPayButton1, "NormalTextColour", "EEE82870") guiSetProperty (skinPayButton2, "NormalTextColour", "EEE82870") guiSetProperty (skinPayButton3, "NormalTextColour", "EEE82870") guiSetProperty (skinPayButton4, "NormalTextColour", "EEE82870") guiSetProperty (skinPayButton5, "NormalTextColour", "EEE82870") guiSetProperty (skinPayButton6, "NormalTextColour", "EEE82870") showCursor(true) guiSetVisible(skinPayButton1, true) guiSetVisible(skinPayButton2, true) guiSetVisible(skinPayButton3, true) guiSetVisible(skinPayButton4, true) guiSetVisible(skinPayButton5, true) guiSetVisible(skinPayButton6, true) end end) local function guzik() guiSetVisible(skinWindow1, false) showCursor(false, false) end bindKey("F4","down",guzik) local function defaultSBuy() guiSetVisible(skinPayButton1, false) setElementModel(localPlayer, 287) end addEventHandler("onClientGUIClick", skinPayButton1, defaultSBuy, false) local function default2SBuy() guiSetVisible(skinPayButton2, false) setElementModel(localPlayer, 283) end addEventHandler("onClientGUIClick", skinPayButton2, default2SBuy, false) local function default3SBuy() guiSetEnabled(skinPayButton3, false) local money = getPlayerMoney(thePlayer) local id = getElementModel(thePlayer) if (money < 500) then --if the player's money is less than 0 go no further outputChatBox("You don't have enough money! (500$)", 255, 0, 0) guiSetVisible(skinPayButton3, true) return end if getElementType () == "player" and id == 284 then outputChatBox("You already pruchased this skin!", 255, 0, 0) end outputChatBox("You purchased a Humvee! (500$)", 0, 255, 0) takePlayerMoney(500) setElementModel(localPlayer, 284) end addEventHandler("onClientGUIClick", skinPayButton3, default3SBuy, false) any idea?
  9. OK, but now working fine, my mistake to i dont change .png files name ?
  10. no debug error but the paintjob is not switch It Solved and work perfecly!
  11. I again, so i have one more problem, if i try switch paintjob with command i got warning: Client side addCommandHandler("pj", function(cmd,id, source) local veh = getPedOccupiedVehicle(source) if veh then local id = tonumber(id) or 0 local model = getElementModel(veh) if availablePaintJobs[model] and availablePaintJobs[model][id] then setElementData(veh, "tuning.paintjob", id) triggerServerEvent("addVehiclePaintJob", localPlayer, veh, model, id, true) end end end) WARNING: exg_paintjob\exClient.lua:108: Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got nil]
  12. it doesn't work i got error: ERROR: exg_paintjob\exClient.lua: 109: attempt to concatenate local 'plrAccName' (a boolean value)
  13. Hii, Again me! I have problem, so i wanna get player account from server side to client side, but it doesn't work. I got 1 error 1 warning: WARNING: exg_paintjob\exClient.lua:108 Bad argument v 'getElementData' [Expected element at argument 1, got nil] ERROR: exg_paintjob\exClient.lua:109: attempt to concatenate local 'plrAccName' (a boolean value) Server Side: function addVehiclePaintJob(veh, model, id) if id > 0 then triggerClientEvent(root, "addVehiclePaintJob", source, veh, model, id) else triggerClientEvent(root, "destroyShaderCache", source, veh) end end addEvent("addVehiclePaintJob", true) addEventHandler("addVehiclePaintJob", root, addVehiclePaintJob) addEventHandler("onPlayerLogin", getRootElement(), function(_, playerAccount) local accName = getAccountName(playerAccount) -- save the account name as data setElementData(source, "accName", accountName) end ) Client Side: availablePaintJobs = { [562] = { {'*remap2010f150*', 'textures/remap2010f150_1.png'}, {'*remap2010f150*', 'textures/remap2010f150_2.png'}, {'*remap2010f150*', 'textures/remap2010f150_3.png'}, }, }; local shaders = {} local elementShaders = {} local textureCache = {} local textureCount = {} local textureSize = 768 function applyShader(texture, img, distance, element) if element then destroyShaderCache(element) end local this = #shaders + 1 shaders[this] = {} shaders[this][1] = dxCreateShader("texturechanger.fx",0,distance,layered) if not textureCount[img] then textureCount[img] = 0 end if textureCount[img] == 0 then textureCache[img] = dxCreateTexture(img) end textureCount[img] = textureCount[img] + 1 shaders[this][2] = textureCache[img] shaders[this][3] = texture if element then if not elementShaders[element] then elementShaders[element] = {shaders[this], img} end end if shaders[this][1] and shaders[this][2] then dxSetShaderValue(shaders[this][1], "TEXTURE", shaders[this][2]) engineApplyShaderToWorldTexture(shaders[this][1], texture, element) end end function destroyShaderCache(element) if elementShaders[element] then destroyElement(elementShaders[element][1][1]) local old_img = elementShaders[element][2] textureCount[old_img] = textureCount[old_img] - 1 if textureCount[old_img] == 0 then destroyElement(elementShaders[element][1][2]) end elementShaders[element] = nil end end addEvent("destroyShaderCache", true) addEventHandler("destroyShaderCache", root, destroyShaderCache) addEventHandler("onClientResourceStart", resourceRoot, function() for k,v in ipairs(getElementsByType("vehicle", root, true)) do local pj = tonumber(getElementData(v, "tuning.paintjob")) or 0 if pj > 0 then addVehiclePaintJob(v, getElementModel(v), pj) end end end) function getVehiclePaintJobs(model) if availablePaintJobs[model] then return #availablePaintJobs[model] else return 0 end end function addVehiclePaintJob(veh, model, id) local pj = availablePaintJobs[model] if pj then local pj = pj[id] if pj then applyShader(pj[1], pj[2], 100, veh) end end end addEvent("addVehiclePaintJob", true) addEventHandler("addVehiclePaintJob", root, addVehiclePaintJob) addEventHandler("onClientElementDestroy", getRootElement(), function() if getElementType(source) == "vehicle" then destroyShaderCache(source) end end) addEventHandler("onClientElementStreamIn", getRootElement(), function() if getElementType(source) == "vehicle" then local pj = tonumber(getElementData(source, "tuning.paintjob")) or 0 if pj > 0 then addVehiclePaintJob(source, getElementModel(source), pj) end end end) addEventHandler("onClientElementStreamOut", getRootElement(), function() if getElementType(source) == "vehicle" then destroyShaderCache(source) end end) addCommandHandler("pj", function(cmd,id) local plrAccName = getElementData(thePlayer, 'accName') if isObjectInACLGroup("user."..plrAccName, aclGetGroup("Admin")) or isObjectInACLGroup("user."..plrAccName, aclGetGroup("Owner")) then local veh = getPedOccupiedVehicle(localPlayer) if veh then local id = tonumber(id) or 0 local model = getElementModel(veh) if availablePaintJobs[model] and availablePaintJobs[model][id] then setElementData(veh, "tuning.paintjob", id) triggerServerEvent("addVehiclePaintJob", localPlayer, veh, model, id, true) end end end end) What's the problem in my code?
  14. i try it, but i got WARNING: WARNING: [SafeZoneSystems]\an_safezoneVehShop\server.lua: Bad argument @ 'getElementType' [Expected element at argument 1, got boolean]
  15. if (money > 10000) or (isElement(hitElement) and getElementType(hitElement) == 'player') then -- Line 90 local money = getPlayerMoney(hitElement) -- Line 91
  16. Hi, i created small shop system with marker, when i hit the marker i got error. ERROR: [SafeZoneSystems]\an_safezoneVehShop\server.lua:90: attempt to compare nubmer with nil Code: function spawnItemsWhenStart ( name ) createPed(287, 1544.75390625, -1675.2421875, 13.55902671814, 90) end addEventHandler ( "onResourceStart", getResourceRootElement(), spawnItemsWhenStart ) function spawnMarkerFunction() --local deleteMarker = createMarker(1529.248046875, -1685.935546875, 4.5, "cylinder", 3, 135, 15, 15, 0) setElementInterior(spawnMarker, 0) setElementDimension(spawnMarker, 0) addEventHandler("onMarkerHit",spawnMarker,onSpawnMarkerHit) end spawnHeliMarker = createMarker (1930.0791015625, -2626.673828125, 12.5, "cylinder", 3, 122, 193, 67, 70) function onSpawnHeliMarkerHit (thePlayer, hitElement, heliSpawnPos) if (money > 10000) or (isElement(hitElement) and getElementType(hitElement) == 'player') and tonumber(getElementData(hitElement, money)) then -- if money is more than 1000 local money = getPlayerMoney(hitElement) outputChatBox("You purchased a blackhawk!", hitElement, 0, 255, 0) takePlayerMoney(hitElement, 10000) local heliSpawnPos={ {1967.8515625, -2636.1103515625, 13.546875}, {1998.966796875, -2636.849609375, 13.546875}, } local theVeh = getPedOccupiedVehicle(hitElement) if ( theVeh ) then if ( VehiclesTable[hitElement] ) then VehiclesTable[hitElement] = nil end return end local x, y, z = getElementPosition (hitElement) local rotX, rotY, rotZ = getElementRotation (hitElement) local random = math.random(1,#heliSpawnPos) VehiclesTable[hitElement] = createVehicle (563, heliSpawnPos[random][1], heliSpawnPos[random][2], heliSpawnPos[random][3]+2) setElementRotation (VehiclesTable[hitElement], rotX, rotY, 0) warpPedIntoVehicle (hitElement, VehiclesTable[hitElement]) elseif(money < 0) then outputChatBox("You don't have enough money!", thePlayer, 255, 0, 0) end end addEventHandler("onMarkerHit", spawnHeliMarker, onSpawnHeliMarkerHit) i dont figure what is this error means.
  17. @Burak5312 Thanks for help, and i try it It did it work! Thank you so much help @Burak5312and@RavenLoad
  18. so another one problem here. WARNING: [DEIXO]\[JOBS]\dx_delivery\server.lua:25: Bad argument @ 'triggerClientEvent' [Expected string at argument 1, got nil] Server side: addEventHandler("onMarkerHit", resourceRoot, function(hitElement, mDim, Player) if (mDim) then if (source == jobMarker) then if (getElementType(hitElement) == "player") then if not ( getElementData(hitElement, "jobVehicle") ) then local isVehicle = false; for i, spot in pairs(vehicleSpots) do local vehicleInSpot = getElementsWithinColShape(spot[4], "vehicle"); if not (#vehicleInSpot > 0) then local jobVehicle = createVehicle(deliveryVehicles[math.random(1)], spot[1], spot[2], spot[3]); --Trigger Client here --> triggerClientEvent(Player, "warpPlrTVeh") setElementData(hitElement, "jobVehicle", jobVehicle); setElementRotation(jobVehicle, 0, 0, -90) local jobVehBlip = createBlipAttachedTo(jobVehicle, 55) outputChatBox("[#1FDBB7Deixo#ffffff]: A járműved #00FF00készen#ffffff áll!", hitElement, 255, 255, 255, true); isVehicle = true; break; end end if not (isVehicle) then outputChatBox("[#1FDBB7Deixo#ffffff]:#FF0000 Nincs szabad hely.#ffffff Várj egy keveset!", hitElement, 255, 255, 255, true); end else outputChatBox("[#1FDBB7Deixo#ffffff]:#FF0000 Már van járműved!#ffffff Keresd meg és menj azzal!", hitElement, 255, 255, 255, true); end end end end end ); Client side: addEventHandler("warpPlrTVeh", localPlayer, function(localPlayer) warpPedIntoVehicle(localPlayer, "jobVehicle") end )
  19. it not work, but i try client side so client side, no error and i dont warp in vehicle
×
×
  • Create New...