Lloyd Logan Posted January 20, 2013 Posted January 20, 2013 How can i make it so that only the "Bus Driver" team can enter the Bus/Coaches? I have this for the Veh and Skins, I would like it for the team? busSkins = { [255] = true } busVehs = { [437] = true } function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle if ( busVehs[getElementModel ( source )] ) and ( not busSkins[getElementModel ( thePlayer )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin removePedFromVehicle( thePlayer )-- force the player out of the vehicle outputChatBox("Only Bus Drivers can drive this vehicle!", thePlayer) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle )
Baseplate Posted January 20, 2013 Posted January 20, 2013 busTeams = { [Team] = true } busVehs = { [437] = true } function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle if ( busVehs[getElementModel ( source )] ) and ( not busTeams[getPlayerTeam( thePlayer )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin removePedFromVehicle( thePlayer )-- force the player out of the vehicle outputChatBox("Only Bus Drivers can drive this vehicle!", thePlayer) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle )
csiguusz Posted January 20, 2013 Posted January 20, 2013 There are some solutions for this: teams = { ["busteam"] = true; ["busteam2"] = true } function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle if ( busVehs[getElementModel ( source )] ) and ( not teams[getTeamName( getPlayerTeam( thePlayer ) )] ) then removePedFromVehicle( thePlayer )-- force the player out of the vehicle outputChatBox("Only Bus Drivers can drive this vehicle!", thePlayer) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) Or this: function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle if ( busVehs[getElementModel ( source )] ) and ( getPlayerTeam( thePlayer ) ~= team )] ) then removePedFromVehicle( thePlayer )-- force the player out of the vehicle outputChatBox("Only Bus Drivers can drive this vehicle!", thePlayer) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle )
csiguusz Posted January 20, 2013 Posted January 20, 2013 Oh, you were a bit faster Samer, but yours should work also .
Baseplate Posted January 20, 2013 Posted January 20, 2013 Yeah that's because of my 1337 horsepowers hands xDD
3NAD Posted January 20, 2013 Posted January 20, 2013 teamName = "Bus Driver" busVehs = { [437] = true } function enterVehicle ( thePlayer ) if busVehs [ getElementModel ( source ) ] then if getTeamFromName ( teamName ) then if getPlayerTeam ( thePlayer ) ~= getTeamFromName ( teamName ) then outputChatBox ( "Only Bus Drivers can drive this vehicle!", thePlayer, 255, 0, 0, true ) cancelEvent ( ) end else outputChatBox ( "The Team Is not Available !", thePlayer, 255, 255, 0, true ) end end end addEventHandler ( "onVehicleStartEnter", root, enterVehicle )
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