Jump to content

Problems


Jaysds1

Recommended Posts

  
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
  • Replies 365
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 month later...

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

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
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
  • 2 months later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...