arris Posted July 17, 2009 Share Posted July 17, 2009 (edited) Hi i have this code but it doesn't work and it doesn't even come up with errors can someone help me local policevehicles = { [407]=true, [416]=true, [425]=true, [427]=true, [428]=true, [432]=true, [433]=true, [470]=true, [490]=true, [523]=true, [528]=true, [544]=true, [596]=true, [597]=true, [598]=true, [599]=true, [601]=true } local policeskins = { [280]=true, [281]=true, [282]=true, [283]=true, [284]=true, [285]=true, [286]=true, [287]=true, [288]=true } function enterVehicle ( theVehicle, seat, jacked ) local skinID = getPlayerSkin ( source ) local vehID = getVehicleID ( theVehicle ) if policevehicles[vehID] and not policeskins[skinID] then removePlayerFromVehicle ( source ) outputChatBox ( "Only someones name can enter police car!", source ) end end addEventHandler ( "onPlayerEnterVehicle", getRootElement(), enterVehicle ) Edited July 17, 2009 by Guest Link to comment
heavy air Posted July 17, 2009 Share Posted July 17, 2009 im pretty new to scripting myself but i can see a few errors local polecvehicles = { [407]=true, [416]=true, [425]=true, [427]=true, [428]=true, [432]=true, [433]=true, [470]=true, [490]=true, [523]=true, [528]=true, [544]=true, [596]=true, [597]=true, [598]=true, [599]=true, [601]=true } i think this should just be the number and no local so like this ---> polecvehicles = { 407, 416, 425, etc. } and same for policeskins ----> policeskins = { 280, 281, 282, etc. } if your using the nightly 1.0 version of MTA i dont think getVehicleID works anymore ( pretty sure its getElementID ) you would need to use getPedOccupiedVehicle first though ( once again only if using nightly 1.0 MTA. If its DP2.3 getVehicleID is fine ) if policevehicles[vehID] and not policeskins[skinID] then i think this should be if vehID == "policevehicles" and skinID ~= "policeskins" then do the remove player from vehicle ( i havent used this command before so id have to check wiki for exact syntax ) u will also need to put in what to do if the player is a police obviously this is not a complete function but if u can tell me what version u are using i may be able to help a bit more But please remember im pretty new to scripting myself so my answers may not be perfect Link to comment
arris Posted July 17, 2009 Author Share Posted July 17, 2009 thank you for the info im using mta dp 2.3 deathmatch. The thing im trying to do is when a police man with the skin police enters the car he stay in it but if the person doesn't have the police skin he gets kick out of the car Link to comment
heavy air Posted July 17, 2009 Share Posted July 17, 2009 unfortunately like i said im pretty new to scripting but i will try and write you a working function for this but it may take a while the people on this forum are very helpful though so im sure somebody will give u a hand if u have a look at the scripts in the BROPH and FR and FREEROAM resources every thing u need is there if the examples on the wiki dont help thats how i picked up most of what i know just by comparing those scripts and the wiki examples ( and a lot of trial and error and a lot more help from the forums ) i wish u luck and will post whatever i can come up with Link to comment
Lordy Posted July 17, 2009 Share Posted July 17, 2009 Heavyair, no you were wrong. randomtable = {["key"] = "value"} means that randomtable["key"] == "value" Which means that if he defines randomtable[111] = true somewhere, then all he has to do is try if randomtable[vehicleID] is true. Eg he is doing it right there Only mistake I could find at the moment is that he's got the event name wrong It's "onPlayerVehicleEnter" not "onPlayerEnterVehicle" Link to comment
arris Posted July 17, 2009 Author Share Posted July 17, 2009 i tried what you guys said but it still doesn't work Link to comment
50p Posted July 17, 2009 Share Posted July 17, 2009 Why do you want to kick players out of the car? It's better if you don't let them go inside using onVehicleStartEnter. I recommend using brackets even if they are optional because in an if statement you may get unexpected results. Link to comment
arris Posted July 17, 2009 Author Share Posted July 17, 2009 ok so i got the thing working when the player tries to enter the car but now when i put on the police skin i can't enter the car Link to comment
50p Posted July 18, 2009 Share Posted July 18, 2009 You need to debug the script. Go step by step where the code goes and try to find out why it doesn't work. The previous code looked ok and your current code probably too. The thing is that when code looks fine and you get no error messages you need to trace what cause the problem by printing some text to chatbox, console or debug window. For instance, AFTER you getPlayerSkin, use outputChatBox( tostring( skinID ) ) to find out if the skinID returned a value (as you expected), then AFTER getVehicleID output some text what vehID is (the same way with outputChatBox or any other output functions). Hope you will try to debug it yourself. 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