-
Posts
104 -
Joined
-
Last visited
Everything posted by Maaster
-
Como dar dinheiro para todos os membros de uma equipe?
Maaster replied to Maaster's topic in Programação em Lua
Consegui fazer isso que eu queria, o codigo ficou assim: moneyTimer = setTimer ( function () local Team = getPlayerTeam(element) if ( Team ) then if getTeamName(Team) == nomePlayer then local players = getPlayersInTeam(Team) for playerKey, playerValue in ipairs ( players ) do givePlayerMoney(playerValue, 100) end end end end,5000,0) esta funcionando, mas quando o jogador que dominou a area sai do servidor, todos param de receber dinheiro e começa a aparecer no debug o warning "Bad argument @ 'getPlayerTeam' [Expected player at argument 1]", como posso resolver isso? -
Como dar dinheiro para todos os membros de uma equipe?
Maaster replied to Maaster's topic in Programação em Lua
Vendo seu codigo tentei aqui, mas nao deu certo, bom, oque eu realmente quero fazer eh quando uma equipe dominar a favela, todos os jogadores desta equipe vao ficar ganhando 10000 a cada 10 minutos, ai esta o codigo do script: local sql = { Query = executeSQLQuery }; cooldawnTimer = false addEventHandler( 'onResourceStart', resourceRoot, function() sql.Query( "CREATE TABLE IF NOT EXISTS areas1 (`atualEquipe1` TEXT NOT NULL)") local insert = true local busca = sql.Query( "SELECT * FROM areas1" ) for i = 1, #busca do insert = false end if(insert == true) then sql.Query( "INSERT INTO areas1 (atualEquipe1) VALUES ('ninguem')") end sql.Query( "UPDATE areas1 SET atualEquipe1 = 'ninguem'") end ); ----------------------------------------Marker---------------------------------------- local marker = createMarker (2499.1157226563,-877.779296875,114.53281402588, "cylinder",2,255 ,0 ,0, 100) local entrar = createMarker (2499.1157226563,-877.779296875,114.53281402588 +1, "arrow", 0, 000,0, 0) ----------------------------------------Blip---------------------------------------- local blip = createBlipAttachedTo ( entrar, 23 ) setBlipVisibleDistance(blip, 250) ----------------------------------------Ao entrar no marker---------------------------------------- function texto () local busca = sql.Query( "SELECT * FROM areas1" ) for i = 1, #busca do triggerClientEvent(root,"onDominate1", root, busca[i].atualEquipe1 ) end end setTimer ( texto, 1000, 0) local hillRadar = createRadarArea(2331.3779296875,-1066.1728515625,350,220,255,0,0,0) function mensagem (source) outputChatBox("#000000[ #FF0000Favela 1 #000000]#FFFFFF Digite #FF0000/dominar",source,255,255,255,true) end addEventHandler("onMarkerHit",marker,mensagem) ----------------------------------------/dominar---------------------------------------- function mastering (element) if not isElementWithinMarker(element, marker) then return end if getElementType(element) == "player" then local inTeam = getPlayerTeam (element) if inTeam then if cooldawnTimer == true then outputChatBox("#000000[ #FF0000Erro #000000]#FFFFFF Esta favela acabou de ser dominada, espere alguns minutos!", element, 255, 255, 255, true) else if getElementData(element,"ModoPassivo") then outputChatBox("#000000[#FF0000 Erro #000000]#FFFFFF Voce esta com o modo passivo ativado!", element, 255, 0, 0, true) else if getElementData(element,"Dominando") then outputChatBox("#000000[#FF0000 Erro #000000]#FFFFFF Espere 1 minuto para usar este comando novamente!", element, 255, 0, 0, true) else --Corp: if getTeamName(inTeam) == "Bope" or getTeamName(inTeam) == "PM" then if nomePlayer == "Bope" or nomePlayer == "PM" then -- Se a favela ja estiver pacificada outputChatBox("#000000[ #FF0000Erro #000000]#FFFFFF Esta favela ja foi pacificada, nao deixe outras gangs domina-la novamente!", element,255,255,255,true) else if nomePlayer == nil then -- Se a favela nao pertencer a nenhuma gang outputChatBox("#000000[ #FF0000Erro #000000]#FFFFFF Esta favela nao foi dominada por nenhuma gang!", element,255,255,255,true) else triggerClientEvent(element,"Temp1",element) r, g, b = getTeamColor ( inTeam ) outputChatBox("#000000[ #FF0000Favela 1 #000000]#FFFFFF A #0000FF"..getTeamName(inTeam).." #FFFFFFesta #00FF00pacificando #FFFFFFa Favela 1 que pertence a gang #FF0000"..(nomePlayer or ""), root,255,255,255,true) setRadarAreaFlashing ( hillRadar, true ) setElementData(element,"Dominando",true)--ganha o elementdata Domindando ao digitar /dominar setTimer (setElementData, 60000, 1, element, "Dominando", false)--remove o elementdata Dominando depois de 1 minuto Favela1time = setTimer (function() setRadarAreaFlashing ( hillRadar, false ) givePlayerMoney(element,42000) -- Dinheiro ganho ao pacificar outputChatBox("#000000[ #FF0000Favela 1 #000000]#FFFFFF Voce recebeu #00FF0042.000R$#FFFFFF por pacificar a favela!", element,255,255,255,true) -- Msg pro policiial que pacificar outputChatBox("#000000[ #FF0000Favela 1 #000000]#FFFFFF A #0000FF"..getTeamName(inTeam).."#FFFFFF conseguiu #00FF00 pacificar#FFFFFF a Favela 1", root,255,255,255,true) nomePlayer = getTeamName(inTeam) sql.Query( "UPDATE areas1 SET atualEquipe1 = '".. nomePlayer .."'") r, g, b = getTeamColor ( inTeam ) setRadarAreaColor(hillRadar, r ,g ,b, 130) triggerClientEvent(element,"TimerStamp1",element) setMarkerColor(marker, 125 ,38 ,205, 80) cooldawn() end,60000,1) end end --Gang: else if getTeamName(inTeam) == nomePlayer then --Se a favela ja for da gang do jogador outputChatBox("#000000[ #FF0000Erro #000000]#FFFFFF Esta favela ja pertence a sua gang, apenas defenda ela!", element,255,255,255,true) else triggerClientEvent(element,"Temp1",element) r, g, b = getTeamColor ( inTeam ) outputChatBox("#000000[ #FF0000Favela 1 #000000]#FFFFFF A gang #FF0000"..getTeamName(inTeam).."#FFFFFF esta#FFFFFF dominando a Favela 1 que pertence a #FF0000"..(nomePlayer or ""), root,255,255,255,true) setRadarAreaFlashing ( hillRadar, true ) setElementData(element,"Dominando",true) --ganha o elementdata Domindando ao digitar /dominar setTimer (setElementData, 60000, 1, element, "Dominando", false) --remove o elementdata Dominando depois de 1 minuto Favela1time = setTimer (function() setRadarAreaFlashing ( hillRadar, false ) outputChatBox("#000000[ #FF0000Favela 1 #000000]#FFFFFF A gang #FF0000"..getTeamName(inTeam).."#FFFFFF dominou a Favela 1 que pertencia a #FF0000"..(nomePlayer or ""), root,255,255,255,true) nomePlayer = getTeamName(inTeam) sql.Query( "UPDATE areas1 SET atualEquipe1 = '".. nomePlayer .."'") r, g, b = getTeamColor ( inTeam ) setRadarAreaColor(hillRadar, r ,g ,b, 130) triggerClientEvent(element,"TimerStamp1",element) setMarkerColor(marker, 125 ,38 ,205, 80) if getPlayerWantedLevel(element) < 6 then -- se o jogador tiver menos de 6 levels de procurado setPlayerWantedLevel(element,getPlayerWantedLevel(element)+1) -- adiciona mais um level de procurado ao jogador que dominar end cooldawn() end,60000,1) ------------------------------Dar money a gang que esta em posse da favela------------------------------ favela1Money = setTimer (function () local players = getPlayersInTeam(inTeam) if players == nomePlayer then for i, p in ipairs(players) do setPlayerMoney(p, givePlayerMoney(p) + 1000) end end end,3000,0) ------------------------------.------------------------------ end end end end end else outputChatBox("#000000[ #FF0000Favela 1 #000000]#FFFFFF Você precisa ser membro de alguma corp ou gang para dominar ou pacificar a Favela1", element,255,255,255,true) end end end addCommandHandler("dominar", mastering) ----------------------------------------Ao sair do marker enquanto domina---------------------------------------- function onLeave (element) triggerClientEvent(element,"TimerStamp1",element) setRadarAreaFlashing ( hillRadar, false ) if (isTimer(Favela1time)) then if not killTimer(Favela1time) then return end outputChatBox("#000000[ #FF0000Favela 1 #000000]#FFFFFF Volte para o marker para continuar dominando!", element,255,255,255,true) end end addEventHandler("onMarkerLeave",marker,onLeave) ----------------------------------------Cooldawn para dominar---------------------------------------- function cooldawn () if cooldawnTimer == false then cooldawnTimer = true else end setTimer(function() cooldawnTimer = false outputChatBox("#000000[ #FF0000Favela 1 #000000]#FFFFFF A Favela 1 ja pode ser dominada novamente!", root, 255, 255, 255, true) end, 60000*60*0.2, 1) end eu teria que usar local "inTeam = getPlayerTeam (element)" novamente? nao coloquei pois ja tem isso um pouco mais acima no script e na funcao de dominar. tambem nao esta dando nenhun error ou warning no debugscript -
Por exemplo, quero fazer algo tipo, /gangmoney ai todos os jogadores que estiverem na mesma equipe de que quem digitou o comando "/gangmoney" ganhem 10k e não apenas o jogador que digitou e sim todos que fazem parte da equipe dele
-
Entendi, obrigado!! e uma ultima duvida, quando um jogador leva dano, ele recebe o ElementData "emCombate", e depois de 10 segundos o ElementData "emCombate" é removido, isso não usa muito processamento? function tomouDano ( attacker ) if not getElementData ( source, "emCombate" ) then if not (attacker) then return end if getElementType(attacker) == "player" then setElementData ( source, "emCombate", true ) setTimer ( setElementData, 10000, 1, source, "emCombate", false ) end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), tomouDano )
-
Entendi, mais voltando a pergunta que fiz la em cima, usar getElementDimension pra verificar se o jogador esta na arena, ficaria mais leve?
-
O 'valor' seria 'true' e 'false' certo?
-
Hmm... e como eu posso configurar para não ser sincronizado, e oque afetaria isso no script?
-
mas n daria no mesmo? os ElementData que mais estou usando, sao ativados ao estar em alguma arena ou trabalho, n ate o jogador deslogar
-
Como posso fazer isso?
-
São temporárias, ativam quando o player esta em um local especifico ou acontece algo especifico com ele, como ser algemado ou levar dano
-
Entendi, e se por exemplo, eu colocar todas as arenas do servidor na dimensao 10, e em vez de setar o ElementData "emArena" para depois bloquear os comandos e teclas, apenas usar isso: addEventHandler("onClientKey", root, function (button, press) if (getElementDimension(getLocalPlayer()) == 10) then if button == "F1" or button == "F5" or button == "F5" or button == "o" or button == "m" or button == "i" then cancelEvent() end end end seria melhor?
-
Tabelas? if getElementData(source,"algemado") or getElementData(source,"preso") or getElementData(source,"emArena") or getElementData(source,"AirNew>Entrada>BoateSF") or getElementData(source,"astronaut:isJobber") then outputChatBox("#000000[#FF0000 Erro #000000]#FFFFFF Você não pode pegar um carro aqui!", source, 255, 255, 255, true) return end voce diz para fazer algo assim, ou daria no mesmo?
-
Bom, estou com uma duvida aqui, queria saber se ao usar muito getElementData vai pesar e causar lags no servidor, se sim, como eu poderia fazer o codigo abaixo: if getElementData(source,"algemado") then outputChatBox("#000000[#FF0000 Erro #000000]#FFFFFF Você não pode pegar um carro enquanto esta algemado!", source, 255, 255, 255, true) return end if getElementData(source,"preso") then outputChatBox("#000000[#FF0000 Erro #000000]#FFFFFF Você não pode pegar um carro dentro da prisao!", source, 255, 255, 255, true) return end if getElementData(source,"emArena") then outputChatBox("#000000[#FF0000 Erro #000000]#FFFFFF Você não pode pegar um carro em arenas!", source, 255, 255, 255, true) return end if getElementData(source,"AirNew>Entrada>BoateSF") then outputChatBox("#000000[#FF0000 Erro #000000]#FFFFFF Você não pegar um carro na boate!", source, 255, 255, 255, true) return end if getElementData(source,"astronaut:isJobber") then outputChatBox("#000000[#FF0000 Erro #000000]#FFFFFF Você não pode pegar um carro enquanto trabalha!", source, 255, 255, 255, true) return end if getElementData(source,"PegouCarro") then outputChatBox("#000000[#FF0000 Erro #000000]#FFFFFF Espere 15 segundos para pegar outro carro !", source, 255, 255, 255, true) return end
-
Qual a funcao pra mudar a velocidade de um player?
Maaster replied to Maaster's topic in Programação em Lua
usei: setElementSpeed(thePlayer, 1) e esta dando o error attempt to call global 'setElementSpeed 'onRecallTeam' (a nil value) no debugscript. E também, esta função não e para veiculos? -
tentei usar: setGameSpeed(thePlayer, 1) n funcionou e apareceu no debug o warning ( Bad argument @ 'setGameSpeed' [Expected number at argument 1, got player] ), ai dei uma olhada em outros scripts que mexia na speed e tentei: setGameSpeed (1) deu certo, mas esta mudando a velocidade de todos os jogadores do servidor, n apenas de um. este eh o codigo: --------------------Arena zombie-------------------- g_base_cols = createColCuboid(-1235.681, -1084.753, 128, 260, 215, 100) hits1 = function(thePlayer) outputChatBox("Voce entrou na arena zombie!", thePlayer, 0, 255, 0, true) setElementData(thePlayer, "emZombie", true) takeWeapon(thePlayer, 28) takeWeapon(thePlayer, 32) takeWeapon(thePlayer, 16) takeWeapon(thePlayer, 39) setGameSpeed (1) end addEventHandler("onColShapeHit", g_base_cols, hits1) --Sair da arena: leaves1 = function(thePlayer) outputChatBox("Voce saiu da arena zombie!", thePlayer, 255, 255, 0, true) setElementData(thePlayer, "emZombie", false) end addEventHandler("onColShapeLeave", g_base_cols, leaves1)
-
No client esta assim: -- Client-side addEvent("passive.ghostmode", true) addEventHandler("passive.ghostmode", resourceRoot, function(vehicle) for i, v in pairs(getElementsByType("vehicle")) do setElementCollidableWith(vehicle, v, false) end end) e no server esta assim: -- Entrar no veiculo -- Server-side addEventHandler("onVehicleEnter", root, function(thePlayer, seat) if seat == 0 then if getElementData(thePlayer, "ModoPassivo") then setElementAlpha(source, 225) triggerClientEvent("passive.ghostmode", resourceRoot, source) end end end) eu entro em um carro e consigo bater normalmente em outros, tambem não esta dando nenhum error ou warning no debugscript
-
Eh... dei uma lida la mais realmente n entendi mt coisa, meu codigo ta assim agora client: function ghostmode ( thePlayer ) if getElementData(source,"ModoPassivo") then setElementCollidableWith(thePlayer, false) end end addEvent( "ghostmode", true ) addEventHandler( "ghostmode", root, ghostmode ) server: function ghostmode( thePlayer ) triggerClientEvent(thePlayer,"ghostmode",thePlayer) end addEventHandler("onVehicleEnter",root,ghostmode)
-
Eu deixo o setElementCollidableWith(source, false) no server ou client? function ghostmode ( thePlayer ) if getElementData(thePlayer,"ModoPassivo") then setElementCollidableWith(source, false) end end addEvent( "ghostmode", true ) addEventHandler( "ghostmode", localPlayer, ghostmode ) deixei isso no client e isso abaixo no server? function ghostmode( thePlayer ) triggerClientEvent(thePlayer,"ghostmode") end addEventHandler("onVehicleEnter",root,ghostmode) e nao deu certo
-
Vlw mano, consegui aqui, agora falta a colisão kkk dei uma olhada na wiki e tentei isso ai: addEventHandler("onVehicleEnter",root, function(thePlayer, seat) if seat == 0 then if getElementData(thePlayer,"ModoPassivo") then setElementAlpha(source,145) local playerVehicle = getPedOccupiedVehicle(thePlayer) if(playerVehicle) then for i,v in pairs(getElementsByType("vehicle")) do setElementCollidableWith(playerVehicle, false) end end end end end ) ta dando isso no debug (attempt to call global "setElementCollidableWith"(a nil value) )
-
Tentei isso e nada seat coloquei do jeito que tu mostrou, o getElementData ta vendo se o player ta com o modo passivo ativo e o setElementAlpha tenho que deixar como source certo? pra setar no veiculo, n faço ideia deque esteja errado addEventHandler("onVehicleEnter",root, function(thePlayer, seat) if seat == 0 then if getElementData(thePlayer,"ModoPassivo") then setElementAlpha(source,145) end end end )