Jump to content

Bartje

Members
  • Content Count

    17
  • Joined

  • Last visited

Everything posted by Bartje

  1. I tried the bone position but it wasn't accurate enough. I used the player camera rotation and player rotation to get the angle. Thanks.
  2. Bartje

    bindTheKeys

    I am not entirely sure, but it seems like you are trying to bind the keys to the server instead of the player. Maybe you are looking for another eventHandler. What about: addEventHandler ( "onPlayerJoin", getRootElement(), bindTheKeys )
  3. Hi, Is it possible to check the aiming status of a player? When you have a weapon like a 'tec-9' and you aim backwards, you will lose your aimcontrol and your player just aims up. Is it possible to check if the player is in this upwards aiming state? Take a look the image below to see what I mean. The second image is the state that I want to check. Thanks!
  4. Lol, this is it! Thank you once again.
  5. Not exactly sure what your question is. But I do believe this topic could help you out: Check out 'myonlake's' reply on it. He draws a colshape on the players position and warps all vehicle within that range to his location. You could use this code as well but instead of warping the vehicles, you could do other things with them like opening or closing the doors. Is this what you were looking for?
  6. Sure. The current code looks like this now: local x, y, z = getElementPosition(player) local direction = Vector3(ctx - csx, cty - csy, ctz - csz); direction:normalize(); local start_x, start_y, start_z = interpolate_position( csx, csy, csz, direction, 10 ); local object = createObject ( 1600, start_x, start_y, start_z) So the problem that I have now is that '10' should be relative instead of a static number. I played around with some calculations to get it, but I can't seem to figure it out.
  7. I think it's a bit more complicated. The part with the start distance actually does half the trick in my situation. Based on the zoom level which you can toggle with 'V', the position has to be set. So using a static number will give different offsets from the player when you use different zoom levels. As you can see in the picture below. Both fish are at a different offset from the player because they were spawned with different camera views. That is the problem I am running into at the moment.
  8. Hi again. So I wanted to tweak the part a little. The moving part is working great. The object is moving into the direction where my camera is looking at. However, I want to create the object first just in front of the player (where the camera is looking at). I came as far as getting the object right on top of the player. but it should have some distance. Mathematics is not my strongest skill. What I've got right now, is the following: local x, y, z = getElementPosition(player) local csx, csy, csz, ctx, cty, ctz = getCameraMatrix(); local object = createObject ( 1600, ctx + (x - ctx),
  9. Exactly what I wanted to hear! Thanks!
  10. Hi again! Thank you so much. I used some of this to make my part work. So that's awesome. Another quick question that you may have the answer to: So I am making this 'projectile' kind of thing. When it hits the player, I reduce the target's health and eventually kill it. I am firing the setElementHealth on the serverside as I thought this would be more 'secure'. I do believe that client side would be more efficient. With my background of webdeveloping, I would still handle this on the server-side to prevent hackers or bug-abusers. What are your thoughts on this?
  11. Hi, So I think I have kind of a difficult one here. Is it possible to move an object towards the players camera look at? I am creating the object in front of the player and I then want to move it in the camera direction with a certain speed (not a destination). Actually just like projectiles work, but then for objects. I have a feeling that the 'moveObject' function is not going to work here. Any ideas or examples on how to do this? Thanks!
  12. Hi! Oh my. This entire code was inside a client script, so it wouldn't have worked either way! It is obvious now. Didn't know about this. I thought the server console was showing all errors. So I can start this debugging by typing for example: 'debugscript 3' in the in-game console, correct? Thanks for making clear that I was mixing up client and server functionality!
  13. Hi, So I am trying to do something simple again. In my experience with other coding languages, this should work. However, here it does not. I am creating a marker near my position when entering a command. At that moment I want to bind a new hit event that triggers a function. The function does not trigger for some reason. Is there something I am missing here? function createTheMarker ( ) local x, y, z = getElementPosition(localPlayer) local theMarker = createMarker ( x, y+5, z, "cylinder", 1.5, 255, 255, 0, 170 ) addEventHandler( "onMarkerHit", theMarker, markerTri
  14. Hehehe this is, definitely not final. Still learning all the Lua basics so I've been playing around to get things to work. Thanks for your help. Everything seems clear to me now.
  15. Alright. So I've got it to work and tested it on two clients at the same time. Works fine. But I still wonder if there is any way to improve this. My currently working code is as followed: server-1.Lua triggerEvent ("updateMoney", client, token) server-2.Lua function updateMoneyHandler(token) local query = exports.mysql:_Query("select gold from accounts where token = ?", token) local gold = 0 for rid, row in ipairs (fromJSON(toJSON(query))) do gold = row['gold'] end triggerClientEvent ("updateMoneyClient", source, gold) end addEvent("updat
  16. Thanks! I used to play MTA way back. I have a full time job as a front-end web developer and saw this as a nice opportunity to play around. Setting the playermoney works now with your solution, thanks for that. I also just found out there is a server-side setPlayerMoney function as well. About the player element. I changed my first trigger to: triggerEvent ("updateMoney", client) In the following code, what would root be in this case? function updateMoneyHandler(token) triggerClientEvent ("updateMoneyClient", source, 1000) end addEvent("updateMoney",true) addEventHa
  17. Hi all, Just started Lua scripting and I am already running into something I do not quite understand. I am trying to set the player's money after logging in. I am not getting any warnings or errors, but the players' money does not get updated for some reason. This is what I tried: On a successful login I trigger an event which I have in another server file: triggerEvent ("updateMoney", root) In my other server file I have the function: function updateMoneyHandler(token) triggerClientEvent ("updateMoneyClient", source, 1000) end addEvent("updateMoney",true) addEventH
×
×
  • Create New...