manuelhimmler Posted December 16, 2008 Share Posted December 16, 2008 I have opened a posting, where I will put all my questions, because I won't create for every question a posting. I wanted to create a script, when I press K the vehicle should lock, when the player is in a vehicle and write in lockcar[player] the vehicleid (lockcar[player]=vehicle), otherwise the script should look at this variable, if it contains anything (a vehicleid), this vehicle shoul open. My script: http://pastebin.com/m22dfc61e Thanks for answers! Link to comment
robhol Posted December 17, 2008 Share Posted December 17, 2008 Make a function named vehicleLockHandler(source) or something. In it, use getPlayerOccupiedVehicle(source) (source is the player) to get the player.then do something like setVehicleLocked(car, not isVehicleLocked(car)) inside the function. Then use bindKey to bind the function to the K. Link to comment
50p Posted December 17, 2008 Share Posted December 17, 2008 Make a function named vehicleLockHandler(source) or something. In it, use getPlayerOccupiedVehicle(source) (source is the player) to get the player.then do something like setVehicleLocked(car, not isVehicleLocked(car)) inside the function.Then use bindKey to bind the function to the K. Do not use source as name of parameter, ever! Use player, vehicle or something else instead. How do you know what is source? I've explained it somewhere on the forum the other day. Link to comment
manuelhimmler Posted December 17, 2008 Author Share Posted December 17, 2008 (edited) @robhol: Look at my code, I've made a function (not your name,but this has no preference), the command getPlayerOccupiedVehicle in my function makes an error and this command is for get the vehicle not the player. @50p: you can look at wiki and look at addeventhandler and then you have to look at onPlayerDead or something (the event) and there you find what source is. bindkey..source is ever the player. Where I can look, when I want to know infos about a command when the wiki is totally empty,like now. Edited December 17, 2008 by Guest Link to comment
Gamesnert Posted December 17, 2008 Share Posted December 17, 2008 @50p: you can look at wiki and look at addeventhandler and then you have to look at onPlayerDead or something (the event) and there you find what source is. bindkey..source is ever the player. He means that you should only use it in the case of an event, but you should never DEFINE it yourself. So nothing like: function blah(source....) source=... (any other possibilities?) It's used in addEventHandler because you will get the element that triggered the event. But except for that, it isn't smart to use source in functions. 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