Jump to content

kewizzle

Members
  • Posts

    162
  • Joined

  • Last visited

Everything posted by kewizzle

  1. Hi i want to make it so you have multiple radar areas and they all spawn together and they all are their own instance so when you enter any of them the script will do the same thing in each one around the map heres a sample WarehouseCol1 = createColRectangle( 2535, 2796, 80, 60 ) and createColRectangle( 1287, 1227, 80, 60 ) WarehouseArea1 = createRadarArea( 2535, 2796, 80, 60, 0, 0, 255, 90, root ) and createRadarArea( 1287, 1227, 80, 60, 0, 0, 255, 90, root )
  2. actually cancel this lol i found my old script i dont have to rewrite completely now HAHA
  3. so i should removeEventHandler each time Edit actually i can probably just call that outside
  4. This script is nearly complete works great but there are some bugs, just wanna see if anyone can point out why it spawns multiple elements each time i complete the warehouse, ill complete it once it spawns 1 truck then the second time it spawns 2 trucks. Also any improvement ideas would be nice. Client: warehouseR = createRadarArea ( 2535, 2795, 80, 50, 255, 0, 0, 75) warehouseCol = createColRectangle ( 2535, 2795, 80, 50 ) createBlip ( 2577, 2820, 11, 22 ) gpt = getElementData(localPlayer, "timer") local screenW, screenH = guiGetScreenSize() timerT = guiCreateLabel((screenW - 600) / 2, (screenH - 52) / 2, 600, 52, "Defend Warehouse: 300", false) guiSetFont(timerT, "sa-gothic") guiLabelSetColor(timerT, 48, 218, 36) guiSetVisible(timerT, false) addEventHandler("onClientColShapeHit", warehouseCol, function(theElement) if isElementWithinColShape ( localPlayer, warehouseCol ) then setElementData(localPlayer, "timer", 300) guiSetVisible(timerT, true) theTimer = setTimer ( function ( ) gpt = getElementData(localPlayer, "timer") setElementData(localPlayer, "timer", gpt-1) guiSetText(timerT, "Defend Warehouse: "..gpt) end, 1000, 300 ) addEventHandler("onClientColShapeLeave", warehouseCol, function() killTimer(theTimer) setElementData(localPlayer, "timer", 300) guiSetText(timerT, "Defend Warehouse: "..gpt) guiSetVisible(timerT, false) end) addEventHandler("onClientElementDataChange", localPlayer, function() if getElementData(localPlayer, "timer") == -2 then outputChatBox ( "Deliver The Supply Truck!", 0, 255, 0 ) triggerServerEvent ( "spawnSupplies", localPlayer, "spawnSupplies" ) end end) end end) Server: function supplySpawn () supplytruck = createVehicle ( 498, 2525, 2810, 11.2, 0, 0, 180 ) warpPedIntoVehicle ( source, supplytruck) stb = createBlipAttachedTo ( supplytruck, 51, 2, 255, 0, 0, 255, 0, 65535 ) dropoff = createMarker(285.5, 2498.8000488281, 16.5, "cylinder", 10, 255, 0, 255, 255, source) dob = createBlipAttachedTo ( dropoff, 35, 2, 255, 0, 0, 255, 0, 65535, source ) addEventHandler("onMarkerHit", dropoff, function() if isElementWithinMarker ( supplytruck, dropoff ) then destroyElement(dropoff) destroyElement(supplytruck) destroyElement(stb) destroyElement(dob) outputChatBox ( "Supply Truck Delivered Successfully! Rewards Recieved!", thePlayer, 0, 255, 0 ) givePlayerMoney(root, math.random(1000,5000)) giveWeapon(root, math.random(1, 46), math.random(0,100)) giveWeapon(root, math.random(1, 46), math.random(0,100)) giveWeapon(root, math.random(1, 46), math.random(0,100)) end end) addEventHandler("onVehicleExplode", supplytruck, function() outputChatBox ( "Supply Truck Destroyed! MISSION FAILED!", thePlayer, 255, 0, 0 ) destroyElement(supplytruck) destroyElement(dropoff) destroyElement(stb) destroyElement(dob) end) end addEvent( "spawnSupplies", true ) addEventHandler( "spawnSupplies", root, supplySpawn )
  5. I figured out a way to make it work without vmware and virtual box
  6. i was trying to use vmware to solo test some scripts with 2 players and it says banned by mta reason 4e security whatever vm type something so wondering whats the best way to test my scripts solo?
  7. i redid it works well i just used my display and text item ima post a video lmk what you think bro
  8. yknow what buddy ima remake this buut completely server side
  9. guess what buddy i was able to use the old script and i fixed it completely. using what you taught me. i found this little piece of code useful (shape == warehouse_col) and my finished script here. function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,...) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getCameraMatrix() local distance = distance or 20 local height = height or 1 if (isLineOfSightClear(x, y, z+2, x2, y2, z2, ...)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end --Warehouse Zones createBlip(2577, 2822, 11, 22) WarehouseCol1 = createColRectangle( 2535, 2796, 80, 50 ) WarehouseArea1 = createRadarArea( 2535, 2796, 80, 50, 0, 0, 255, 90, root ) setElementData(WarehouseCol1, "warehoue", true) setElementData(WarehouseArea1, "warehoue", true) --Leaving the warehouse function warehouseLeave() if (getElementType(source) == "ped") or (getElementType(source) == "marker") then return end --thought maybe this would work if isElementWithinColShape(localPlayer, WarehouseCol1) == true then timertxt = getElementData(localPlayer, "timer") Wtimer = dxDrawTextOnElement(localPlayer, "Defend Warehouse: "..timertxt, 1, 20, 255, 0, 255, 255, 5, "arial") elseif Wtimer == nil then return else destroyElement(Wtimer) end end addEventHandler("onClientRender", getRootElement(), warehouseLeave) addEventHandler("onClientElementColShapeLeave", localPlayer, warehouseLeave) --warehouse timer function warehoueTimer() if (getElementType(localPlayer) == "ped") or (getElementType(localPlayer) == "marker") then return end --thought maybe this would work timerW = getElementData(localPlayer, "timer") if isElementWithinColShape(localPlayer, WarehouseCol1) == true and getElementData(localPlayer, "timer") >= 1 then setElementData(localPlayer, "timer", timerW-1) elseif isElementWithinColShape(localPlayer, WarehouseCol1) == true and getElementData(localPlayer, "timer") == 0 then triggerServerEvent("doSupplyTruck", localPlayer) end end --Entering warehouse function warehoueEnter(shape) if (getElementType(source) == "ped") or (getElementType(source) == "marker") or (shape ~= WarehouseCol1) then return end --thought maybe this would work if isElementWithinColShape(localPlayer, WarehouseCol1) == true and (shape == WarehouseCol1) then setElementData(localPlayer, "timer", 60) :O = setTimer(warehoueTimer, 1000, 61) else killTimer(:O) end end addEventHandler("onClientElementColShapeLeave", localPlayer, warehoueEnter) addEventHandler("onClientElementColShapeHit", localPlayer, warehoueEnter) --switch from destroyed element source to player source function switchh() triggerServerEvent("switch2", localPlayer) end addEventHandler( "switch", localPlayer, switchh ) addEvent( "switch", true ) this is my largest script ive ever written other than guis i think i did pretty good it works flawless.
  10. Thanks for all your help I'd like you to win the day again so I went ahead and gave you a good boost
  11. Okay I'ma rewrite the script from start to finish. Can you give me an example on how to use an element from one function to another? Or how would I do that? Say I created the setTimer in warehouseEnter and want to kill it in warehouseLeave.
  12. Well @The_GTAEverytime I hit a marker it resets the timer and it also doubles the speed I'm pretty sure it is running the setTimer timer Everytime I hit a marker I just need each function to be cancelled if I hit a marker while Inside WarehouseCol1. Idk if I'm correct but maybe it's becaus markers have colshapes?
  13. id recommend using guieditor resource to design the gui and then check out the gui client functions and events at https://wiki.multitheftauto.com/wiki/Client_Scripting_Events#GUI and https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions#GUI_functions_2 make sure if you use guieditor to rename each object or it will be a pain. Make sure you use triggerServerEvent function when purchasing items and takePlayerMoney because if you intend to save these things those things will need to be triggered from client side and executed server side.
  14. kewizzle

    Marker

    marker = createMarker(arguments) setElementData(marker, "playerhit", 5) function markerData() getplayerhit = getElementData(marker, "playerhit") if getplayerhit >= 1 then setElementPosition( arguments ) setElementData(marker, "playerhit" getplayerhit-1) elseif getplayerhit == 0 then outputChatBox("You need to wait some time to enter this", thePlayer, 255, 0, 0) end end addEventHandler("onMarkerHit", marker, markerData) --make a timer function that sets the element data of the marker back to 5 for "playerhit". yes you will get errors if you straight up use this code read through it and add your arguments to what you want use setTimer for the timer function.
  15. well i been messing with it allllll day and i wrote this entirely myself last night and i just cant figure out this tho i just learned more than i wanted to from the wiki than i was trying too atm lmao but if anyone especially @The_GTA can show me how to return the end of each function if the colshape is not WarehouseCol1 much appreciated. function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,...) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getCameraMatrix() local distance = distance or 20 local height = height or 1 if (isLineOfSightClear(x, y, z+2, x2, y2, z2, ...)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end --Warehouse Zones createBlip(2577, 2822, 11, 22) WarehouseCol1 = createColRectangle( 2535, 2796, 80, 50 ) WarehouseArea1 = createRadarArea( 2535, 2796, 80, 50, 0, 0, 255, 90, root ) setElementData(WarehouseCol1, "warehoue", true) setElementData(WarehouseArea1, "warehoue", true) --Leaving the warehouse function warehouseLeave() if (getElementType(source) == "ped") or (getElementType(source) == "marker") then return end --thought maybe this would work if isElementWithinColShape(localPlayer, WarehouseCol1) == true then timertxt = getElementData(localPlayer, "timer") Wtimer = dxDrawTextOnElement(localPlayer, "Defend Warehouse: "..timertxt, 1, 20, 255, 0, 255, 255, 5, "arial") elseif Wtimer == nil then return else destroyElement(Wtimer) end end addEventHandler("onClientRender", getRootElement(), warehouseLeave) addEventHandler("onClientElementColShapeLeave", localPlayer, warehouseLeave) --warehouse timer function warehoueTimer() if (getElementType(source) == "ped") or (getElementType(source) == "marker") then return end --thought maybe this would work timerW = getElementData(localPlayer, "timer") if isElementWithinColShape(localPlayer, WarehouseCol1) == true and getElementData(localPlayer, "timer") >= 1 then setElementData(localPlayer, "timer", timerW-1) elseif isElementWithinColShape(localPlayer, WarehouseCol1) == true and getElementData(localPlayer, "timer") == 0 then triggerServerEvent("doSupplyTruck", localPlayer) end end --Entering warehouse function warehoueEnter() if (getElementType(source) == "ped") or (getElementType(source) == "marker") then return end --thought maybe this would work if isElementWithinColShape(localPlayer, WarehouseCol1) == true then setElementData(localPlayer, "timer", 60) :O = setTimer(warehoueTimer, 1000, 61) else killTimer(:O) end end addEventHandler("onClientElementColShapeLeave", localPlayer, warehoueEnter) addEventHandler("onClientElementColShapeHit", localPlayer, warehoueEnter) --switch from destroyed element source to player source function switchh() triggerServerEvent("switch2", localPlayer) end addEvent( "switch", true ) addEventHandler( "switch", localPlayer, switchh ) this is what im working with rn. bout to lay down possibly goto sleep.
  16. so the problem is just when entering markers inside the colshape i need to figure out how to exclude them
  17. i got it to work now another stupid problem lmao now when i hit a pickup or marker within the col it just resets the timer lmao
  18. iight so if not (getElementType(source) == "player") then return end doesnt work, tho i kinda need something like that am i doing that wrong?
  19. it works now except when a zombie is killed within the col shape it resets the timer and speeds it up lol im getting there also maybe has something with the Leave function so ima mess with it HAHAHAHAHA idk if you remember the drop system i made lmaooo i had to fix the supply run to include those if (getElementType(source) == "ped") or (getElementType(source) == "pickup") or (getElementType(source) == "marker") then return end i could probably do instead if not (getElementType(source) == "player") then return end
  20. sooo i wrote this script tonight all works well until i add zombies they keep triggering the functions and causing the timer to not work as intendded. function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,...) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getCameraMatrix() local distance = distance or 20 local height = height or 1 if (isLineOfSightClear(x, y, z+2, x2, y2, z2, ...)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end --Warehouse Zones createBlip(2577, 2822, 11, 22) WarehouseCol1 = createColRectangle( 2535, 2796, 80, 50 ) WarehouseArea1 = createRadarArea( 2535, 2796, 80, 50, 0, 0, 255, 90, root ) setElementData(WarehouseCol1, "warehoue", true) setElementData(WarehouseArea1, "warehoue", true) --Leaving the warehouse function warehouseLeave() if (getElementType(getRootElement()) == "ped") then return end --thought maybe this would work if isElementWithinColShape(localPlayer, WarehouseCol1) == true then timertxt = getElementData(localPlayer, "timer") Wtimer = dxDrawTextOnElement(localPlayer, "Defend Warehouse: "..timertxt, 1, 20, 255, 0, 255, 255, 5, "arial") elseif Wtimer == nil then return else destroyElement(Wtimer) end end addEventHandler("onClientRender", getRootElement(), warehouseLeave) addEventHandler("onClientElementColShapeLeave", getRootElement(), warehouseLeave) --warehouse timer function warehoueTimer() if (getElementType(getRootElement()) == "ped") then return end --thought maybe this would work timerW = getElementData(localPlayer, "timer") if isElementWithinColShape(localPlayer, WarehouseCol1) == true and getElementData(localPlayer, "timer") >= 1 then setElementData(localPlayer, "timer", timerW-1) elseif isElementWithinColShape(localPlayer, WarehouseCol1) == true and getElementData(localPlayer, "timer") == 0 then triggerServerEvent("doSupplyTruck", localPlayer) end end --Entering warehouse function warehoueEnter() if (getElementType(getRootElement()) == "ped") then return end --thought maybe this would work if isElementWithinColShape(localPlayer, WarehouseCol1) == true then setElementData(localPlayer, "timer", 60) :O = setTimer(warehoueTimer, 1000, 61) else killTimer(:O) end end addEventHandler("onClientElementColShapeLeave", getRootElement(), warehoueEnter) addEventHandler("onClientElementColShapeHit", getRootElement(), warehoueEnter) --switch from destroyed element source to player source function switchh() triggerServerEvent("switch2", localPlayer) end addEvent( "switch", true ) addEventHandler( "switch", localPlayer, switchh )
×
×
  • Create New...