Jump to content

teams carcolor


Recommended Posts

If you are in teamAdmins your car will be black but this don't work?

function teamcolor ()
local players = getPlayersInTeam ( teamAdmins )
local vehicle = getPedOccupiedVehicle( players )
if ( vehicle ) then
	setVehicleColor ( vehicle, 0, 0, 0, 0 )
end
end
 
setTimer ( teamcolor, 100, 0 )

Link to comment
If you are in teamAdmins your car will be black but this don't work?

function teamcolor ()
local players = getPlayersInTeam ( teamAdmins )
local vehicle = getPedOccupiedVehicle( players )
if ( vehicle ) then
	setVehicleColor ( vehicle, 0, 0, 0, 0 )
end
end
 
setTimer ( teamcolor, 100, 0 )

is your teamAdmins set before?

and you have to loop through all players, not use array as player in getPedOccupiedVehicle

like

for key,val in ipairs(players) do
-- do your loop here,
-- val = player
end

read about arrays and loops in lua

Link to comment

this is my team script but the teamcarcolor function don't work, everything else works fine =)

function createTeamsOnStart ()
  teamAdmins = createTeam ( "Admins", 255, 100, 0 )
  teamMembers = createTeam ( "Members", 34, 139, 34 )
  teamGuests = createTeam ( "Guests", 255, 255, 255 )
end
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart  )
 
addEventHandler( "onPlayerJoin", root,
 function()
     setPlayerTeam ( source, teamGuests )
end
)
 
addEventHandler( 'onPlayerLogin', root,
 function()
   if isObjectInACLGroup( 'user.'..getPlayerName( source ), aclGetGroup( 'Admin' ) ) then
     setPlayerTeam ( source, teamAdmins )
   else 
     setPlayerTeam ( source, teamMembers )
     outputChatBox('* LOGIN: ' .. getPlayerName(source) .. ' has logged in', 34, 139, 34, true)
   end;
 end
);
 
function teamcarcolor()
local theTeam = getTeamFromName ( teamAdmins )
if ( teamAdmins ) then
	local players = getPlayersInTeam ( teamAdmins )
	for playerKey, playerValue in ipairs ( players ) do
		setVehicleColor ( players, 0, 0, 0, 0 )
	end
end
end

Link to comment

read my post again..

part of your code:

local players = getPlayersInTeam ( teamAdmins )
for playerKey, playerValue in ipairs ( players ) do
setVehicleColor ( players, 0, 0, 0, 0 )
end

"playerValue" is your player!! "players" is array of players!!

so in that loop (from "for" to "end") you have to

1. get player vehicle

2. set vehicle color

so again:

read about arrays and loops in lua

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