Jump to content

FECHADO | Session ID


Recommended Posts

Galera Gostaria de Criar Comandos Baseados na Session ID do Jogador

1° Gostaria de Criar um Sistema de Gang que possa Convidar Jogadores para Gang Através da Session ID.

2° Gostaria que Apareçe-se a Session ID do jogador encima da cabeça dele Ex : NickX(ID : X).

3° Sistema de Procurado Baseado no SAMP , Este sistema funciona da seguinte forma o Policial Digita "/procurado" irá apareçer um tabela em Gui informando O nivel de Procurado e a Session ID do jogador,

o Policial se quiser procurar um jogador vai digitar "/procurar (ID JOGADOR)" ai apareçerá um blip no jogador que está sendo procurado.

Estes são os mods que quero fazer mais não sei que Comandos Utilizar (Como sempre) procurei na Wiki sobre Session ID mais não achei :(

Edited by Guest
Link to comment

Como não existe nada na wiki sobre isso você tem que pensar como fazer esse sistema 'manualmente'...

Devemos, primeiro, gerar um id único para cada jogador, para isso precisamos armazenar o id de todos os jogadores (afinal não queremos que existam dois jogadores com o mesmo id), Você pode fazer isso usando element datas + um loop ou uma simples tabela;

ID_Dos_Jogadores    =   {}      -- Criamos a tabela 'ID_Dos_Jogadores', que ira armazenar os ids que ja foram usados 
  
function onJoin () -- Função que irá dar um id ao jogador logo quando ele entrar. 
    for i = 0, getMaxPlayers() do -- fazemos um loop numerico do numero 0 ao slot maximo de jogadores 
        --  aqui a variavel "i" correspondera a um numero (o atual do loop, que aumenta a cada execução dele) 
        if not ID_Dos_Jogadores[ i ] then -- checamos se o id já não está sendo usado 
            ID_Dos_Jogadores [ i ] = source -- definimos, na tabela, o id como o jogador que acabou de entrar 
            break -- paramos o loop, afinal o jogador já tem um id 
        end 
    end 
end 
addEventHandler ( "onPlayerJoin", root, onJoin ); -- adicionamos o evento onPlayerJoin a função onJoin 

Com o codigo acima você pode criar uma função que 'pegue' um jogador pelo seu id e usar ela em um export

function getPlayerFromID ( id ) -- função que ira obter um jogador pelo seu id 
    if ID_Dos_Jogadores[id] then -- checamos se o id está sendo usado 
        return ID_Dos_Jogadores[id] -- retornamos o jogador 
    else 
        return false -- retornamos falso pois não existe ninguem com este id 
    end 
end 

↑ isso já responde sua primeira 'duvida' :P, Para a segunda você vai precisar provavelmente de element datas para conseguir o id do jogador no lado do cliente e assim usar dxDrawText.

Para a terceira você só precisa fazer um loop com todos os jogadores, e inserir cada um deles em uma tabela (juntamente com seu id e nível de procurado) e depois passar essa tabela para o cliente usando triggerClientEvent.

Espero que tenhas entendido, Se não conseguir algo ou ficar com alguma duvida tente fazer o código e poste ele aqui.

Link to comment
  • 2 months later...

Eu conseguir criar o sistema de ids , baixei um sistema de gangs e quero configurar ele para poder recrutar e da quit em um jogador pela id. Só diz o que tenho que modificar no sistema de gang .

Sistema de Ids

--[[  
################################ID System############################### 
--]] 
  
addCommandHandler("ids", 
function(player, command) 
    players = getElementsByType("player") 
    for id,p in ipairs(players) do 
        outputChatBox(getPlayerName(p) .. ": " .. tostring(id), player) 
    end 
end) 
  
function getIDFromPlayer(player) 
    if player then 
        local theid 
        players = getElementsByType("player") 
        for id,p in ipairs(players) do 
            if player == p then 
                theid = i 
            end 
        end 
        return theid 
    else return false end 
end 
  
function getPlayerFromID(theID) 
    if theID then 
        theID = tonumber(theID) 
        local theplayer 
        players = getElementsByType("player") 
        for id,p in ipairs(players) do 
            if theID == id then 
                theplayer = p 
            end 
        end 
        return theplayer 
    else return false end 
end 
  
--[[Just an example of an command with this ID system.]]-- 
addCommandHandler("heal", 
function (player, command, id) 
    if id then 
        target = getPlayerFromID(id) 
        if target == false or target == nil then 
            outputChatBox("That ID isn't connected.", player) 
            return 
        end 
        setElementHealth(target, 100) 
        outputChatBox("Player is healed") 
    else 
        outputChatBox("Syntax: /heal id", player) 
    end 
end) 
  
--[[This is an example on how to use this resource in another resource. 
  
function callTest(player, command, id) 
    player = call(getResourceFromName("idsystem"), "getPlayerFromID", tonumber(id)) 
    if player then 
        outputChatBox(getPlayerName(player) .. " is online!", player) 
    else 
        outputChatBox("Player is not online, or call function failed.", player) 
    end 
end 
  
addCommandHandler("calltest", callTest) 
  
--]] 

Sistema de Gangs

function criarGang ( source, commandName, teamName ) 
local getaMoney =  getPlayerMoney (source) 
if teamName then 
if getaMoney <400000 then 
outputChatBox("#F4A460[Gang]#F08080 Você não tem dinheiro suficiente para criar uma gang Valor 4.000$",source,255,255,255,true) 
else 
if ( getPlayerTeam(source) ~= false ) and ( countPlayersInTeam(getPlayerTeam(source)) == 1 ) then 
                                destroyElement(getPlayerTeam(source)) 
outputChatBox("#F4A460[Gang]#F08080 Sua gang antiga foi deletada e foi criada uma nova!",source,255,255,255,true) 
end 
  local newTeam = createTeam ( teamName) 
  if newTeam then 
  takePlayerMoney (source,400000 ) 
local getGang = getTeamName ( newTeam ) 
setTeamColor (newTeam,math.random(0,255), math.random(0,255), math.random(0,255)) 
    setPlayerTeam ( source, newTeam ) 
local playerTeam = getPlayerTeam( source ) 
 outputChatBox("#F4A460[Gang]#F08080 Gang criada com sucesso!! Valor 4.000$",source, 255, 255, 255, true) 
end 
end 
else 
outputChatBox("#F4A460[Gang]#F08080 Uso correto: /fundargang [nome]",source,255,255,255,true) 
end 
end 
addCommandHandler("fundargang",criarGang) 
  
addEventHandler("onPlayerLogin",root,function() 
local team = getAccountData (getPlayerAccount(source), "team") 
if (team==getTeamName(getTeamFromName(team))) then 
setPlayerTeam(source, getTeamFromName(team)) 
end 
end) 
  
function save() 
local team = getPlayerTeam(source) 
local account = getPlayerAccount(source) 
if not isGuestAccount(account) then 
if(team)then 
setAccountData(account, "team", getTeamName(team)) 
end 
end 
end 
addEventHandler("onPlayerLogout", root, save) 
addEventHandler("onPlayerQuit", root, save) 
  
function sairDaGang(source) 
local playerTeam = getPlayerTeam (source) 
if (playerTeam) then 
setPlayerTeam (source, nil) 
outputChatBox("#F4A460[Gang]#F08080 Você saiu da gang",source,255,255,255,true) 
else 
outputChatBox("#F4A460[Gang]#F08080 Você não tem gang",source,255,255,255,true) 
end 
end 
addCommandHandler("abandonargang", sairDaGang) 
  
function desfazerGang (source) 
local playerVeri = getPlayerTeam (source) 
  
if (playerVeri) then 
  
destroyElement (playerVeri) 
outputChatBox("#F4A460[Gang]#F08080 Você deletou sua gang",source,255,255,255,true) 
else 
outputChatBox("#F4A460[Gang]#F08080 Você não tem gang",source,255,255,255,true) 
end 
end 
addCommandHandler("deletargang", desfazerGang) 
  
function enviarGang(source,cmd,targetPlayer) 
local target = getPlayerFromName (targetPlayer) 
local geta = getPlayerName (target) 
gang = getPlayerTeam (source) 
local getName = getTeamFromName(source) 
lala = getTeamName(source) 
local convidado = true 
setElementData(target, "gangConvite", gang, false) 
if gang == getName then 
 outputChatBox("#F4A460[Gang]#F08080 Você não pertence a nenhuma gang",source, 255, 255, 255, true) 
else 
 outputChatBox("#F4A460[Gang]#F08080 Convite de recrutamento enviado para "..targetPlayer,source, 255, 255, 255, true) 
 outputChatBox("#F4A460[Gang]#F08080 Você foi convidado para o recrutamento digite /aceitargang Gang: "..getTeamName(gang),target, 255, 255, 255, true) 
 end 
end 
addCommandHandler("recrutargang", enviarGang) 
  
function Recrutamento(source) 
 local gangConvite = getElementData(source, "gangConvite") 
 if isElement(gangConvite) then 
  outputChatBox("#F4A460[Gang]#F08080 Você entrou na gang "..getTeamName(gang),source, 255, 255, 255, true) 
  setPlayerTeam (source, gangConvite) 
 else 
  outputChatBox("#F4A460[Gang]#F08080 Você não foi convidado para nenhuma gang",source, 255, 255, 255, true) 
 end 
end 
addCommandHandler("aceitargang",Recrutamento) 
  
function Infor(source) 
outputChatBox("#F4A460[COMANDOS]#F08080 - Comandos de gang -",source, 255, 255, 255, true) 
outputChatBox("#F4A460[Gang]#F08080 /fundargang [nome]",source, 255, 255, 255, true) 
outputChatBox("#F4A460[Gang]#F08080 /abandonargang",source, 255, 255, 255, true) 
outputChatBox("#F4A460[Gang]#F08080 /deletargang",source, 255, 255, 255, true) 
outputChatBox("#F4A460[Gang]#F08080 /recrutargang [nick]",source, 255, 255, 255, true) 
outputChatBox("#F4A460[Gang]#F08080 /aceitargang [entra em uma gang]",source, 255, 255, 255, true) 
end 
addCommandHandler ("gang",Infor) 
  
function Infor2() 
outputChatBox("",source, 255, 255, 255, true) 
end 
addEventHandler ( "onPlayerJoin", root, Infor2 ) 

Link to comment

Esse sistema de IDs que você fez não vai funcionar muito bem, Toda vez que alguém sair do servidor o ID das pessoas que entraram depois dessa que saiu vai mudar, acho que você não quer isso...

Usa o sistema que te mandei, com algumas adaptações dá pra deixar ele completamente funcional.

Já pra usar um sistema de IDs na parte de gang basta trocar a linha 71 para achar o jogador pelo seu ID (se você quiser mesmo usar esse seu sistema de IDS basta ver da linha 56 em diante, Lá mostra como usar a função getPlayerFromID).

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...