-
Posts
980 -
Joined
-
Last visited
-
Days Won
1
Everything posted by manawydan
-
[duvida] não to conseguindo setar acl
manawydan replied to Capitao_Nascimento's topic in Programação em Lua
em lua todo if tem um then e um end para limitar o corpo da função, eu tenho uns tutorias de lua no youtube se achar necessario pode ve-los e tambem uma pequena série sobre mta sa. -
[AJUDA] Determinar o grupo da acl
manawydan replied to Capitao_Nascimento's topic in Programação em Lua
de uma olhada no exemplo da wiki: https://wiki.multitheftauto.com/wiki/IsObjectInACLGroup -
a funcao get é apenas para o lado do server, mas vc pode usar o get pelo server e usar um setElementData no root, para poder pelo client usar getElementData e retornar o valor da setings, essa é uma das formas, vc pode utilizar triggers tambem.
-
Eai pessoal blz? fiz um video simples falando sobre logica de programação e lua. se tudo der certo embreve faço a parte 2.
- 1 reply
-
- 1
-
you can use my code or edit Bonus code like this: local peds = { [1] = {1067.0164794922, 2035.6273193359, 10.8203125, 90}, [2] = {1067.0299072266, 2041.1890869141, 10.8203125, 90}, [3] = {-2067.029296875, 2035.0201416016, 9.8203125,90}, [4] = {2067.0295410156, 1032.1505126953, 10.8203125,90}, [5] = {1067.0295410156, 2027.8729248047, 10.8203125,90} } local createdPeds = {} addEventHandler("onResourceStart", resourceRoot, function () for i=1, 3 do local x,y,z,rot = getRandomizePos() -- now you can use x,y,z,rot variables local ped = createPed (0,x,y,z,rot) --createBlip(x,y,z) end end) function getRandomizePos() local rnd = math.random ( #peds ) while createdPeds[rnd] do rnd = math.random ( #peds ) end table.insert(createdPeds,rnd) local x,y,z,rot = peds[rnd][1],peds[rnd][2],peds[rnd][3],peds[rnd][4] return x,y,z,rot end
-
i make some changes now work: local repeteadIndex = {} local peds = { [1] = {x=1067.0164794922,y=2035.6273193359, z=10.8203125, rot=90}, [2] = {x=1067.0299072266,y=2041.1890869141, z=10.8203125, rot=90}, [3] = {x=-2067.029296875,y=2035.0201416016, z=9.8203125,rot=90}, [4] = {x=2067.0295410156,y=1032.1505126953, z=10.8203125,rot=90}, [5] = {x=1067.0295410156,y=2027.8729248047, z=10.8203125,rot=90} -- the last dont have , } function getRandomizePos() local i repeat i = math.random(#peds) until(table.contains(repeteadIndex,i)==false) table.insert(repeteadIndex,i) local x,y,z,r = peds[i]["x"],peds[i]["y"],peds[i]["z"],peds[i]["rot"] outputChatBox("index: "..i.." value x: "..x.." y: "..y.." z: "..z.." rot: "..r) return x,y,z,r end function table.contains(t,value) for k,v in pairs(t) do if(v==value)then return true end end return false end addEventHandler("onResourceStart", resourceRoot, function () for i=1,3 do local x,y,z,rot = getRandomizePos() local ped = createPed(0,x,y,z,rot) end end) but Bonus code is better
-
try this no tested: local repeteadIndex = {} local peds = { [1] = {x=1067.0164794922,y=2035.6273193359, z=10.8203125, rot=90}, [2] = {x=1067.0299072266,y=2041.1890869141, z=10.8203125, rot=90}, [3] = {x=-2067.029296875,y=2035.0201416016, z=9.8203125,rot=90}, [4] = {x=2067.0295410156,y=1032.1505126953, z=10.8203125,rot=90}, [5] = {x=1067.0295410156,y=2027.8729248047, z=10.8203125,rot=90} -- the last dont have , } function getRandomizePos() local i repeat i = math.random(#peds) until(table.contains(repeteadIndex,i)==false) table.insert(repeteadIndex,i) local x,y,z,r = peds[i]["x"],peds[i]["y"],peds[i]["z"],peds[i]["rot"] outputChatBox("index: "..i.." value x: "..x.." y: "..y.." z: "..z.." rot: "..r) return x,y,z,r end function table.contains(t,value) for k,v in pairs(t) do if(v==value)then return true end end return false end addEventHandler("onResourceStart", resourceRoot, function () for i=1,3 do local x,y,z,rot = getRandomizePos() peds = createPed(0,x,y,z,rot) end end)
-
what you want do? spawn the 5 peds once time?
-
ok try again, code change
-
try this: local peds = { [1] = {x=1067.0164794922,y=2035.6273193359, z=10.8203125, rot=90}, [2] = {x=1067.0299072266,y=2041.1890869141, z=10.8203125, rot=90}, [3] = {x=-2067.029296875,y=2035.0201416016, z=9.8203125,rot=90}, [4] = {x=2067.0295410156,y=1032.1505126953, z=10.8203125,rot=90}, [5] = {x=1067.0295410156,y=2027.8729248047, z=10.8203125,rot=90} -- the last dont have , } function getRandomizePos() local i = math.random(#peds) local x,y,z,r = peds[i]["x"],peds[i]["y"],peds[i]["z"],peds[i]["rot"] outputChatBox("index: "..i.." value x: "..x.." y: "..y.." z: "..z.." rot: "..rot) return x,y,z,r end addEventHandler("onResourceStart", resourceRoot, function () local x,y,z,rot = getRandomizePos() peds = createPed(0,x,y,z,rot) end)
-
vc quer converter as posicoes x,y dos dx?
-
try this: function vehicledamaged (thePlayer) -- source is the vehicle setVehicleDamageProof (source, false) -- damagable fixVehicle (source) end addEventHandler ( "onVehicleEnter", getRootElement(), vehicledamaged ) function vehicleundamaged (thePlayer) setVehicleDamageProof (source, true) -- not damagable fixVehicle (source) end addEventHandler ( "onVehicleExit", getRootElement(), vehicleundamaged )
-
thanks man works fine!
-
because i use notepad
-
so i am want do this: local weaponsTable = { {name="Soldier",weaponsID={31,22,16},weaponsAmmo = {1000,50,1}}, {name="Soldier2",weaponsID={31,22,16},weaponsAmmo = {2000,100,2}} } function giveWeaponsByLevel(player) local armyLevel = "Soldier" -- first index(1) local index = table.getIndexByValue(weaponsTable,armyLevel) -- index should be 1 local name,weaponID,weaponsAmmo = unpack(weaponsTable[index]) -- name should be "Soldier", weaponID should be weaponsID={31,22,16}, -- weaponsAmmo should be weaponsAmmo = {1000,50,1} -- so give weapons by the weaponsTable[index] for i=1,#weaponID do giveWeapon(player,weaponID[i],weaponsAmmo[i]) end end function table.getIndexByValue(t,value) for i,v in pairs(t) do -- or ipairs, if count zero if(v == value) then return i elseif(type(v) == "table") then return table.getIndexByValue(v,value) -- recursion, call the same function for internal tables end end end but index return nil instead 1
-
anyone?
-
so, i am try get the first table index checking with value function table.getIndexByValue(t,value) for i=1,#t do if(type(t[i])=="table")then local rila = t[i] for j=1,#t[i] do if(rila[j]==value)then return i -- return the first index end end end if(t[i]==value)then return i -- return the first index end end end i make this function but dont work with sub-table only with table how i can make the function check tables inside tables(sub-table)?
-
lol a noob error thanks man
-
so, i am try make one gamemode, but i am get error in spawn core_server line 62,63 "spawnpoint" nil. --[[ Project: Humans vs Zombies Script: core_server author: Manawydan ]] local firtsPlayerZombie = nil local roundTimer = nil local playerTeam = createTeam("Survivors",0,0,255) local zombieTeam = createTeam("Zombies",255,0,0) local roundDuration = 10*60*1000 local playersTable = {} local playerSkins = {0,1,2,3} local zombieSkin = {5,6,7} function Start() local player_n = #UpdatePlayerTable() if(player_n>=2)then StartRoundNormal() else StartRoundNoPlayers() end end function UpdatePlayerTable() playersTable = {} for k,v in ipairs(getElementsByType("player")) do table.insert(playersTable,v) end return playersTable end function StartRoundNormal() SpawnPlayers() setTimer(SetFirtsPlayerZombie,10*1000,1) roundTimer = exports.missiontimer:createMissionTimer (roundDuration,true,"%m:%s",0.5,10,true,"default-bold",1,255,255,255) addEventHandler ( "onMissionTimerElapsed", roundTimer,OnTimerOver ) end function StartRoundNoPlayers() end function OnMapLoad(startedMap) mapRoot = getResourceRootElement(startedMap) outputChatBox("map started ok!") UpdatePlayerTable() StartRoundNormal() end addEventHandler ( "onGamemodeMapStart", root, OnMapLoad ) function OnGamemodeStart() outputChatBox("gamemode start ok") end addEventHandler ( "onGamemodeStart", resourceRoot, OnGamemodeStart ) function SpawnPlayers() local mapSpawns = getElementsByType("spawnpoint") print("number spawns: "..#mapSpawns.." players: "..#playersTable) for k,v in ipairs(playersTable) do local spIndex = mapSpawns[math.random(#mapSpawns)] local x = getElementData(mapSpawns[spIndex],"posX") local y = getElementData(mapSpawns[spIndex],"posY") local z = getElementData(mapSpawns[spIndex],"posZ") local rot = math.random(359) local skin = playerSkins[math.random(#playerSkins)] spawnPlayer(v,x,y,z,rot,skin) setPlayerTeam(v,playerTeam) end end function SetFirtsPlayerZombie() if(#UpdatePlayerTable()>=2)then firtsPlayerZombie = getRandomPlayer() triggerEvent("onPlayerBecameZombie",firtsPlayerZombie) outputChatBox("O player: "..getPlayerName(firtsPlayerZombie).." Virou Zombie!") end end function SetPlayerZombie() takeAllWeapons(source) setElementModel(source,zombieSkin[math.random(#zombieSkin)]) setElementData(source,"zombie",true) setElementHealth(source,200) setPlayerTeam(source,zombieTeam) end addEvent("onPlayerBecameZombie",true) addEventHandler("onPlayerBecameZombie",root,SetPlayerZombie) function OnTimerOver() end _getPlayerName = getPlayerName getPlayerName = function(player) return string.gsub(_getPlayerName (player),"#%x%x%x%x%x%x","") end meta: <meta> <info author="Manawydan" name = "Players Vs Zombies" version="1" type="gamemode" edf:definition="edf/playersVsZombies.edf" /> <script src="core_client.lua" type="client" /> <script src="core_server.lua" type="server" /> </meta> edf(inside gamemode edf folder): <def name = "Players Vs Zombies"> <element name = "spawnpoint" friendlyname = "spawnPoint"> <data name = "position" type = "coord3d" default="0,0,0"/> </element> </def> And a little test map: <map edf:definitions="Players_vs_Zombies,editor_main"> <pickup id="pickup (Colt 45) (1)" type="22" interior="0" amount="100" respawn="30000" dimension="0" alpha="255" posX="249.89999" posY="1800.5" posZ="7.4" rotX="0" rotY="0" rotZ="0"></pickup> <spawnpoint id="spawnpoint1" posX="250.10000610352" posY="1801.1999511719" posZ="7"/> </map> the problem is player not spawn, get error in line 62,63, say the position vector is nil. Anyone can help? Thanks
-
faz um tempo fiz um sistema de inventario simples: https://community.multitheftauto.com/in ... s&id=11668 de uma olhada talvez possa ser util para voce entender
-
so i have one old inventory script: https://community.multitheftauto.com/in ... s&id=11668 maybe can help.
-
voce pode criar uma tabela que contenha os player que ganharam(verificando se o numero do "bilhete" dele for o sorteado) ai pode usar #nomeDaTabela que vai retornar a quantidade de elementos da tabela(no caso o numero de vencedores), então use um for pra dar dinheiro aos players da tabela, a quantidade de dinheiro de cada um seria dinheiroTotal/#nomeDaTabela
-
can post your scripts?
-
i dont see erros, mta bug?