iago santana Posted April 14 Share Posted April 14 (edited) Então tenho um script que tem alguns ped, ARENA M4, AK, PISTOLA E CORRIDA, o player chega na frente do PED e aperta no teclado letra E, se possivel alguem me ajudar para ao lado aparecer ' X JOGADORES' para o jogador que acabar de entrar saber onde os outros players estão jogando, no caso ficaria [E] ARENA AK 47(2JOGADORES).IMAGEM DO PED config = { ['m4'] = { ped = { id_skin = 217, pos = {358.091, -2329.963, 20.783, 226, 0, 0}, -- x, y, z, rot, int, dim message = 'Aperte E para acessar arena M4', text_ped = 'ARENA M4', }, weapon = 31, spawns = { {1585.958, -1408.656, 770.083}, {1568.064, -1409.361, 770.083}, {1566.266, -1430.026, 770.083}, {1576.802, -1480.393, 770.083}, --{2337.175, 86.032, 26.336}, }, }, ['ak47'] = { ped = { id_skin = 217, pos = {362.293, -2322.51, 20.783, 226, 0, 0}, -- x, y, z, rot, int, dim message = 'Aperte E para acessar arena AK47', text_ped = 'ARENA AK47', }, weapon = 30, spawns = { {1578.124, -1296.77, 770.13}, {1557.427, -1247.243, 770.13}, {1566.276, -1222.277, 770.13}, {1597.004, -1270.135, 770.13}, --{2337.175, 86.032, 26.336}, }, }, ['pistol'] = { ped = { id_skin = 217, pos = {370.574, -2318.154, 20.783, 226, 0, 0}, -- x, y, z, rot, int, dim message = 'Aperte E para acessar arena Pistol', text_ped = 'ARENA PISTOL', }, weapon = 23, spawns = { {-1003.64801, -670.05334, 32.00781}, {-1092.57129, -622.87628, 32.01260}, }, }, ['corridas'] = { ped = { id_skin = 217, pos = {358.397, -2337.375, 20.783, 273, 0, 0}, -- x, y, z, rot, int, dim message = 'Aperte E para acessar as corrridas', text_ped = 'ARENA CORRIDAS', }, weapon = false, spawns = { {1793.953, -1932.536, 13.386}, {1793.953, -1932.536, 13.386}, }, }, ['lobby'] = { weapon = false, spawns = { {373.256, -2325.826, 20.783}, }, }, } x, y = guiGetScreenSize() function draw_arenas() local alpha = interpolateBetween(0, 0, 0, 255, 0, 0, ((getTickCount() - tick) / 500), 'Linear') dxDrawImage(45, 95, 400, 410, 'assets/base.png', 0, 0, 0, tocolor(255, 255, 255, alpha)) dxDrawImage(205, 95, 180, 101, 'assets/ak47.png', 0, 0, 0, select == 'ak47' and tocolor(6, 115, 13, alpha) or (isMouseInPosition(205, 95, 180, 101) and tocolor(6, 115, 13, alpha) or tocolor(255, 255, 255, alpha)) or tocolor(255, 255, 255, alpha)) dxDrawImage(273, 179, 43, 32, 'assets/pistol.png', 0, 0, 0, select == 'pistol' and tocolor(6, 115, 13, alpha) or (isMouseInPosition(273, 179, 43, 32) and tocolor(6, 115, 13, alpha) or tocolor(255, 255, 255, alpha)) or tocolor(255, 255, 255, alpha)) end bindKey('f1', 'down', function() if not isEventHandlerAdded('onClientRender', root, draw_arenas) then tick = getTickCount() addEventHandler('onClientRender', root, draw_arenas) showCursor(true) showChat(false) else removeEventHandler('onClientRender', root, draw_arenas) showCursor(false) showChat(true) end end ) addEventHandler('onClientClick', root, function(b, s) if ( b == 'left' ) and ( s == 'down' ) then if isEventHandlerAdded('onClientRender', root, draw_arenas) then if isMouseInPosition(273, 179, 43, 32) then select = 'pistol' elseif isMouseInPosition(205, 95, 180, 101) then select = 'ak47' elseif isMouseInPosition(322, 250, 111, 27) then if not select then return end triggerServerEvent('onPlayerSelectArena', localPlayer, localPlayer, select) elseif isMouseInPosition(322, 460, 111, 27) then triggerServerEvent('onPlayerSelectArena', localPlayer, localPlayer, 'corridas') end end end end ) local arenas = { 'm4', 'ak47', 'pistol', 'corridas', } local ped, peds_table, marker = {}, {}, {} setTimer(function() for i, v in ipairs(arenas) do ped[i] = createPed(config[v].ped.id_skin, config[v].ped.pos[1], config[v].ped.pos[2], config[v].ped.pos[3], config[v].ped.pos[4]) table.insert(peds_table, {ped[i], config[v].ped.text_ped}) setElementInterior(ped[i], config[v].ped.pos[5]) setElementDimension(ped[i], config[v].ped.pos[6]) setElementFrozen(ped[i], true) addEventHandler('onClientPedDamage', ped[i], function() cancelEvent() end ) addEventHandler('onClientPlayerStealthKill', root, function(element) if (element == ped[i]) then cancelEvent() end end ) marker[i] = createMarker(config[v].ped.pos[1], config[v].ped.pos[2], config[v].ped.pos[3] - 1, 'cylinder', 4, 0, 0, 0, 0) setElementInterior(marker[i], config[v].ped.pos[5]) setElementDimension(marker[i], config[v].ped.pos[6]) addEventHandler('onClientMarkerHit', marker[i], function(player, dim) if isElement(player) and getElementType(player) == 'player' then if (dim) then if (player == localPlayer) then add_message(config[v].ped.message, v) end end end end ) addEventHandler('onClientMarkerLeave', marker[i], function(player, dim) if isElement(player) and getElementType(player) == 'player' then if (dim) then if (player == localPlayer) then remove_message() end end end end ) end end, 500, 1) local font_msg = dxCreateFont('assets/font_sbold.ttf', 15) function draw_msg() --dxDrawText(message_, (x / 2) - (dxGetTextWidth(message_, 1, font_msg) / 2), y / 2, 0, 0, tocolor(255, 255, 255, 255), 1, font_msg, 'left', 'top', false, false, false, true) end function add_message(msg, arena_) message_ = msg arena_marker = arena_ if not isEventHandlerAdded('onClientRender', root, draw_msg) then addEventHandler('onClientRender', root, draw_msg) end end function remove_message() removeEventHandler('onClientRender', root, draw_msg) end addEventHandler('onClientRender', root, function() for i, v in ipairs(peds_table) do dxDrawTextOnElement(v[1], '[E] '..v[2], 1, 10, 255, 255, 255, 255, 1, font_msg) end end ) bindKey('e', 'down', function() if isEventHandlerAdded('onClientRender', root, draw_msg) then if (arena_marker) then triggerServerEvent('onPlayerSelectArena', localPlayer, localPlayer, arena_marker) end end end ) ------------------------------------------------ function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,...) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getCameraMatrix() local distance = distance or 20 local height = height or 1 if (isLineOfSightClear(x, y, z+2, x2, y2, z2, ...)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawRectangle((sx) - 80, (sy - 12), dxGetTextWidth(text, 1, font_msg, true), 30, tocolor(23, 147, 40, 255)) if text == '[E] ARENA CORRIDAS' then dxDrawText(text, sx+50, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), 0.75, font or "arial", "center", "center", false, false, false, true) else dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), 0.75, font or "arial", "center", "center", false, false, false, true) end end end end end ------------------------------------------------ local arena_selected = {} addEvent('onPlayerSelectArena', true) addEventHandler('onPlayerSelectArena', root, function(player, arena) if not arena_selected[player] then spawn_arena(player, arena) else message(player, 'Caso queira mudar de arena utilize /sair', 'ERRO') end end ) addCommandHandler('sair', function(player) if (arena_selected[player]) then takeAllWeapons(player) arena_selected[player] = false setElementData(player, 'Arena', false) setElementDimension(player, 0) local random = math.random(#config['lobby'].spawns) setElementPosition(player, config['lobby'].spawns[random][1], config['lobby'].spawns[random][2], config['lobby'].spawns[random][3]) end end ) function spawn_arena(player, arena) arena_selected[player] = arena local random = math.random(#config[arena].spawns) setElementPosition(player, config[arena].spawns[random][1], config[arena].spawns[random][2], config[arena].spawns[random][3]) setElementData(player, 'Arena', arena) takeAllWeapons(player) setElementDimension(player, 0) if (config[arena].weapon) then giveWeapon(player, config[arena].weapon, 9999, true) end end addEventHandler('onPlayerWasted', root, function() if (arena_selected[source]) then spawn_arena(source, arena_selected[source]) end end ) function message(player, text, title) exports['volt_notify']:notify(player, title, text) end os 3 scripts que utlizam nos ped Edited April 14 by iago santana Link to comment
Other Languages Moderators Lord Henry Posted April 15 Other Languages Moderators Share Posted April 15 (edited) Crie uma variável com valor 0. Por exemplo playersArena = 0 Sempre que um jogador entrar, aumente em +1 nessa variável: playersArena = playersArena + 1 Sempre que um jogador sair ou desconectar do servidor, diminua em -1 essa variável: playersArena = playersArena - 1 Dai no texto, apenas mostre o valor dessa variável com um tostring(playersArena). Edited April 15 by Lord Henry 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