kuwalda Posted June 23, 2014 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?
ADCX Posted June 23, 2014 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 ) My Skype: scriptmtasupport My Resources: http://www.scriptmta.co.nr - Cheap high-quality MTA resources by me and Kevin (ScriptMTA.co.nr)
Max+ Posted June 23, 2014 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) - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
kuwalda Posted June 24, 2014 Author 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'
Moderators IIYAMA Posted June 24, 2014 Moderators Posted June 24, 2014 You sure it is a player and not a ped? Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
kuwalda Posted June 24, 2014 Author 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?
kuwalda Posted June 24, 2014 Author Posted June 24, 2014 Nevermind, got it all working by adding if getElementType(player) == "player" then Thanks everyone for help!
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