AGENT_STEELMEAT Posted October 11, 2011 Share Posted October 11, 2011 local pedModel = 23 local pedPositions = { {-3666.6447753906,-2015.8166503906,11.793441772461,124.23803710938}, {-3660.0227050781,-2013.6018066406,9.9486846923828,124.23803710938}, {-3652.7902832031,-2014.0773925781,8.7459049224854,124.23803710938}, {-3609.2392578125,-2068.7431640625,6.6531052589417,118.68984985352}, {-3600.7316894531,-2065.0659179688,6.3656249046326,123.07897949219}, {-3590.8957519531,-2061.6762695313,6.3656249046326,126.83633422852}, {-3585.2629394531,-2059.3198242188,6.2059550285339,122.42526245117} } --To start off, create the first ped local dummyPed = createPed(pedModel, pedPositions[1][1], pedPositions[1][2], pedPositions[1][3], pedPositions[1][4]) setElementData(dummyPed, "ID", 1, false) addEventHandler("onPedWasted", dummyPed, onDummyPedKill) --This function is triggered whenever one of the peds create by this script is killed. function onDummyPedKill(killer) local pedID = getElementData(source, "ID") if pedID = 1 then dummyPed = nil --Clear the 'dummyPed' variable from memory. end if pedID == #pedPositions then --Detect whether or not this is the last ped outputDebugString("Ped dummy killing spree complete!") removeEventHandler("onPedWasted", source, onDummyPedKill) --You could also remove this and use destroyElement(source) instead. triggerEvent("finish2", killer) return else local newID = pedID + 1 local dummyPed = createPed(pedModel, pedPositions[newID][1], pedPositions[newID][2], pedPositions[newID][3], pedPositions[newID][4]) setElementData(dummyPed, "ID", newID, false) addEventHandler("onPedWasted", dummyPed, onDummyPedKill) return end end To start, you create the first ped, and attach onPedWasted to the function onDummyPedKill - which will create the next ped if neccesary, or end the mission if it is the last ped. Also, I used a table to store the coordinates, so now you can just add entries to the table to expand the script, rather than adding a bunch of if statements. Link to comment
Jaysds1 Posted October 11, 2011 Author Share Posted October 11, 2011 thanks, but How do I know if it's the last ped? The first 3 peds killed, the person that killed them goes to another station then they get another weapon, how do I add this to this script? Link to comment
AGENT_STEELMEAT Posted October 11, 2011 Share Posted October 11, 2011 It already does - if the peds ID matches the length of the table, then you know its the last one. Link to comment
Jaysds1 Posted October 11, 2011 Author Share Posted October 11, 2011 ok, I see what you did now, thanks Link to comment
Jaysds1 Posted October 12, 2011 Author Share Posted October 12, 2011 @John_Michael, The same problem persist, The event wont trigger for the player that killed the peds, it says "Expected element at argument 2, got number("0"), How do I fix this? Link to comment
Castillo Posted October 12, 2011 Share Posted October 12, 2011 Could you explain me what are you trying to do? Link to comment
AGENT_STEELMEAT Posted October 12, 2011 Share Posted October 12, 2011 Change function onDummyPedKill(killer) to function onDummyPedKiller(_, killer) Link to comment
Jaysds1 Posted October 13, 2011 Author Share Posted October 13, 2011 @Solidsnake14, The problem was, When the eventhandler onPedWasted triggered, the triggerEvent function didn't worked for the player who killed the ped, but John helped me, thanks for trying @John_Michael, Thanks, it works now Link to comment
Jaysds1 Posted November 19, 2011 Author Share Posted November 19, 2011 Hi everyone, I want to bind a table of keys but I get an debug error message saying " [2011-11-18 21:04:59] WARNING: [gameplay]\save\server.lua:39: Bad argument @ 'bindKey'", here's my code: local key = {"[", "]", ";", "'", ","} bindKey(source,key,"down",(DON'T NEED TO KNOW)) thanks for helping... Link to comment
Castillo Posted November 19, 2011 Share Posted November 19, 2011 With just two lines we can't help you, post the whole code, or at least the function where you bind it. Link to comment
Jaysds1 Posted November 19, 2011 Author Share Posted November 19, 2011 ok addCommandHandler("saveM", -- save position, where the markers going to go function(player,command,comment) if (command) then comment = tostring(comment) local x,y,z = getElementPosition(player) outputChatBox("What type of marker do you want: Press [ = checkpoint, ] = ring, ; = cylinder, ' = arrow, , = corona.",player,100,0,0) local key = {"[", "]", ";", "'", ","} bindKey(source,key,"down", function(source,key,keystate) if (key == "[") then local Mtype = "checkpoint" outputChatBox("What do you want your marker size to be? (1 -10)",source,100,0,0) unbindKey(source,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(source,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) elseif (key == "]") then local Mtype = "ring" outputChatBox("What do you want your marker size to be? (1 -10)",player,100,0,0) unbindKey(player,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(player,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) elseif (key == ";") then local Mtype = "cylinder" outputChatBox("What do you want your marker size to be? (1 -10)",player,100,0,0) unbindKey(player,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(player,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) elseif (key == "'") then local Mtype = "arrow" outputChatBox("What do you want your marker size to be? (1 -10)",player,100,0,0) unbindKey(player,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(player,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) elseif (key == ",") then local Mtype = "corona" outputChatBox("What do you want your marker size to be? (1 -10)",player,100,0,0) unbindKey(player,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(player,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) end end) end end) Link to comment
Castillo Posted November 19, 2011 Share Posted November 19, 2011 addCommandHandler("saveM", -- save position, where the markers going to go function(player,command,comment) if (command) then comment = tostring(comment) local x,y,z = getElementPosition(player) outputChatBox("What type of marker do you want: Press [ = checkpoint, ] = ring, ; = cylinder, ' = arrow, , = corona.",player,100,0,0) local key = {"[", "]", ";", "'", ","} bindKey(player,key,"down", function(player,key,keystate) if (key == "[") then local Mtype = "checkpoint" outputChatBox("What do you want your marker size to be? (1 -10)",player,100,0,0) unbindKey(player,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(player,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) elseif (key == "]") then local Mtype = "ring" outputChatBox("What do you want your marker size to be? (1 -10)",player,100,0,0) unbindKey(player,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(player,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) elseif (key == ";") then local Mtype = "cylinder" outputChatBox("What do you want your marker size to be? (1 -10)",player,100,0,0) unbindKey(player,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(player,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) elseif (key == "'") then local Mtype = "arrow" outputChatBox("What do you want your marker size to be? (1 -10)",player,100,0,0) unbindKey(player,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(player,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) elseif (key == ",") then local Mtype = "corona" outputChatBox("What do you want your marker size to be? (1 -10)",player,100,0,0) unbindKey(player,key) local numbers = {1,2,3,4,5,6,7,8,9,10} bindKey(player,tostring(numbers),"down", function(player,numbers,keystate) if (numbers) then local Msize = tonumber(numbers) local markerID = {x,y,z,Mtype,Msize} triggerEvent("Marker",getRootElement(),markerID,comment) unbindKey(player,numbers) end end) end end) end end) Link to comment
Jaysds1 Posted November 19, 2011 Author Share Posted November 19, 2011 now i get this error: [2011-11-18 21:46:00] WARNING: [gameplay]\save\server.lua:39: Bad 'player' pointer @ 'bindKey'(1) Link to comment
Castillo Posted November 19, 2011 Share Posted November 19, 2011 Your script is a mess, you are creating like 6 functions to do the same thing, why not just create one? Link to comment
Jaysds1 Posted January 22, 2012 Author Share Posted January 22, 2012 Hi all, Today/Tonight I'm having trouble with this and I get this error in console: [2012-01-22 02:59:28] ERROR: [gameplay]\JL\server.lua:3: dbConnect failed; Can't connect to MySQL server on 'mysql13.000webhost.com' (10060) this is all I got in the script: addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function() cnct = dbConnect("mysql","dbname=a4528318_players;host=mysql13.000webhost.com","a4528318_JWP","*********") end) Is this an error or bug? Link to comment
BinSlayer1 Posted January 22, 2012 Share Posted January 22, 2012 the link is just not working I suppose browsers should return something but mine just says "connecting" 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