Jump to content

Namecolors?


Deadmau5

Recommended Posts

Works :)

Now another problem...

Why it spams the chat when i use this code?

function setTheCarColors( ) 
    local playersteam = getTeamFromName( "Players" ) 
    local membersteam = getTeamFromName( "Members" ) 
    local moderatorsteam = getTeamFromName( "Moderators" ) 
    local adminsteam = getTeamFromName( "Admins" ) 
    local ownersteam = getTeamFromName( "Server Owners" ) 
     
    for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
        local theplayer = getVehicleOccupant( car ) 
        local nowteam = getPlayerTeam( theplayer )         <------------- Always showing and spamming an error at this line... 
        if(nowteam == playersteam) then 
            setVehicleColor(car, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0) 
        end 
        if(nowteam == membersteam) then 
            setVehicleColor(car, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 
        end 
        if(nowteam == moderatorsteam) then 
            setVehicleColor(car, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 
        end 
        if(nowteam == adminsteam) then 
            setVehicleColor(car, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0) 
        end 
        if(nowteam == ownersteam) then 
            setVehicleColor(car, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 
        end 
    end 
end 
addEvent("onVehColorChange",true) 
addEventHandler("onVehColorChange",getRootElement(),setTheCarColors) 
  
function timer() --Delay it a bit to allow players to warp in their vehicle... 
    setTimer(setTheCarColors,500,0) 
end 
addEventHandler("onMapStarting",getRootElement(),timer) 
addCommandHandler ( "set_vehicle_color", setTheCarColors ) 

The error:

WARNING: putplayertoteamscript/script.lua:74: Bad argument @ 'getPlay

erTeam'

and that causes serverlags -.-

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