Jump to content

zFelpszada

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by zFelpszada

  1. You're welcome! If you could leave a review and close the thread, I'd appreciate it. Good luck with everything!
  2. --// Setting ACL group. local ACL = "Mafia" --// Setting delay value. local DELAY = 1000 --// Store players delay in memory server. local cooldown = {} --// Get player account name. local function getPlayerAccountName(player) local account = getPlayerAccount(player) return getAccountName(account) end --// Verify if player is in ACL group. local function isPlayerHasAcl(player, acl) local group = aclGetGroup(acl) local accountName = getPlayerAccountName(player) return isObjectInACLGroup("user."..accountName, group) end --// Clan chat. local function clan(player, _, ...) --// Protect player from spamming. local now = getTickCount() if cooldown[player] and now - cooldown[player] < DELAY then cancelEvent() return outputChatBox("Please wait a moment before sending another message.", player, 255, 0, 0) end --// Set player delay. cooldown[player] = now --// Verify if player is in ACL group. if not isPlayerHasAcl(player, ACL) then return false end --// Concatenate message. local message = table.concat({...}, " ") if not message or message == "" then return false end --// Show message to all players in the same ACL group. local name = getPlayerName(player) local players = getElementsByType("player") local r, g, b = getPlayerNametagColor(player) for i = 1, #players do local target = players[i] if isPlayerHasAcl(target, ACL) then outputChatBox("[Clan]: "..name..": "..message, target, r, g, b) end end return true end addCommandHandler("clan", clan) --// Bind key to player on resource start. addEventHandler("onResourceStart", resourceRoot, function() local players = getElementsByType("player") for i = 1, #players do local player = players[i] bindKey(player, "u", "down", "chatbox", "clan") end end) --// Bind key to player on player login. addEventHandler("onPlayerLogin", root, function() bindKey(source, "u", "down", "chatbox", "clan") end) Hey, what's up? Honestly, I don't see any reason to implement this on the client-side. The best option is to do it on the server-side, ensuring server security against cheaters, better synchronization for all players, and other benefits. I made some improvements to your initial code.
  3. --// Setting delay value. local DELAY = 1000 --// Store players delay in memory server. local cooldown = {} --// Get player account name. local function getPlayerAccountName(player) local account = getPlayerAccount(player) return getAccountName(account) end --// Verify if player is in ACL group. local function isPlayerHasAcl(player, acl) local group = aclGetGroup(acl) local accountName = getPlayerAccountName(player) return isObjectInACLGroup("user."..accountName, group) end --// Add event handler for player chat clan. addEventHandler("onPlayerChat", root, function(message, type) --// Check if it's a normal message. if type ~= 0 then return false end --// Check if the message is empty. if message == "" or message == " " then return false end --// Protect player from spamming. local now = getTickCount() if cooldown[source] and now - cooldown[source] < DELAY then cancelEvent() return outputChatBox("Please wait a moment before sending another message.", source, 255, 0, 0) end --// Check if the player is in ACL group. local playerName = getPlayerName(source) if not isPlayerHasAcl(source, "Console") then return false end --// Added player to cooldown. cooldown[source] = now --// Send message to all players in ACL group. local players = getElementsByType("player") local r, g, b = getPlayerNametagColor(source) for i = 1, #players do local player = players[i] if isPlayerHasAcl(player, "Console") then outputChatBox("[Clan]: "..playerName..": "..message, player, r, g, b) end end --// Cancel MTA default message. cancelEvent() end) --// Add event handler for player quit and delete memory value. addEventHandler("onPlayerQuit", root, function() if cooldown[source] then cooldown[source] = nil end end) Hey, what's up? I made a simple example of a chat, showing how you can create a clan-specific chat using the 't' key (the default chat key in MTA).
  4. --// Armazena as armas dos jogadores na memória do servidor. local weapons = {} --// Função para obter todas as armas do player. local function getPlayerWeapons(player) local weapons = {} for i = 0, 12 do local weapon = getPedWeapon(player, i) local ammo = getPedTotalAmmo(player, i) if weapon > 0 and ammo > 0 then weapons[weapon] = ammo end end return weapons end --// Função para setar o timer de respawn do player. local function setPlayerSpawnTimer(player) setTimer(function(player) if isTimer(sourceTimer) then killTimer(sourceTimer) end if not isElement(player) then return false end --// Recupera o skin do player para setar no spawn. local playerSkin = getElementModel(player) spawnPlayer(player, spawnX, spawnY, spawnZ, 0, playerSkin) end, 3000, 1, player) end --// Evento para quando o player morrer, setar o timer de respawn, dar o dinheiro para que matou, tirar o dinheiro de quem morreu e salvar as armas. addEventHandler("onPlayerWasted", root, function(_, killer) if (killer) and (killer ~= source) then givePlayerMoney(killer, killerMoney) end --// Armazena as armas do player que morreu. weapons[source] = getPlayerWeapons(source) setPlayerSpawnTimer(source) setCameraTarget(source, source) takePlayerMoney(source, deadPlayerMoney) end) --// Evento para quando o player spawnar, setar as armas dele. addEventHandler("onPlayerSpawn", root, function() local playerWeapons = weapons[source] if not playerWeapons then return false end for weapon, ammo in pairs(playerWeapons) do giveWeapon(source, weapon, ammo) end weapons[source] = nil return true end) --// Evento para quando o player sair, remover as armas dele da memória e evitar vazamento de memória. addEventHandler("onPlayerQuit", root, function() if weapons[source] then weapons[source] = nil end end)
  5. @Wendell_D3v, suave? Provavelmente seu server/mta está desatualizado, tente reinstalar para ultima versão. download oficial.
  6. Você pode remover essa linha do seu código: addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), setHud) No arquivo meta.xml do script hud adiciona essa linha: <export function="setHud" type="client"/> E no seu script de login na função que fecha o painel, você pode adicionar essa linha de código para aparecer a hud depois que fechar a tela de login. export["nome"]:setHud() Lembre-se de alterar o argumento nome para o nome do resource da sua hud. Explicando sobre alteração, nós removemos o evento de inicialização do resource, adicionamos uma função exportável no meta e chamamos a função para aparecer hud.
×
×
  • Create New...