TheNightRider Posted December 31, 2011 Share Posted December 31, 2011 Hey guys ive been trying to set vehicles to only take driver based on their team I though to do 1 team and then try to do different teams which are in my server. However I cannot get the function to work Could anyone give me some help please? This far as i got so far, function pAccess (thePlayer) if (police[getElementModel(source)]) and then Cop = getPlayerTeam ( thePlayer ), not ( thePlayer ) then cancelEvent() outputChatBox("you are not a Police officer", thePlayer) end end addEventHandler("onVehicleStartEnter",root,pAccess) Link to comment
50p Posted December 31, 2011 Share Posted December 31, 2011 Do you want only 1 skin to be allowed to drive the vehicles? Or only specific vehicles to be driven by 1 team? Like, police officers can drive police vehicles? Your if statement won't work.. Use "debugscript 3" command and try to run this script. You have to remember to debug your scripts, that is the most important action during scripting. Nobody scripts without debugging. I don't really understand your question. Link to comment
TheNightRider Posted December 31, 2011 Author Share Posted December 31, 2011 I don't want the script to work based on players skin otherwise i would of done that. The code itself is refering to team so it will only work for a team called COP And of course I use debugger lol what so of question is that? The debugger says unexpected symbol near then only line 16 Link to comment
TAPL Posted December 31, 2011 Share Posted December 31, 2011 function pAccess (thePlayer) if (police[getElementModel(source)]) and getTeamName(getPlayerTeam(thePlayer)) == "Cop" then cancelEvent() outputChatBox("you are not a Police officer", thePlayer) end end addEventHandler("onVehicleStartEnter",root,pAccess) Link to comment
TheNightRider Posted December 31, 2011 Author Share Posted December 31, 2011 Thank you that makes a lot more sense Link to comment
TheNightRider Posted December 31, 2011 Author Share Posted December 31, 2011 I have got it work however it only allows Cops to drive Police vehicles and nothing else lol Anyone got any idea's? local police = {[598]=true, [596]=true, [597]=true, [599]=true, [601]=true, [490]=true, [528]=true} function pAccess (thePlayer) if (police[getElementModel(source)]) and getTeamName(getPlayerTeam(thePlayer)) == "LVPD" then return 0 else cancelEvent() outputChatBox("you are not a Police officer", thePlayer) end end addEventHandler("onVehicleStartEnter",root,pAccess) Link to comment
BinSlayer1 Posted December 31, 2011 Share Posted December 31, 2011 that's what it's scripted to do.. it looks like it does just that Link to comment
TheNightRider Posted December 31, 2011 Author Share Posted December 31, 2011 (edited) Okay but I didn't want it to restrict the Cops from driving other vehicles while their is no script in place to restrict them. Could you please show me where ive gone wrong on this small script? It should only allow police to drive police vehicles but not disallowing them to drive other vehicles. Could i add something to make the script ignore other vehicles which isn't in the array? Edited December 31, 2011 by Guest Link to comment
BinSlayer1 Posted December 31, 2011 Share Posted December 31, 2011 local police = {[598]=true, [596]=true, [597]=true, [599]=true, [601]=true, [490]=true, [528]=true} function pAccess (thePlayer) if police[getElementModel(source)] and getTeamName(getPlayerTeam(thePlayer)) ~= "LVPD" then cancelEvent() outputChatBox("you are not a Police officer", thePlayer) end end addEventHandler("onVehicleStartEnter",root,pAccess) Link to comment
TheNightRider Posted December 31, 2011 Author Share Posted December 31, 2011 Thanks man that works a treat I changed it from COP to LVPD cos i remembered that's the only police i have so far lol. Another issue i noticed players cannot get into passengers seat what could I do to allow them to enter vehicle as passenger but disallow them to enter drivers seat? PS could you explain the difference between using == and ~= ? Link to comment
BinSlayer1 Posted January 1, 2012 Share Posted January 1, 2012 local police = {[598]=true, [596]=true, [597]=true, [599]=true, [601]=true, [490]=true, [528]=true} function pAccess (thePlayer, seat) if police[getElementModel(source)] and getTeamName(getPlayerTeam(thePlayer)) ~= "LVPD" and seat == 0 then cancelEvent() outputChatBox("you are not a Police officer", thePlayer) end end addEventHandler("onVehicleStartEnter",root,pAccess) Here you go. But.. You do realise that you must learn from the codes that are given to you, don't you? Next time try to do it yourself. You need to learn from the mta wiki. Click the function names in the code for more info. Link to comment
TheNightRider Posted January 1, 2012 Author Share Posted January 1, 2012 Thank you for your advise and I do use Wikki etc. and i did have the code working before you posted the code you modified. I have it working 100% as expected and again thank you for your input. PS you cannot expect someone to learn by just doing the Wikki thing getting input from other fellow human beings goes much further i.e. discussions brings more light to the subject 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