PashaBiceps Posted April 17, 2019 Share Posted April 17, 2019 Olá gente, estou tendo um problema com vários comandos quero que eles detetem o jogador pelo id. Aqui é um comando deles o que está errado? Obrigado desde já! function getPlayerID( string ) if( string and type( string ) == 'string' ) then local matches = { } for k,v in ipairs( getElementsByType'player' ) do if( string.find( getElementData(v, "ID"), tostring( string ), 0 ) ) then table.insert ( matches, v ); end end if( #matches == 1 ) then return matches[1]; end end return false; end function algemar_jogador ( thePlayer, _, id ) if id then if getPlayerID ( id ) then local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "PM") ) then local player_a_ser_algemado = getPlayerID ( id ) local nick_do_jogador = getPlayerName ( player_a_ser_algemado ) local nick_do_policial = getPlayerName ( thePlayer ) local policiax, policiay, policiaz = getElementPosition ( thePlayer ) local revistadox, revistadoy, revistadoz = getElementPosition ( player_a_ser_algemado ) local dist = getDistanceBetweenPoints3D ( policiax, policiay, policiaz, revistadox, revistadoy, revistadoz ) if ( dist > 5 ) then outputChatBox("#000000[#4286f4PSP#000000]#ffffff Chega #ff0000mais perto#ffffff do jogador para usar o comando!", thePlayer, 255, 255, 255, true) elseif ( dist < 4 )then setElementData(player_a_ser_algemado,"algemado", nick_do_jogador) setPedAnimation( player_a_ser_algemado, "GRAVEYARD", "mrnm_loop", -1, true, false, false, false) setElementFrozen( player_a_ser_algemado, true ) toggleControl(player_a_ser_algemado, "fire", false) outputChatBox("#000000[#4286f4PSP#000000]#ffffff #ff0000"..nick_do_jogador.."#ffffff foi algemado pelo #4286f4Agente "..nick_do_policial.."", root, 255, 255, 255, true) outputChatBox("#000000[#4286f4PSP#000000]#ffffff Tu foste #ff0000algemado#ffffff! ", player_a_ser_algemado, 255, 255, 255, true) end end else outputChatBox("#000000[#4286f4PSP#000000]#ffffff Tu #ff0000não tens permissão#ffffff para usar este comando!", thePlayer, 255, 255, 255, true) end end end addCommandHandler("algemar", algemar_jogador) Link to comment
Nice_x #Scripting; Posted April 17, 2019 Share Posted April 17, 2019 Teste desse jeito, substitua o seu por esse, ainda não testado, mas me fala ai se deu certo function getPlayerID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end function algemar_jogador ( thePlayer, _, id ) if(id) then local playerID = tonumber(id) if(playerID) then local Player2 = getPlayerID(playerID) local cx,cy,cz = getElementPosition(Player2) local x,y,z = getElementPosition(thePlayer) local dist = getDistanceBetweenPoints3D(x,y,z,cx,cy,cz) if(Player2) then if dist <= 5 then local accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user."..accountname, aclGetGroup("PM")) and dist <= 5 then setElementData(Player2,"algemado", Player2) setPedAnimation( Player2, "GRAVEYARD", "mrnM_loop", -1, true, false, false, false) setElementFrozen( Player2, true ) toggleControl(Player2, "fire", false) outputChatBox("#000000[#4286f4PSP#000000]#ffffff #ff0000"..getPlayerName(Player2).."#ffffff foi algemado pelo #4286f4Agente "..getPlayerName(thePlayer).."", root, 255, 255, 255, true) outputChatBox("#000000[#4286f4PSP#000000]#ffffff Tu foste #ff0000algemado#ffffff! ", Player2, 255, 255, 255, true) else outputChatBox("#000000[#4286f4PSP#000000]#ffffff Tu #ff0000não tens permissão#ffffff para usar este comando!", thePlayer, 255, 255, 255, true) end else outputChatBox("#000000[#4286f4PSP#000000]#ffffff Chega #ff0000mais perto#ffffff do jogador para usar o comando!", thePlayer, 255, 255, 255, true) end end end end end addCommandHandler("algemar", algemar_jogador) 1 Link to comment
PashaBiceps Posted April 17, 2019 Author Share Posted April 17, 2019 2 hours ago, nicifer said: Teste desse jeito, substitua o seu por esse, ainda não testado, mas me fala ai se deu certo function getPlayerID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end function algemar_jogador ( thePlayer, _, id ) if(id) then local playerID = tonumber(id) if(playerID) then local Player2 = getPlayerID(playerID) local cx,cy,cz = getElementPosition(Player2) local x,y,z = getElementPosition(thePlayer) local dist = getDistanceBetweenPoints3D(x,y,z,cx,cy,cz) if(Player2) then if dist <= 5 then local accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user."..accountname, aclGetGroup("PM")) and dist <= 5 then setElementData(Player2,"algemado", Player2) setPedAnimation( Player2, "GRAVEYARD", "mrnM_loop", -1, true, false, false, false) setElementFrozen( Player2, true ) toggleControl(Player2, "fire", false) outputChatBox("#000000[#4286f4PSP#000000]#ffffff #ff0000"..getPlayerName(Player2).."#ffffff foi algemado pelo #4286f4Agente "..getPlayerName(thePlayer).."", root, 255, 255, 255, true) outputChatBox("#000000[#4286f4PSP#000000]#ffffff Tu foste #ff0000algemado#ffffff! ", Player2, 255, 255, 255, true) else outputChatBox("#000000[#4286f4PSP#000000]#ffffff Tu #ff0000não tens permissão#ffffff para usar este comando!", thePlayer, 255, 255, 255, true) end else outputChatBox("#000000[#4286f4PSP#000000]#ffffff Chega #ff0000mais perto#ffffff do jogador para usar o comando!", thePlayer, 255, 255, 255, true) end end end end end addCommandHandler("algemar", algemar_jogador) Perfeito, obrigado. Fiz o mesmo procedimento em vários 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