Jump to content

Bartje

Members
  • Posts

    17
  • Joined

  • Last visited

Bartje's Achievements

Square

Square (6/54)

3

Reputation

  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. 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?
  5. 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.
  6. 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.
  7. 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), cty + (y - cty) , ctz + (z - ctz) ) So the above code makes the object spawn directly at the players' position. How can I give a little offset, let's say 1 meter towards the direction of where I am looking at?
  8. 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?
  9. 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!
  10. 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!
  11. 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, markerTriggered ) end addCommandHandler ( "create", createTheMarker ) function markerTriggered ( ) outputServerLog ( 'hit' ) end Thanks!
  12. 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.
  13. 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("updateMoney",true) addEventHandler("updateMoney",root ,updateMoneyHandler) Especially this part is what I am worried about. the 'root' seems to overkill to me, but I still can't find another way to get this to work. client.Lua function updateMoneyClientHandler(gold) setPlayerMoney(tonumber(gold)) end addEvent("updateMoneyClient",true) addEventHandler("updateMoneyClient", localPlayer, updateMoneyClientHandler)
×
×
  • Create New...