Enargy, Posted December 7, 2013 Share Posted December 7, 2013 I have an error in this script, I want the car in the id '411 'and '402' Whether booked by a team, but when a player who is not a member of the team can lead (server) NameT= "SC Life" vehTeam = {{411,402}} function enterVehicle ( thePlayer, seat, jacked ) if getElementType ( thePlayer ) == "player" then local team = getPlayerTeam ( thePlayer ) local teamName = ( team and getTeamName ( team ) or "" ) if ( teamName == NameT ) then if ( vehTeam[getElementModel ( source )] ) then outputChatBox("vehicle from: "..NameT, thePlayer, 255, 255, 0, true) else outputChatBox("you can't use this", thePlayer, 255, 255, 0, true) end end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) Link to comment
Castillo Posted December 7, 2013 Share Posted December 7, 2013 You made your table wrong. NameT = "SC Life" vehTeam = { [ 411 ] = true, [ 402 ] = true } function enterVehicle ( thePlayer, seat, jacked ) if ( getElementType ( thePlayer ) == "player" ) then local team = getPlayerTeam ( thePlayer ) local teamName = ( team and getTeamName ( team ) or "" ) if ( teamName == NameT ) then if ( vehTeam [ getElementModel ( source ) ] ) then outputChatBox ( "vehicle from: ".. NameT, thePlayer, 255, 255, 0, true ) else outputChatBox ( "you can't use this", thePlayer, 255, 255, 0, true ) end end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) Link to comment
Enargy, Posted December 7, 2013 Author Share Posted December 7, 2013 but I can still enter the car without equipment Link to comment
TAPL Posted December 7, 2013 Share Posted December 7, 2013 That's because you never cancelled the event (this event not cancelable anyway) and you never removed the player from the vehicle. Link to comment
xScatta Posted December 7, 2013 Share Posted December 7, 2013 This would work like you want. NameT = "SC Life" vehTeam = { [ 411 ] = true, [ 402 ] = true } function enterVehicle ( thePlayer, seat, jacked ) if ( getElementType ( thePlayer ) == "player" ) then local team = getPlayerTeam ( thePlayer ) local teamName = ( team and getTeamName ( team ) or "" ) if ( teamName == NameT ) then if ( vehTeam [ getElementModel ( source ) ] ) then outputChatBox ( "vehicle from: ".. NameT, thePlayer, 255, 255, 0, true ) else outputChatBox ( "you can't use this", thePlayer, 255, 255, 0, true ) removePedFromVehicle(thePlayer) end end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) Link to comment
Castillo Posted December 7, 2013 Share Posted December 7, 2013 but I can still enter the car without equipment NameT = "SC Life" vehTeam = { [ 411 ] = true, [ 402 ] = true } function enterVehicle ( thePlayer, seat, jacked ) if ( getElementType ( thePlayer ) == "player" ) then local team = getPlayerTeam ( thePlayer ) local teamName = ( team and getTeamName ( team ) or "" ) if ( teamName == NameT ) then if ( vehTeam [ getElementModel ( source ) ] ) then outputChatBox ( "vehicle from: ".. NameT, thePlayer, 255, 255, 0, true ) else outputChatBox ( "you can't use this", thePlayer, 255, 255, 0, true ) cancelEvent ( ) end 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