Jump to content

[HELP]Colored cars with auto-team


t4rox

Recommended Posts

Hello i donwload auto-team resource and its working great, but i want change car color (not only name).Im begginer so take it easy please :)

This is the auto-team script:

---------------do not change or touch this---------- 
Names={} 
Tags={} 
Colors={} 
ACL={} 
-------------------------------------------------------------- 
  
---------------------------here put your clans read readme for instructions--------------------------------------- 
  
  
local names ={"Destruction Derby Skills"} 
local tags  ={"%DDS%|"} 
local colors ={"#ff00ff"} 
local acls ={"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) 
         end 
              end 
                     end  
 end 
    
  
function timer() 
setTimer(blip,3000,1,source) 
end 
  
addEventHandler("onPlayerSpawn",getRootElement(),timer) 
  
  

Link to comment

Well you can use this

function autoTeamColor () 
local vehicle = getPedOccupiedVehicle(source) 
local team = getPlayerTeam(source) 
if (team = getTeamFromName("Destruction Derby Skills")) 
setVehicleColor(vehicle, 255, 0, 255) 
end 
end 
addEventHandler("onPlayerSpawn", root, autoTeamColor) 

I'd suggest to use it in other script

Link to comment
I create the file, name it script.lua and i make meta.xml.. what must be in meta? this?:
     "unnamed" type="script" name="car_color" description="This script will change your car color.(for teams)" /> 
     

< 
meta> 
     <script src="script.lua" /> 
</meta> 

is not needed.

Btw. i wouldn't use that script.

I would use:

onVehicleEnter 
getPlayerTeam 
getTeamColor 
setVehicleColor 

Link to comment

I make this... its copy of Samer post

function carColor ( source ) 
    local playerTeam = getPlayerTeam ( source )   
    local playerCar = onVehicleEnter ( source ) 
if (playerTeam = getTeamColor ( playerTeam )) 
setVehicleColor ( playerCar, 255, 100, 255 ) 
     
    end 
end 
addEventHandler("onPlayerSpawn", root, carColor) 

I think i can´t ask what is bad because everythink is bad (i think). :(

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