Jump to content

Send Invite


Recommended Posts

Hello everyone, I have my panel of make a player in team

when I invite a player in team, he automaticlly join to the team, I need to make a anti spam like this:

I need when I invite him, he needs to say /acceptclan for join the team, anyone help me?

function Invitar (source) 
    local favteam = getTeamFromName("Police") 
        local player = getPlayerFromName(source) 
    if (favteam) then  
        setPlayerTeam(player, favteam) 
    outputChatBox (getPlayerName(player) .. ' #00FF00has been invited to Police', source, r, g, b, true ) 
    outputChatBox (getPlayerName(source) .. ' #00FF00has changed to Police', player, r, g, b, true ) 
    else 
    cancelEvent() 
    outputChatBox ( "", thePlayer, 0, 245, 82, true ) 
   end 
end 
addEvent( "Invitar", true) 
addEventHandler( "Invitar", getRootElement(), Invitar )  

Link to comment
function Invitar (source) 
    local favteam = getTeamFromName("D.S.K") 
        local player = getPlayerFromName(source) 
    if (favteam) then  
        setElementData(player, favteam) 
    outputChatBox (getPlayerName(player) .. ' #00FF00Ha sido invitado a DSK', source, r, g, b, true ) 
    outputChatBox (getPlayerName(source) .. ' #00FF00Se ha cambiado a DSK', player, r, g, b, true ) 
    else 
    cancelEvent() 
    outputChatBox ( "", thePlayer, 0, 245, 82, true ) 
   end 
end 
addEvent( "Invitar", true) 
addCommandHandler ( "accept", Invitar )  

help !!

Link to comment
function Invitar (source) 
    local favteam = getTeamFromName("Police") 
        local player = getPlayerFromName(source) 
    if (favteam) then  
        setPlayerTeam(player, favteam) 
    outputChatBox (getPlayerName(player) .. ' #00FF00has been invited to Police', source, r, g, b, true ) 
    outputChatBox (getPlayerName(source) .. ' #00FF00has changed to Police', player, r, g, b, true ) 
    else 
    cancelEvent() 
    outputChatBox ( "", thePlayer, 0, 245, 82, true ) 
   end 
end 
addEvent( "Invitar", true) 
addEventHandler( "Invitar", getRootElement(), Invitar )  

1: r, g and b are not defined (In this function, maybe outside the function?)

2: Why would you use 'cancelEvent()' as it doesn't stop anything?

3: Sorry that I say it, but you have no idea what you are doing since this is just copied? :roll:

Anyway, like N3xT said. Instead of putting the player into the team, you can use 'setElementData' and set the team-name or team-element on the player. Then with another function (addCommandHandler) check if there is element data with 'getElementData'. If there is, check if the team still exists and if so, place the player into the team.

Link to comment

help please

function Invitar (source) 
    local favteam = getTeamFromName("D.S.K") 
        local player = getPlayerFromName(source) 
    if (favteam) then 
        setElementData(player, favteam) 
    outputChatBox (getPlayerName(player) .. ' #00FF00Ha sido invitado a DSK', source, 255, 0, 0, true ) 
    outputChatBox (getPlayerName(source) .. ' #00FF00Se ha cambiado a DSK', player, 255, 0, 0, true ) 
    else 
    cancelEvent() 
    outputChatBox ( "", thePlayer, 0, 245, 82, true ) 
   end 
end 
addEvent( "Invitar", true) 
addCommandHandler ( "accept", Invitar )  

Link to comment

Not tested -

   invited = {} 
  
   function Invitar (otherPlayer) 
        local other = getPlayerFromPartialName(otherPlayer) 
            if other then 
        local favteam = getTeamFromName("D.S.K") 
            if (favteam) then 
        outputChatBox (getPlayerName(other) .. ' #00FF00Ha sido invitado a DSK', client, 255, 0, 0, true ) 
        invited[other] = client 
       end 
    end 
end 
  
addEvent( "Invitar", true) 
addEventHandler( "Invitar", root, Invitar )  
     
     
function Accept (player) 
    if invited[player] then 
        setPlayerTeam(player,getTeamFromName("D.S.K")) 
        outputChatBox (otherPlayer.. ' #00FF00Se ha cambiado a DSK', invited[player], 255, 0, 0, true ) 
        invited[player] = nil 
    end 
end 
     
addCommandHandler ( "accept", Accept )  
     
     
     
function getPlayerFromPartialName(name) 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(name, 1, true) then 
                return player 
            end 
        end 
    end 
end 

Link to comment

Sorry noticed something I messed up on, here.

           invited = {} 
          
           function Invitar (otherPlayer) 
                local other = getPlayerFromPartialName(otherPlayer) 
                    if other then 
                local favteam = getTeamFromName("D.S.K") 
                    if (favteam) then 
                outputChatBox (getPlayerName(other) .. ' #00FF00Ha sido invitado a DSK', client, 255, 0, 0, true ) 
                invited[other] = client 
               end 
            end 
        end 
          
        addEvent( "Invitar", true) 
        addEventHandler( "Invitar", root, Invitar ) 
            
            
        function Accept (player) 
            if invited[player] then 
                setPlayerTeam(player,getTeamFromName("D.S.K")) 
                outputChatBox (getPlayerName(player).. ' #00FF00Se ha cambiado a DSK', invited[player], 255, 0, 0, true ) 
                invited[player] = nil 
            end 
        end 
            
        addCommandHandler ( "accept", Accept ) 
            
            
            
        function getPlayerFromPartialName(name) 
            local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
            if name then 
                for _, player in ipairs(getElementsByType("player")) do 
                    local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
                    if name_:find(name, 1, true) then 
                        return player 
                    end 
                end 
            end 
        end 

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...