Jump to content

Carcolor the same as My Team


Mazer30

Recommended Posts

Hello guys,

I just messed around with the create team script, and I got it working. But I have a question, I want my Carcolor to be the same color as my team, could somebody help me out?

Here's a picture of what I mean by "Team"

29f74tv.png

And here's my Create team lua:

function createAdminTeamOnStart () 
    AdminTeam = createTeam ( "|Kr1|", 123, 143, 209 )-- create a new team and named it 'Kr1' 
end 
addEventHandler("onResourceStart", resourceRoot, createAdminTeamOnStart) -- add an event handler 
  
function setAdminTeam() 
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then -- if he is admin 
   setPlayerTeam(source, AdminTeam) -- set him to admin team 
   end 
end 
addEventHandler("onPlayerLogin",getRootElement(),setAdminTeam) -- add an event handler 

Link to comment
setTimer( 
function () 
local players = getElementsByType ( "player" ) 
    for _,v in ipairs(players) do 
        if getTeamName(getPlayerTeam( v )) == "|Kr1|" then 
            local pVehicle = getPedOccupiedVehicle( v ) 
            if pVehicle then 
            setVehicleColor( pVehicle, 123, 143, 209  ) 
            end 
        end 
    end 
end 
, 100, 0) 

Try

Link to comment
Guest Guest4401

getTeamColor might help you, as it gets the team color and helps you get the color of each team.

addEventHandler("onPlayerVehicleEnter",root, 
    function(vehicle) 
        local team = getPlayerTeam(source) 
        if team then 
            local r,g,b = getTeamColor(team) 
            setVehicleColor(vehicle,r,g,b) 
        end 
    end 
) 

Link to comment
setTimer( 
function () 
local players = getElementsByType ( "player" ) 
    for _,v in ipairs(players) do 
        if getTeamName(getPlayerTeam( v )) == "|Kr1|" then 
            local pVehicle = getPedOccupiedVehicle( v ) 
            if pVehicle then 
            setVehicleColor( pVehicle, 123, 143, 209  ) 
            end 
        end 
    end 
end 
, 100, 0) 

Try

Works like a charm, thank you.

Link to comment
Guest Guest4401
setTimer( 
function () 
local players = getElementsByType ( "player" ) 
    for _,v in ipairs(players) do 
        local team = getPlayerTeam(v) 
        if team then 
            if getTeamName(team) == "|Kr1|" then 
                local pVehicle = getPedOccupiedVehicle( v ) 
                if pVehicle then 
                setVehicleColor( pVehicle, 123, 143, 209  ) 
                end 
            end 
        end 
    end 
end 
, 100, 0) 

Link to comment

I think this problem could be in autoteams script if you have it. Because if in team is 0 peoples, team is deleted, but when is 1 people team is creating again and maybe server can't read color from team which is deleted . But I could be wrong. (Sorry if I make a mistake, I'm from Poland :D)

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