Jump to content

[HELP] vehicle


Recommended Posts

Hello guys the code, okay but the problem is the order only for the player who have the vehicle i want any player want to enter

the vehicle he can't if he is not in the team and thanks.

    addEventHandler("onVehicleStartEnter", root, 
    function    (   player  ) 
    if ( source == veh[player] ) then 
    if Settings["forFree"] == true then return end 
    if getPlayerTeam ( player ) ~= getTeamFromName ( Settings["teamName"] ) then 
       outputChatBox( "* #0069c7this vehicle for #ff0000team",player,255,0,0,true ) 
                    cancelEvent(    ) 
                  end 
                end 
            end 
    ) 

Link to comment

addEvent( "onVehicleStartEnter", true ) 
addEventHandler( "onVehicleStartEnter", getRootElement(), 
function( player ) 
    if(source==C)then 
        if (getPlayerTeam(player)~="yourteam")then 
            cancelEvent() 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Only For Team !", player,r,b,g, true ) 
        else 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Welcome Team", player, r,b,g, true ) 
        end 
    end 
end 
) 

* C = the vehicle what you created and what you want it as Team's vehicle

Link to comment
addEvent( "onVehicleStartEnter", true ) 
addEventHandler( "onVehicleStartEnter", getRootElement(), 
function( player ) 
    if(source==C)then 
        if (getPlayerTeam(player)~="yourteam")then 
            cancelEvent() 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Only For Team !", player,r,b,g, true ) 
        else 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Welcome Team", player, r,b,g, true ) 
        end 
    end 
end 
) 

* C = the vehicle what you created and what you want it as Team's vehicle

ok are you sure that any player other can't enter the vehicle if he is not in team..? :?

Link to comment

why that?, i post it in NotePad++ and all true

EDIT:

sorry my code is wrong as prestege said

try this

local team = getPlayerTeam ( player ) 
  
addEvent( "onVehicleStartEnter", true ) 
addEventHandler( "onVehicleStartEnter", getRootElement(), 
function( player ) 
    if(source==C)then 
        if (getTeamName( team ) == "yourTeam") then 
            cancelEvent() 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Only For Team !", player,r,b,g, true ) 
        else 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Welcome Team", player, r,b,g, true ) 
        end 
    end 
end 
) 
Edited by Guest
Link to comment

so replace the veh[player] from C

PUT IT LIKE THIS

local team = getPlayerTeam ( player ) 
  
addEvent( "onVehicleStartEnter", true ) 
addEventHandler( "onVehicleStartEnter", getRootElement(), 
function( player ) 
    if(source==veh[player])then 
        if (getTeamName( team ) == "yourTeam")then 
            cancelEvent() 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Only For Team !", player,r,b,g, true ) 
        else 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Welcome Team", player, r,b,g, true ) 
        end 
    end 
end 
) 
Link to comment
so replace the veh[player] from C

PUT IT LIKE THIS

local team = getPlayerTeam ( player ) 
  
addEvent( "onVehicleStartEnter", true ) 
addEventHandler( "onVehicleStartEnter", getRootElement(), 
function( player ) 
    if(source==veh[player])then 
        if (getTeamName( team ) == "yourTeam")then 
            cancelEvent() 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Only For Team !", player,r,b,g, true ) 
        else 
            r,b,g = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
            outputChatBox( "* Welcome Team", player, r,b,g, true ) 
        end 
    end 
end 
) 

yeah thanks man for help :wink:

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