TorNix~|nR Posted July 15, 2016 Share Posted July 15, 2016 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
N3xT Posted July 15, 2016 Share Posted July 15, 2016 replace setPlayerTeam to setElementData , with team name then addCommandHandler / accept or declined Link to comment
TorNix~|nR Posted July 15, 2016 Author Share Posted July 15, 2016 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
Submitter Posted July 15, 2016 Share Posted July 15, 2016 'r, g, b' from where they came? Use something like 0, 255, 0 Link to comment
TorNix~|nR Posted July 15, 2016 Author Share Posted July 15, 2016 the problem is not in r,g,b :3 Link to comment
Et-win Posted July 15, 2016 Share Posted July 15, 2016 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? 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
TorNix~|nR Posted July 19, 2016 Author Share Posted July 19, 2016 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
Captain Cody Posted July 21, 2016 Share Posted July 21, 2016 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
Captain Cody Posted July 21, 2016 Share Posted July 21, 2016 /accept to accept, the other one you said you were triggering from a panel correct? Link to comment
Captain Cody Posted July 21, 2016 Share Posted July 21, 2016 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
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