-------------------------------------
---
--- Por '~FN|DaLesTe^'
---
-------------------------------------
function getPlayerFromID(id)
return call(getResourceFromName("game_id2"), "getPlayerFromID", tonumber(id))
end
function getPlayerID(player)
return getElementData(player,"id")
end
function criarGang ( source, commandName, ... )
local getaMoney = getPlayerMoney (source)
local teamName = table.concat({...}, " ")
if teamName then
if getaMoney <300000 then
outputChatBox("#7d26cd[SERVER] #FF0000Você não tem dinheiro suficiente para criar uma gang valor 5000$",source,255,255,255,true)
else
if ( getPlayerTeam(source) ~= false ) and ( countPlayersInTeam(getPlayerTeam(source)) == 1 ) then
destroyElement(getPlayerTeam(source))
outputChatBox("#F4A460[SERVER]#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,300 )
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("#43CD80[GANG] #FFFFFFGang criada com sucesso!",source, 255, 255, 255, true)
end
end
else
outputChatBox("#43CD80[GANG] #FFFFFFUso correto: /gangcriar [nome]",source,255,255,255,true)
end
end
addCommandHandler("gangcriar",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("#43CD80[GANG] #FFFFFFVocê saiu da gang",source,255,255,255,true)
else
outputChatBox("#43CD80[GANG] #ffffffVocê não tem gang",source,255,255,255,true)
end
end
addCommandHandler("gangsair", sairDaGang)
function desfazerGang (source)
local playerVeri = getPlayerTeam (source)
if (playerVeri) then
destroyElement (playerVeri)
outputChatBox("#43CD80[GANG] #FFFFFFVocê deletou sua gang",source,255,255,255,true)
else
outputChatBox("#43CD80[GANG] #FFFFFFVocê não tem gang",source,255,255,255,true)
end
end
addCommandHandler("gangdeletar", desfazerGang)
function enviarGang(source,cmd,targetPlayer)
local target = getPlayerFromID (targetPlayer)
local geta = getPlayerFromID (target)
gang = getPlayerTeam (source)
local getName = getTeamFromName(source)
lala = getTeamName(source)
local convidado = true
setElementData(target, "gangConvite", gang, false)
if gang == getName then
outputChatBox("#43CD80[GANG] #FFFFFFVocê não pertence a nenhuma gang",source, 255, 255, 255, true)
else
outputChatBox("#43CD80[GANG] #FFFFFFConvite de recrutamento enviado para o Jogador " ..getPlayerName(target).. " ID: "..targetPlayer,source, 255, 255, 255, true)
outputChatBox("#43CD80[GANG] #FFFFFFVocê foi convidado para a gang #43CD80" ..getTeamName(gang).. " #FFFFFFuse #43CD80/gangaceitar #FFFFFFpara entrar na Gang: #ffffff "..getTeamName(gang),target, 255, 255, 255, true)
end
end
addCommandHandler("gangconvidar", enviarGang)
function Recrutamento(source)
local gangConvite = getElementData(source, "gangConvite")
if isElement(gangConvite) then
outputChatBox("#43CD80[GANG] #FFFFFFVocê entrou na gang "..getTeamName(gang),source, 255, 255, 255, true)
setPlayerTeam (source, gangConvite)
else
outputChatBox("#43CD80[GANG] #FFFFFFVocê não foi convidado para nenhuma gang",source, 255, 255, 255, true)
end
end
addCommandHandler("gangaceitar",Recrutamento)
function gangCommands(thePlayer)
outputChatBox ( "#7d26cd[GANG] #ffffffUse /gangcriar | /gangcor CODE RGB | /gangtag | /gangconvidar ID/Nome | /gangabandonar | /gangsair | /gangdeletar", thePlayer, 255, 255, 255, true )
end
addCommandHandler ( "gang", gangCommands )
function gangName ( player, commandName, newName )
local theTeam = getPlayerTeam ( player )
setTeamName ( theTeam, newName )
outputChatBox("A Gangue "..getTeamName(theTeam).." alterou o nome ["..newName.."]", root, 255, 0, 0)
end
addCommandHandler("gangnome", gangName )
function gangFarbe ( player, commandName, r, g, b )
local team = getPlayerTeam ( player )
setTeamColor ( team, r, g, b )
outputChatBox("[INFO] A gangue "..getTeamName(team).." alterou a cor da Gangue", source, 255, 255, 255, tonumber(r), tonumber(g), tonumber(b))
end
addCommandHandler("gangcor", gangFarbe )
addCommandHandler( "gangtag",
function ( source, cmdname, tag )
if tag and ( tag:len() > 3 or tag:len() == 0 ) then
return outputChatBox("A tag deve ter no máximo 3 caracteres.", source, 230, 0, 0)
end
if getPlayerTeam(source) and tag then
setPlayerName(source, "["..tag.."]"..getPlayerName(source))
elseif not tag then
outputChatBox("Sintaxe: /gangtag <tag da gangue>", source, 230, 0, 0)
end
end
)
function getPlayerFromParticalName(thePlayerName)
local thePlayer = getPlayerFromName(thePlayerName)
if thePlayer then
return thePlayer
end
for _,thePlayer in ipairs(getElementsByType("player")) do
if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then
return thePlayer
end
end
return false
end