Enargy, Posted December 7, 2013 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 )
Castillo Posted December 7, 2013 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 )
Enargy, Posted December 7, 2013 Author Posted December 7, 2013 but I can still enter the car without equipment
TAPL Posted December 7, 2013 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.
xScatta Posted December 7, 2013 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 )
Castillo Posted December 7, 2013 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 )
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