Baseplate Posted September 7, 2012 Posted September 7, 2012 copVehicles = { [523]=true,[598]=true,[596]=true,[597]=true,[599]=true } copTeams = {["Police"]=true,["Military"]=true,["SWAT"]=true} function copenterVehicle ( player, seat, jacked ) if ( copVehicles[getElementModel ( source )] ) and ( not copTeams[getTeamName(getPlayerTeam( player ))] ) and ( seat == 0 ) then removePedFromVehicle ( player )--force the player out of the vehicle outputChatBox ( "You cannot drive this car.", 255, 0, 0, player ) --and tell the player why end end addEventHandler ( "onVehicleEnter", getRootElement(), copenterVehicle ) This is my current script so far, how can I make the player can't use the car before he open the door and gets in
Moderators IIYAMA Posted September 7, 2012 Moderators Posted September 7, 2012 cancelEvent () copVehicles = { [523]=true,[598]=true,[596]=true,[597]=true,[599]=true } copTeams = {["Police"]=true,["Military"]=true,["SWAT"]=true} function copenterVehicle ( player, seat, jacked ) if ( copVehicles[getElementModel ( source )] ) and ( not copTeams[getTeamName(getPlayerTeam( player ))] ) and ( seat == 0 ) then cancelEvent () outputChatBox ( "You cannot drive this car.", 255, 0, 0, player ) --and tell the player why end end addEventHandler ( "onVehicleEnter", getRootElement(), copenterVehicle )
Baseplate Posted September 7, 2012 Author Posted September 7, 2012 Dosen't work, I can get in the car it outputs that sentence
InDev Posted September 7, 2012 Posted September 7, 2012 Have you tried with the onVehicleStartEnter event ? The example do exactly what you want to do by the way...
Baseplate Posted September 7, 2012 Author Posted September 7, 2012 I want to keep it on Teams mate. EDIT:I found a solution i'll test and i'll tell you policeVehicles = { [598]=true,[596]=true,[597]=true,[599]=true } copTeams = {["Police"]=true,["Military"]=true,["SWAT"]=true} function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle if ( policeVehicles[getElementModel(source)] ) and ( not copTeams[getTeamName(getPlayerTeam( player ))] ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin cancelEvent() outputChatBox ( "Only policeman can enter police cars!", player ) --and tell the player why end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) --add an event handler for onVehicleStartEnter Dosen't work
Moderators IIYAMA Posted September 8, 2012 Moderators Posted September 8, 2012 https://wiki.multitheftauto.com/wiki/OnVehicleStartEnter why don't u use the full version of the wiki page?
Castillo Posted September 8, 2012 Posted September 8, 2012 policeVehicles = { [ 598 ] = true, [ 596 ] = true, [ 597 ] = true, [ 599 ] = true } copTeams = { [ "Police" ] = true, [ "Military" ] = true, [ "SWAT" ] = true } function enterVehicle ( player, seat, jacked ) if ( policeVehicles [ getElementModel ( source ) ] ) and not ( copTeams [ getTeamName ( getPlayerTeam ( player ) ) ] ) then cancelEvent ( ) outputChatBox ( "Only policeman can enter police cars!", player ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
Baseplate Posted September 8, 2012 Author Posted September 8, 2012 As usual, Castillo helps thanks mate workin as I wanted
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