kewizzle Posted October 4, 2020 Share Posted October 4, 2020 so when i deliver the ped to the marker it spawns two instead of one local avaibleSkins = { 0, 104 } local spawnPoints = { { -1221.7, 457.3, 7.2, 90.0 }, { -1388.8, 440.8, 7.2, 180.0 }, { -1676.1, 413.4, 7.2, 180.0 }, } function createMarkerAttachedTo(element, mType, size, r, g, b, a, visibleTo, xOffset, yOffset, zOffset) mType, size, r, g, b, a, visibleTo, xOffset, yOffset, zOffset = mType or "checkpoint", size or 4, r or 0, g or 0, b or 255, a or 255, visibleTo or getRootElement(), xOffset or 0, yOffset or 0, zOffset or 0 assert(isElement(element), "Bad argument @ 'createMarkerAttachedTo' [Expected element at argument 1, got " .. type(element) .. "]") assert(type(mType) == "string", "Bad argument @ 'createMarkerAttachedTo' [Expected string at argument 2, got " .. type(mType) .. "]") assert(type(size) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 3, got " .. type(size) .. "]") assert(type(r) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 4, got " .. type(r) .. "]") assert(type(g) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 5, got " .. type(g) .. "]") assert(type(b) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 6, got " .. type(b) .. "]") assert(type(a) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 7, got " .. type(a) .. "]") assert(isElement(visibleTo), "Bad argument @ 'createMarkerAttachedTo' [Expected element at argument 8, got " .. type(visibleTo) .. "]") assert(type(xOffset) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 9, got " .. type(xOffset) .. "]") assert(type(yOffset) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 10, got " .. type(yOffset) .. "]") assert(type(zOffset) == "number", "Bad argument @ 'createMarkerAttachedTo' [Expected number at argument 11, got " .. type(zOffset) .. "]") local m = createMarker(0, 0, 0, mType, size, r, g, b, a, visibleTo) if m then if attachElements(m, element) then return m end end return false end function killedPed() outputChatBox("The Survivor Was Killed! New One Spawning!", server, 255, 0, 0) destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) destroyElement(toMarker) destroyElement(saveBlip) setTimer(spawnSurvivor, 30000, 1) end function hitSurv(playerSource, thePlayer) local theVehicle = getPedOccupiedVehicle ( playerSource ) if theVehicle then outputChatBox(getPlayerName(playerSource).." Has Collected The Survivor!", server, 0, 255, 0) destroyElement(survivorMarker) destroyElement(survivorBlip) setElementData(playerSource, "hasSurv", true) toMarker = createMarker(-719, 951, 11, "cylinder", 3, 255, 0, 255, 150, playerSource) saveBlip = createBlipAttachedTo( toMarker, 22 ) warpPedIntoVehicle ( survivorPed, theVehicle, 1 ) else outputChatBox("You Need A Vehicle!", playerSource, 255, 0, 0) end addEventHandler("onMarkerHit", toMarker, hitSurvDes) end function hitSurvDes(playerSource) destroyElement(toMarker) destroyElement(survivorPed) destroyElement(saveBlip) givePlayerMoney(playerSource, math.random(500, 1000)) outputChatBox("Survivor Saved Spawning New One In 30 Secs.", server, 0, 255, 0) setElementData(playerSource, "hasSurv", false) setTimer(spawnSurvivor, 30000, 1) end function spawnSurvivor() local random1 = math.random(1, #avaibleSkins) local random2 = math.random(1, #spawnPoints) survivorPed = createPed(avaibleSkins[random1], spawnPoints[random2][1], spawnPoints[random2][2], spawnPoints[random2][3], spawnPoints[random2][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) addEventHandler("onPedWasted", survivorPed, killedPed) addEventHandler("onMarkerHit", survivorMarker, hitSurv) outputChatBox("New Survivor Spawned! Save him for cash.", server, 0, 255, 0) end addEventHandler("onResourceStart", root, function() spawnSurvivor() end) function pedEnter() vehicle = getPlayerVehicle(source) warpPedIntoVehicle(survivorPed, vehicle) end addEventHandler("onClientVehicleEnter", root, pedEnter) Spoiler Link to comment
Tekken Posted October 4, 2020 Share Posted October 4, 2020 try this addEventHandler("onResourceStart", resourceRoot, function()-- root may start 2 times if you have 2 resources spawnSurvivor() end) function hitSurv(playerSource, thePlayer) if not getElementType(playerSource) == "player" then return end -- you might check if it's a player local theVehicle = getPedOccupiedVehicle ( playerSource ) if theVehicle then outputChatBox(getPlayerName(playerSource).." Has Collected The Survivor!", server, 0, 255, 0) destroyElement(survivorMarker) destroyElement(survivorBlip) setElementData(playerSource, "hasSurv", true) toMarker = createMarker(-719, 951, 11, "cylinder", 3, 255, 0, 255, 150, playerSource) saveBlip = createBlipAttachedTo( toMarker, 22 ) warpPedIntoVehicle ( survivorPed, theVehicle, 1 ) else outputChatBox("You Need A Vehicle!", playerSource, 255, 0, 0) end end addEventHandler("onMarkerHit", toMarker, hitSurvDes) 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