igthomas Posted February 16, 2012 Share Posted February 16, 2012 Here's a script that I've made but the problem is that everyone can enter the vehicles not only FBI fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi(player, seat, jacked) if (source == fbi1 and source == fbi2 and source == fbi3) then local skin = getElementModel (thePlayer) if ( skin == 100 or skin == 255) then return end cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), lockfbi ) Link to comment
SDK Posted February 16, 2012 Share Posted February 16, 2012 Some small mistakes fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi(player, seat, jacked) if (source == fbi1 or source == fbi2 or source == fbi3) then local skin = getElementModel (player) if ( skin == 100 or skin == 255) then cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), lockfbi ) Link to comment
igthomas Posted February 16, 2012 Author Share Posted February 16, 2012 Tried and same problem everyone can enter Link to comment
Scripting Moderators Sarrum Posted February 16, 2012 Scripting Moderators Share Posted February 16, 2012 fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi(player, seat, jacked) if (source == fbi1 or source == fbi2 or source == fbi3) then local skin = getElementModel (player) if not (skin == 100 or skin == 255) then --FBI skins cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), lockfbi ) Link to comment
denny199 Posted February 16, 2012 Share Posted February 16, 2012 It's onVehicleEnter.... fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi(player, seat, jacked) if (source == fbi1 or source == fbi2 or source == fbi3) then local skin = getElementModel (player) if not (skin == 100 or skin == 255) then --FBI skins removePedFromVehicle ( player ) outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end addEventHandler ( "onVehicleEnter", getRootElement(), lockfbi ) Link to comment
Castillo Posted February 16, 2012 Share Posted February 16, 2012 Why denny? you can cancel the event "onVehicleStartEnter", instead of removing the player from the vehicle. Link to comment
denny199 Posted February 16, 2012 Share Posted February 16, 2012 Searched wrong sorry, my mistake, i was tought it was a old event... Link to comment
igthomas Posted February 16, 2012 Author Share Posted February 16, 2012 Thanks ZverCR it worked and this mistake won't happen again ;P and last question is it possible to change the car color with createVehicle? or should I make a new function where I mention the car colors? Link to comment
igthomas Posted February 18, 2012 Author Share Posted February 18, 2012 Guys I have another problem now: only FBi can enter car and only they can seat as passanger so if I spawn as another skin I couldn't even press g Link to comment
Kenix Posted February 18, 2012 Share Posted February 18, 2012 (edited) fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi( player, seat, jacked ) if source == fbi1 or source == fbi2 or source == fbi3 then if seat == 0 then local skin = getElementModel ( player ) if not skin == 100 or not skin == 255 then --FBI skins cancelEvent( ) outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end end addEventHandler ( "onVehicleStartEnter", root, lockfbi ) Edited February 18, 2012 by Guest Link to comment
Castillo Posted February 18, 2012 Share Posted February 18, 2012 You mean passengers can't enter because they are not using the X skin? If so, you must check if the seat is 0. fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi(player, seat, jacked) if (source == fbi1 or source == fbi2 or source == fbi3) then if (seat == 0) then local skin = getElementModel (player) if not (skin == 100 or skin == 255) then --FBI skins cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), lockfbi ) Link to comment
igthomas Posted February 19, 2012 Author Share Posted February 19, 2012 Thanks Castillo that's what I wanted and it worked Link to comment
igthomas Posted February 23, 2012 Author Share Posted February 23, 2012 Sorry to bump but why doesn't it want to work with ACL Groups? fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi(player, seat, jacked) if (source == fbi1 or source == fbi2 or source == fbi3) then if (seat == 0) then if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("FBI" or "Admin")) then cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), lockfbi ) Link to comment
TAPL Posted February 23, 2012 Share Posted February 23, 2012 fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi(player, seat, jacked) if (source == fbi1 or source == fbi2 or source == fbi3) then if (seat == 0) then if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("FBI" or "Admin")) then cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), lockfbi ) Link to comment
igthomas Posted February 23, 2012 Author Share Posted February 23, 2012 Only FBI members can enter the vehicles not admins Link to comment
Kenix Posted February 23, 2012 Share Posted February 23, 2012 (edited) fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi( player, seat, jacked ) if source == fbi1 or source == fbi2 or source == fbi3 then if (seat == 0) then if not isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "FBI" ) ) and not isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "Admin" ) ) then cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end end addEventHandler ( "onVehicleStartEnter", root, lockfbi ) TAPL:aclGetGroup( "FBI" or "Admin" ) incorrect , because if value nil or false then used operator 'or'. Example g = false print( g or 0 ) -- 0 Edited February 23, 2012 by Guest Link to comment
igthomas Posted February 23, 2012 Author Share Posted February 23, 2012 It writed the Outputchatbox but nobody can enter it Link to comment
Kenix Posted February 23, 2012 Share Posted February 23, 2012 It should work only for Admins and FBI groups. Link to comment
igthomas Posted February 23, 2012 Author Share Posted February 23, 2012 Yes you are right but when I log in as Admin or FBI and try to enter vehicle it writes me "Only FBI can enter this vehicle" Link to comment
Kenix Posted February 23, 2012 Share Posted February 23, 2012 fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi( player, seat, jacked ) if source == fbi1 or source == fbi2 or source == fbi3 then if (seat == 0) then if not isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "FBI" ) ) and not isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "Admin" ) ) then cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end end addEventHandler ( "onVehicleStartEnter", root, lockfbi ) My bad:/ Tested Link to comment
igthomas Posted February 23, 2012 Author Share Posted February 23, 2012 Thanks man it works perfectly now 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