GamerDeMTA Posted July 28, 2013 Share Posted July 28, 2013 I need help with this! function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle if getElementType ( thePlayer ) == "player" then local p = getTeamName(getPlayerTeam(thePlayer)) if (p == "xd") then else removePedFromVehicle( thePlayer )-- force the player out of the vehicle --Here's the problem! ^^^^^^ end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) It works fine but it's a bit 'ugly' that. i saw in a server that when you try to enter in a vehicle of police and u aren't police, you can't just enter. But with this script the problem is that you can enter, and when u are in the vehicle, and not in the team, it just spawns you up of the vehicle. that's a bit ugly =/ can't i do that he can't just enter? Link to comment
Vision Posted July 28, 2013 Share Posted July 28, 2013 function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle if getElementType ( thePlayer ) == "player" then local p = getTeamName(getPlayerTeam(thePlayer)) if ( p ~= "xd" ) then cancelEvent ( ) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) Link to comment
GamerDeMTA Posted July 28, 2013 Author Share Posted July 28, 2013 it doesn't work... now it let's me drive the vehicle. Link to comment
iPrestege Posted July 28, 2013 Share Posted July 28, 2013 function enterVehicle ( thePlayer, seat, jacked ) local team = getPlayerTeam ( thePlayer ) if not team then return end local p = getTeamName ( team ) if p and p ~= "xd" then cancelEvent ( ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) Link to comment
GamerDeMTA Posted July 28, 2013 Author Share Posted July 28, 2013 Doesn't work. I just want to do that he can't enter the vehicle if he isn't in the team 'xd' Link to comment
boro Posted July 28, 2013 Share Posted July 28, 2013 server addEventHandler ( "onClientVehicleStartEnter", root, function ( thePlayer ) if ( thePlayer == localPlayer ) then local plrTeam = getPlayerTeam ( localPlayer ) if ( plrTeam ) then if ( getTeamName ( plrTeam ) ~= "xd" ) then cancelEvent ( ) end end end end ) Link to comment
Castillo Posted July 28, 2013 Share Posted July 28, 2013 function enterVehicle ( thePlayer, seat, jacked ) local team = getPlayerTeam ( thePlayer ) if ( not team ) then cancelEvent ( ) return end local p = getTeamName ( team ) if ( p ~= "xd" ) then cancelEvent ( ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) Link to comment
GamerDeMTA Posted July 28, 2013 Author Share Posted July 28, 2013 thanks a lot !!! it works! but can you say me how to do it for only a vehicle? for example ID 425? Link to comment
Castillo Posted July 28, 2013 Share Posted July 28, 2013 You must use getElementModel. function enterVehicle ( thePlayer, seat, jacked ) if ( getElementModel ( source ) == 425 ) then local team = getPlayerTeam ( thePlayer ) if ( not team ) then cancelEvent ( ) return end local p = getTeamName ( team ) if ( p ~= "xd" ) then cancelEvent ( ) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) Link to comment
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