Jump to content

Carcolor the same as My Team


Mazer30

Recommended Posts

Posted

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 

Posted
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

Guest Guest4401
Posted

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 
) 

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

Guest Guest4401
Posted
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) 

Posted

Looping every player every 100 miliseconds is very bad practise. You should use the onVehicleEnter event.

Posted
It's race! You are allready in vehicle!!!!!

nope, when map starting you can use

onPlayerVehicleEnter 

or

onPlayerPickUpRacePickup 

Guest Guest4401
Posted

Vehicles might not have been spawned during onMapStarting.

Posted

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)

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