awesomenessispure Posted April 16, 2016 Posted April 16, 2016 swatpeds = { [1] = {285, 1572.2216796875, -1626.880859375, 13.3828125} } for k, v in ipairs(swatpeds) do local k = createPed(285, v) givePedWeapon(k, 31, 5000, true) -- Give ped 5000 rounds of M4 end I can't figure out why it is throwing errors... The list swatpeds is the coordinates where the ped should spawn
aka Blue Posted April 16, 2016 Posted April 16, 2016 Try this: local swatpeds = { -- Model, Pox, Posy, Posz {285, 1572.2216796875, -1626.880859375, 13.3828125} } for k, data in ipairs ( swatpeds ) do local ped = createPed ( v[1], v[2], v[3], v[4] ) givePedWeapon ( ped, 31, 5000, true ) end
undefined Posted April 16, 2016 Posted April 16, 2016 swatpeds = { [1] = {285, 1572.2216796875, -1626.880859375, 13.3828125} } for k, v in ipairs(swatpeds) do local ped = createPed(unpack(v)) givePedWeapon(ped, 31, 5000, true) -- Give ped 5000 rounds of M4 end
awesomenessispure Posted April 16, 2016 Author Posted April 16, 2016 I get this error now [17:32:44] ERROR: myserver\script.lua:11: attempt to call global 'givePedWeapon' (a nil value)
awesomenessispure Posted April 16, 2016 Author Posted April 16, 2016 swatpeds = { [1] = {285, 1572.2216796875, -1626.880859375, 13.3828125}, [2] = {285, 1544.6943359375, -1621.15234375, 13.55456161499} } for k, v in ipairs(swatpeds) do local ped = createPed(unpack(v)) local x,y,z = getElementPosition(ped) setPedRotation(ped, 90) giveWeapon(ped, 31, 200, true) end how would i change local ped = createPed(unpack(v)) to be local ped + VALUE OF K = createPed(unpack(v)) so that each ped can have different weps and face different directions. instead of the ped being called just ped I need the peds to be called ped1 and ped2
undefined Posted April 17, 2016 Posted April 17, 2016 swatpeds = { { ped = nil, arguements = {285, 1572.2216796875, -1626.880859375, 13.3828125, 90}, -- model,x,y,z,rotation weapon = { id = 31, ammo = 5000, setAsCurrent = true }, special_function = function(ped) -- eg. setPedHeadless(ped, false) -- TO DO end }, { ped = nil, arguements = {285, 1544.6943359375, -1621.15234375, 13.55456161499, 90}, weapon = { id = 31, ammo = 5000, setAsCurrent = true }, special_function = function(ped) -- eg. setPedHeadless(ped, true) -- TO DO end } } for i, data in ipairs(swatpeds) do local ped = createPed(unpack(data.arguements)) giveWeapon(ped, data.weapon.id, data.weapon.ammo, data.weapon.setAsCurrent) if type(data.special_function) == "function" then data.special_function(ped) end data.ped = ped end You can reach peds with: swatpeds[1].ped swatpeds[2].ped ...
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