Mazer30 Posted June 22, 2012 Share Posted June 22, 2012 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" 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
Wei Posted June 22, 2012 Share Posted June 22, 2012 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 Posted June 22, 2012 Share Posted June 22, 2012 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
Wei Posted June 22, 2012 Share Posted June 22, 2012 But player is allready in a vehicle. I think. Link to comment
Mazer30 Posted June 22, 2012 Author Share Posted June 22, 2012 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
Mazer30 Posted June 22, 2012 Author Share Posted June 22, 2012 Btw, I have a small problem. A friend of mine joined and this popped up in the console: Link to comment
Guest Guest4401 Posted June 22, 2012 Share Posted June 22, 2012 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
Callum Posted June 22, 2012 Share Posted June 22, 2012 Looping every player every 100 miliseconds is very bad practise. You should use the onVehicleEnter event. Link to comment
Wei Posted June 22, 2012 Share Posted June 22, 2012 It's race! You are allready in vehicle!!!!! Link to comment
TwiX! Posted June 22, 2012 Share Posted June 22, 2012 It's race! You are allready in vehicle!!!!! nope, when map starting you can use onPlayerVehicleEnter or onPlayerPickUpRacePickup Link to comment
Mefisto_PL Posted June 22, 2012 Share Posted June 22, 2012 Dude this error will be showed everytime to use make vehicle colour with "onPlayerVehicleEnter" on Race, but it works. Link to comment
Guest Guest4401 Posted June 23, 2012 Share Posted June 23, 2012 Looping every player every 100 miliseconds is very bad practise. You should use the onVehicleEnter event. That's what I did initially. viewtopic.php?f=91&t=44622#p447181 Link to comment
Callum Posted June 23, 2012 Share Posted June 23, 2012 If it's race, then use the custom 'onMapStarting' event (see this page for more information about race events). Link to comment
Guest Guest4401 Posted June 23, 2012 Share Posted June 23, 2012 Vehicles might not have been spawned during onMapStarting. Link to comment
Mefisto_PL Posted June 23, 2012 Share Posted June 23, 2012 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 ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now