Jump to content

[HELP] vehicle


Recommended Posts

Posted

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 
    ) 

Posted (edited)
I don't understand what you mean.
I think he mean you want any vehicle not a veh[player] only ?

no actually i want any player who wants to enter the the Private vehicle he can't if he is not in the team :?

Edited by Guest
Posted

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

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

Posted (edited)

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
Posted (edited)

the code is okay but i ask if you sure that will by for all players :?

Edit:

Because I do not have server to test it

Edited by Guest
Posted

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 
) 
Posted
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:

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