kewizzle Posted April 21, 2017 Share Posted April 21, 2017 so I am trying to create a random survivor script and when the first survivor dies survivorPed it also destroys elements survivorMarker, survivorBlip and survivorPed. But when the next survivor spawns it does not do that and it does not spawn a survivor after 15 seconds. addEventHandler("onResourceStart", root, function() function spawnSurvivor() survivorPed = createPed(livingPeds[rnd2][1], spawns[rnd][1], spawns[rnd][2], spawns[rnd][3], spawns[rnd][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) outputChatBox("The Survivor Was Saved! New one spawning soon.") end spawnSurvivor() addEventHandler("onPedWasted", survivorPed, function() outputChatBox("The Survivor Was Saved! New one spawning soon.") destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) setTimer(spawnSurvivor, 15000, 1) end) end) this works but now the location isnt random function spawnSurvivor() survivorPed = createPed(livingPeds[rnd2][1], spawns[rnd][1], spawns[rnd][2], spawns[rnd][3], spawns[rnd][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) outputChatBox("The Survivor Was Saved! New one spawning soon.") addEventHandler("onPedWasted", survivorPed, function() outputChatBox("The Survivor Was Saved! New one spawning soon.") destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) setTimer(spawnSurvivor, 15000, 1) end) end addEventHandler("onResourceStart", root, function() spawnSurvivor() end) Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 1 hour ago, 3laa33 said: Post the table local spawns = { { -786, 893, 13, 90.0 }, { -767, 882, 13, 120.6928 } } local livingPeds = { { 0 }, { 104 } } Link to comment
AE. Posted April 21, 2017 Share Posted April 21, 2017 local spawns = { { xf = -786, yf = 893, zf = 13, ro = 90.0 }, { xf = -767, yf = 882, zf = 13, ro = 120.6928 } } local livingPeds = { { id = 0 }, { id = 104 } } and rnd = math.random(1,2) rnd2 = math.random(1,2) survivorPed = createPed(livingPeds[rnd2].id, spawns[rnd].xf, spawns[rnd].yf, spawns[rnd].zf, spawns[rnd].ro) Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 1 hour ago, 3laa33 said: local spawns = { { xf = -786, yf = 893, zf = 13, ro = 90.0 }, { xf = -767, yf = 882, zf = 13, ro = 120.6928 } } local livingPeds = { { id = 0 }, { id = 104 } } and rnd = math.random(1,2) rnd2 = math.random(1,2) survivorPed = createPed(livingPeds[rnd2].id, spawns[rnd].xf, spawns[rnd].yf, spawns[rnd].zf, spawns[rnd].ro) still not working as it should, both scripts however did a random spawn and skin on each resource restart tho. Link to comment
AE. Posted April 21, 2017 Share Posted April 21, 2017 (edited) as it should ? what do you want it to do? Edited April 21, 2017 by 3laa33 Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 1 hour ago, 3laa33 said: as it should ? what do do you want it to do? each time the spawnSurvivor function is called by setTimer it spawns a new survivorPed with a random location in the table and a random skin. Basically onPedWasted it destroys the ped, blimp and marker and then 15 seconds later respawns somewhere else, kinda like breifcase. Link to comment
AE. Posted April 21, 2017 Share Posted April 21, 2017 function spawnSurvivor() survivorPed = createPed(livingPeds[rnd2][1], spawns[rnd][1], spawns[rnd][2], spawns[rnd][3], spawns[rnd][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) outputChatBox("The Survivor Was Saved! New one spawning soon.") end addEventHandler("onPedWasted", survivorPed, function() outputChatBox("The Survivor Was Saved! New one spawning soon.") destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) setTimer(spawnSurvivor, 15000, 1) end) get out the pedwasted event from the function and if there is debug errors post it Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 1 hour ago, 3laa33 said: function spawnSurvivor() survivorPed = createPed(livingPeds[rnd2][1], spawns[rnd][1], spawns[rnd][2], spawns[rnd][3], spawns[rnd][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) outputChatBox("The Survivor Was Saved! New one spawning soon.") end addEventHandler("onPedWasted", survivorPed, function() outputChatBox("The Survivor Was Saved! New one spawning soon.") destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) setTimer(spawnSurvivor, 15000, 1) end) get out the pedwasted event from the function and if there is debug errors post it expected element at argument 2 for addEventHandler onPedWasted Link to comment
AE. Posted April 21, 2017 Share Posted April 21, 2017 survivorMarker = 0 survivorBlip = 0 survivorPed = 0 put this in the top of the script Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 1 hour ago, 3laa33 said: survivorMarker = 0 survivorBlip = 0 survivorPed = 0 put this in the top of the script now a single ped spawns but still gives the debug error as well as doesnt destroy the elements onPedWasted or respawn. Link to comment
AE. Posted April 21, 2017 Share Posted April 21, 2017 return the function with the event inside it like it was before i tell you to split them and try Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 1 hour ago, 3laa33 said: return the function with the event inside it like it was before i tell you to split them and try already returned it. It works perfect except the random stuff. Link to comment
NeXuS™ Posted April 21, 2017 Share Posted April 21, 2017 function spawnSurvivor() survivorPed = createPed(livingPeds[rnd2][1], spawns[rnd][1], spawns[rnd][2], spawns[rnd][3], spawns[rnd][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) addEventHandler("onPedWasted", survivorPed, killedPed) outputChatBox("The Survivor Was Saved! New one spawning soon.") end function killedPed() outputChatBox("The Survivor Was Saved! New one spawning soon.") destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) setTimer(spawnSurvivor, 15000, 1) end I suppose you want this. Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 1 hour ago, NeXuS™ said: function spawnSurvivor() survivorPed = createPed(livingPeds[rnd2][1], spawns[rnd][1], spawns[rnd][2], spawns[rnd][3], spawns[rnd][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) addEventHandler("onPedWasted", survivorPed, killedPed) outputChatBox("The Survivor Was Saved! New one spawning soon.") end function killedPed() outputChatBox("The Survivor Was Saved! New one spawning soon.") destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) setTimer(spawnSurvivor, 15000, 1) end I suppose you want this. it doesnt work i get the error bad argument at createMarkerAttachedTo expected element at argument 1 got boolean and when i remove that line(which is needed for further development) i get 3 more errors, createPed expected element at argument 1 got nil and createBlipAttachedTo element expected at argument 1 got boolean and addEventHandler expected element at argument 2 got boolean Link to comment
NeXuS™ Posted April 21, 2017 Share Posted April 21, 2017 local avaibleSkins = { 0, 1, 2 } local spawnPoints = { {0, 0, 0, 0}, {10, 10, 10, 90} } 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], spawns[random2][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) addEventHandler("onPedWasted", survivorPed, killedPed) outputChatBox("The Survivor Was Saved! New one spawning soon.") end function killedPed() outputChatBox("The Survivor Was Saved! New one spawning soon.") destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) setTimer(spawnSurvivor, 15000, 1) end You gotta learn have to fix easy errors like these. 1 Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 1 hour ago, NeXuS™ said: local avaibleSkins = { 0, 1, 2 } local spawnPoints = { {0, 0, 0, 0}, {10, 10, 10, 90} } 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], spawns[random2][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) addEventHandler("onPedWasted", survivorPed, killedPed) outputChatBox("The Survivor Was Saved! New one spawning soon.") end function killedPed() outputChatBox("The Survivor Was Saved! New one spawning soon.") destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) setTimer(spawnSurvivor, 15000, 1) end You gotta learn have to fix easy errors like these. works but aye i can fix the easy errors, I like to speed up the process by posting tho cuz im working on it as you professionals help. Im a moderate scripter i guess. Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 2 hours ago, NeXuS™ said: local avaibleSkins = { 0, 1, 2 } local spawnPoints = { {0, 0, 0, 0}, {10, 10, 10, 90} } 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], spawns[random2][4]) survivorMarker = createMarkerAttachedTo ( survivorPed, "cylinder", 4.0, 0, 0, 255, 255 ) survivorBlip = createBlipAttachedTo( survivorPed, 47 ) addEventHandler("onPedWasted", survivorPed, killedPed) outputChatBox("The Survivor Was Saved! New one spawning soon.") end function killedPed() outputChatBox("The Survivor Was Saved! New one spawning soon.") destroyElement(survivorMarker) destroyElement(survivorBlip) destroyElement(survivorPed) setTimer(spawnSurvivor, 15000, 1) end You gotta learn have to fix easy errors like these. youre really good at scripting so im wondering okay so i got this function hitSurv(playerSource) 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 ) setPedAnimation( survivorPed, "ped", "WOMAN_run") addEventHandler("onMarkerHit", toMarker, hitSurvDes) end i need the ped to follow me once i hit the marker but all i got it to do is run. is there a way to use setPedLookAt to work with the server side created ped? Link to comment
NeXuS™ Posted April 21, 2017 Share Posted April 21, 2017 I think you'll have to use setElementRotation and a ton of math. 1 Link to comment
kewizzle Posted April 21, 2017 Author Share Posted April 21, 2017 1 hour ago, NeXuS™ said: I think you'll have to use setElementRotation and a ton of math. alright lol :~ well i will see what i can cook up Link to comment
kewizzle Posted April 22, 2017 Author Share Posted April 22, 2017 5 hours ago, NeXuS™ said: I think you'll have to use setElementRotation and a ton of math. alright well i played with it couldnt get it to work lol so i just decided to attach the ped to the player. I dont like it but for now i guess i will have to stick with it. 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