kuwalda Posted June 23, 2014 Share Posted June 23, 2014 Can someone please show me brief example on how to createVehicle and then apply on it rule, that only specific team can gain access to it? I had an idea like: car1 = createVehicle ( 540, x, y, z ) car2 = createVehicle ( 540, x, y, z ) car3 = createVehicle ( 540, x, y, z ) function enterVehicle ( thePlayer, seat, jacked ) if car1 or car2 or car3 and getTeamName ~= "myTeam" then --kick him out of the car end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) but is this basiclly the only way? I would like better that those cars are locked and only "myTeam" can open the doors and drive normally with them. Is this possible or I have to use something like I mentioned above? Or maybe someone have better solution or advice? Link to comment
ADCX Posted June 23, 2014 Share Posted June 23, 2014 car1 = createVehicle ( 540, x, y, z ) car2 = createVehicle ( 540, x, y, z ) car3 = createVehicle ( 540, x, y, z ) function enterVehicle ( thePlayer, seat, jacked ) if not (getTeamName(getPlayerTeam(thePlayer)) == "MyTeam") then if (source == car1) or (source == car2) or (source == car3) then cancelEvent() end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) Link to comment
Max+ Posted June 23, 2014 Share Posted June 23, 2014 you mean like this , ? Vehicles = { [540]=true} -- Cars , function enterVehicle(player) local Team = getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) if (Vehicles[getElementModel(source)]) and (Team ~= "myTeam") then outputChatBox('welcome Back ',player, 0, 255, 0 ) else removePedFromVehicle(player) outputChatBox("You Cant Use this Car it's Private !", player, 255, 0, 0) end end addEventHandler("onVehicleEnter", root, enterVehicle) Link to comment
kuwalda Posted June 24, 2014 Author Share Posted June 24, 2014 Ok, thanks for help, but why do both of these scripts give me out Bad 'player' pointer @ 'getPlayerTeam'(1) Bad argument @ 'getTeamName' Link to comment
Moderators IIYAMA Posted June 24, 2014 Moderators Share Posted June 24, 2014 You sure it is a player and not a ped? Link to comment
kuwalda Posted June 24, 2014 Author Share Posted June 24, 2014 You sure it is a player and not a ped? Ohh, I got it. I have traffic resource going on for me around the map and probbobly those peds are driving with those cars. Is there a way to apply this check only for "real" players/peds? Link to comment
kuwalda Posted June 24, 2014 Author Share Posted June 24, 2014 Nevermind, got it all working by adding if getElementType(player) == "player" then Thanks everyone for help! 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