Jump to content

Autoteams


Sex*

Recommended Posts

So i want to put two autoteams together to make the ultimate autoteams script :twisted:

But it doesnt work, like at all, doesnt save, doesnt create teams.

Error:

Bad argument at addEventHandler line 39 

Heres my script:

---------------do not change or touch this---------- 
Names={} 
Colors={} 
-------------------------------------------------------------- 
  
---------------------------here put your clans read readme for instructions--------------------------------------- 
  
local names ={"The Professionals"} 
local colors ={"#ff4000"} 
-------- load------------ 
  
function loadTeams() 
 for i,name in pairs(names) do 
Names[i]=name 
end 
  
for i,color in pairs(colors) do 
Colors[i] = color 
end 
  
  
addEventHandler("onResourceStart",getRootElement(),loadTeams) 
  
  
-----------check---------------------------- 
  
function check (player) 
local account = getPlayerAccount(source) 
local team = getAccountData (account, "team") 
return end 
local name = Names[i] 
local color = Colors[i] 
  if  not getTeamFromName(name) then 
createTeam(name,getColorFromString(color)) 
end 
local team = getTeamFromName(name) 
setPlayerTeam(player,team) 
end 
addEventHandler("onPlayerLogin",root,check) 
  
  
  
-------------------------------- 
  
  
----------remove Empty Team ---------- 
  
function remove() 
 for t,teams in pairs(names) do 
 local team = getTeamFromName(teams) 
  if team then 
     if  countPlayersInTeam ( team )==0 then 
         destroyElement(team) 
end 
   end 
       end 
          end 
  
--------------------------LOL--------------------------- 
  
  

These two old ones that work:

function setTeam() 
local account = getPlayerAccount(source) -- gets players account 
local team = getAccountData (account, "team") -- gets players team 
if (team) and getTeamFromName(team) then 
      setPlayerTeam(source, getTeamFromName(team)) -- sets players team 
     end 
end 
addEventHandler("onPlayerLogin",root,setTeam) -- sets players team on login 
  
function save() 
 local team = getPlayerTeam(source) -- Gets the players team 
local account = getPlayerAccount(source) 
if (team) and not isGuestAccount(account) then -- Checks to see if the player is a guest or not 
setAccountData(account, "team", getTeamName(team)) --saves team 
 end 
    end 
addEventHandler("onPlayerQuit", getRootElement(), save) -- saves team on quit 

---------------do not change or touch this---------- 
Names={} 
Tags={} 
Colors={} 
ACL={} 
-------------------------------------------------------------- 
  
---------------------------here put your clans read readme for instructions--------------------------------------- 
  
local names ={"Guest Team","xR Team"} 
local tags  ={"","%-xR%|"} 
local colors ={"#e6e6e6","#ff4500"} 
local acls ={"none","none"} 
-------- load------------ 
  
function loadTeams() 
 for i,name in pairs(names) do 
Names[i]=name 
end 
  
for i,tag in pairs(tags) do 
Tags[i]=tag 
end 
  
for i,color in pairs(colors) do 
Colors[i] = color 
end 
  
  
for i,acl in pairs(acls) do 
ACL[i] = acl 
end 
 end 
  
  
addEventHandler("onResourceStart",getRootElement(),loadTeams) 
  
--------------------------------------------------- 
  
----- move on start------------------ 
  
function moveOnStart() 
for i,player in pairs(getElementsByType("player")) do 
check(player) 
end 
end 
  
addEventHandler("onResourceStart",getRootElement(),moveOnStart) 
------------------------------------------------------------------------- 
  
-----------check---------------------------- 
  
function check (player) 
setPlayerTeam(player,nil) 
 for i,tag in pairs(tags) do 
    if string.find(getPlayerName(player),tag) then 
local account=getPlayerAccount(player) 
   if ACL[i]~="none" and not  isObjectInACLGroup ( "user." ..getAccountName(account) , aclGetGroup ( ACL[i] ) ) then 
return end 
local name = Names[i] 
local color = Colors[i] 
  if  not getTeamFromName(name) then 
createTeam(name,getColorFromString(color)) 
end 
local team = getTeamFromName(name) 
setPlayerTeam(player,team) 
  
end 
   end 
      end 
  
  
-------------------------------- 
  
  
----------remove Empty Team ---------- 
  
function remove() 
 for t,teams in pairs(names) do 
 local team = getTeamFromName(teams) 
  if team then 
     if  countPlayersInTeam ( team )==0 then 
         destroyElement(team) 
end 
   end 
       end 
          end 
  
----------------------------------------------------- 
  
-------NickChange------------- 
  
function nick(old,new) 
setTimer(check,1000,1,source) 
setTimer(remove,1500,1) 
end 
  
addEventHandler("onPlayerChangeNick",getRootElement(),nick) 
--------------------------------------------- 
  
-------Join-------------------------------- 
  
function join() 
setTimer(check,4000,1,source) 
end 
  
addEventHandler("onPlayerJoin",getRootElement(),join) 
------------------------------- 
  
---------Quit--------------------- 
  
function quit(player) 
setTimer(remove,1000,1) 
end 
  
addEventHandler("onPlayerQuit",getRootElement(),quit) 
------------------------------------ 
  
---------Login--------------------- 
  
function login() 
setTimer(check,1000,1,source) 
setTimer(remove,1500,1) 
end 
  
addEventHandler("onPlayerLogin",getRootElement(),login) 
------------------------------------ 
  
---------Logout--------------------- 
  
function logout() 
setTimer(check,1000,1,source) 
setTimer(remove,1500,1) 
end 
  
addEventHandler("onPlayerLogout",getRootElement(),logout) 
------------------------------------ 
  
  
----------blip-------------- 
  
function blip(player) 
  
 local team = getPlayerTeam(player) 
if team then 
 for v,blip in pairs(getAttachedElements(player)) do 
    if getElementType(blip)=="blip" then 
          local r,g,b =getTeamColor(team) 
             setBlipColor(blip,r,g,b,255) 
             setVehicleColor ( blip,r,g,b) 
         end 
              end 
                     end  
 end 
    
  
function timer() 
setTimer(blip,3000,1,source) 
end 
  
addEventHandler("onPlayerSpawn",getRootElement(),timer) 
  
addEvent ( 'onPlayerPickUpRacePickup', true ) 
    function zaa ( id, type, model ) 
        if ( getPlayerTeam ( source ) ) then 
            if ( eventName == 'onPlayerPickUpRacePickup' and id == 'vehiclechange' or id == 'repair' or id == 'nitro' ) then 
                local r, g, b = getTeamColor ( getPlayerTeam ( source ) ) 
                local vehicle = getPedOccupiedVehicle(source) 
                setVehicleColor ( vehicle, r, g, b ); 
            else 
                local r, g, b = getTeamColor ( getPlayerTeam ( source ) ) 
                 local vehicle = getPedOccupiedVehicle(source) 
                setVehicleColor ( vehicle, r, g, b ) 
            end 
        end 
    end 
addEventHandler ( 'onPlayerVehicleEnter', root, zaa ) 
addEventHandler ( 'onPlayerPickUpRacePickup', root, zaa ) 
  

Link to comment

Why are you missing "end" on line 20? I'm pretty sure you get more error/warning messages but you showed us only 1 of them which tells us there is something wrong with the argument but there isn't. Better code indentation will solve your problem.

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