Jump to content

tma

Members
  • Posts

    173
  • Joined

  • Last visited

Everything posted by tma

  1. I played with the cameras more after that but could never: (a) Get rid of twitchy looking movement when speccing yourself in a car. It all works fine (it was based on what I posted in the other thread) but is never smooth. Maybe onClientPreRender sorts this. (b) Stop it falling through the floor at distance when you move the camera too far away. I've sorted this by setting the players velocity to 0,0,0 while spectating - unless there's a better way ? There are certain things you can do with the camera on the same frame - as 50p mentioned setting the position and look-at direction is OK, but other combinations aren't. I altered your code to include timers so that mode changes and movement/target weren't on the same frame. If you try to go fixed mode and move/lookat something in the same frame it seems to fail and look in the wrong direction. You could try over-riding the camera while using the train - haven't tried - but did try when you're deading with the floating camera - that seemed to keep resetting.
  2. There's a couple of missing "," in that code. Try: addEventHandler( "onVehicleExplode", getRootElement( ), function( ) local parent = getElementParent( source ) if getElementType( parent ) == "map" then local parentRes = getElementParent( parent ) if parentRes == getThisResource( ) then setTimer( respawnVehicle, 5000, 1, source ) else setTimer( destroyElement, 5000, 1, source ) end else setTimer( destroyElement, 5000, 1, source ) end end )
  3. Well every time a vehicle respawns you're killing every timer you've created in the last second, regardless of what they're connected with. So you could stop timers that weren't meant to destroy the vehicle for one. So you when you create your timer you need to save this and associate it with the vehicle it's designed to destroy - so you can handle only it's timer when it respawns.
  4. randInt() is server only. Try this instead: local rand = math.random(1,5)
  5. You can test it with any vehicle - controlled or not. I just added getPlayerOccupiedVehicle to your code because you weren't calling isVehicleOnGround() with a vehicle element. It's simple enough to apply this check to any/all vehicles e.g. (untested) for _,v in pairs(getElementsByType("vehicle")) do outputChatBox(tostring(isVehicleOnGround(v))) end AFAIK, it won't work with non-vehicles so you'll have to do your cluster bomb another way. There is a cluster bomb resource (or similar) so have a look how they've done it.
  6. Try: function Test(thePlayer) v=isVehicleOnGround(getPlayerOccupiedVehicle(thePlayer)) outputChatBox(tostring(v)) end addCommandHandler("g", Test) Are you running this as client code ? If so it would be more like: function Test() v=isVehicleOnGround(getPlayerOccupiedVehicle(getLocalPlayer())) outputChatBox(tostring(v)) end
  7. I'd do something like this for the client (untested / replaces all your client code): function SAMfire() setTimer(SAMfireMissile,500,5) -- Call to fire a rocket 5 times with 500 ms between each end function SAMfireMissile ( player ) local px,py,pz = getElementPosition ( getLocalPlayer() ) local glow1 = createMarker ( 353, 2030, 30, "corona", 5, 255, 0, 0, 150 ) local shot1 = createObject ( 3106, 353, 2030, 30 ) attachElementToElement ( glow1, shot1, 0, 0, 0 ) setTimer ( moveObject, 50, 1, shot1, 500, px, py, pz ) setTimer ( destroyElement, 570, 1, shot1 ) setTimer ( destroyElement, 570, 1, glow1 ) setTimer ( createExplosion, 550, 1, px, py, pz, 0 ) end addEvent ( "onarea69samfire", true ) addEventHandler ( "onarea69samfire", getLocalPlayer(), SAMfire)
  8. I think it's the way you're declaring the array indicies. Try it like this instead: local classes = { civilians = { title = 'Street people', team = 'civilian', message = 'Living people on the streets,\nThey do just normal!' }, ... You can then access like: local p = classes["civilians"] OR local p = classes.civilians
  9. He basically means that by using an interior, you won't have (m)any GTA specific objects so you can construct objects freely. Similar to just building a new map of objects out in the sea areas. You're not gonna be able to do your original aim - manipulation of real world GTA objects.
  10. No problem. I've spent a while trying various camera calls (server/client side, on timers etc.) and the above sequence was the one I found most reliable. The camera dropping through the world is a distance-based issue - changing the camera mode from/to fixed when the camera position is far away from the player. I worked out a fixed for that but it involves move the players position as well as the camera. In your stunt mode you should be able to drop the time from 15 seconds down to whatever you won't so this shouldn't happen too often.
  11. This was as close as I could get: function camTrack() setCameraLookAt(getElementPosition(getLocalPlayer())) end function camTrackOn() addEventHandler("onClientRender",getLocalPlayer(),camTrack) end function camTrackOff() removeEventHandler("onClientRender",getLocalPlayer(),camTrack) end function camTrackStart(duration) local x,y,z = getElementPosition(getLocalPlayer()) toggleCameraFixedMode(false) toggleCameraFixedMode(true) setTimer(setCameraPosition,50,1,x + 30,y + 30,z + 10) setTimer(camTrackOn,100,1) setTimer(camTrackOff,duration - 100,1) setTimer(toggleCameraFixedMode,duration,1,false) end addCommandHandler("camtest", function() camTrackStart(15000) end ) I've just butchered your code to make this but it does put the camera away from the player and then specs them for 15 seconds (use /camtest). It's a little jerky (in a fast vehicle) but maybe that will be helped in DP3 with onClientPreRender or the new camera functions.
  12. Something like this would double the damage on the rhino (untested): addEventHandler("onVehicleDamage",getRootElement(), function(loss) if getVehicleID(source) == 432 then setElementHealth(source,getElementHealth(source) - loss) end end )
  13. I'm confused. Your're right about it doesn't work - but it does sometimes ? I put this in server-side: addEventHandler("onVehicleDamage",getRootElement(), function(loss) setElementHealth(source,0) end ) and I can punch a tank to make it instantly burn. I can hit it with a rocket but only at close quarter; I can't hit it with an AK47 at all ? Is this event bugged or does it only consistently work for car collisions ? (i.e. not being shot at). Or is this problematic because firing is essentially client-side and this event is server-side ?
  14. Can't you just trap the onVehicleDamage() event and use the 'loss' parameter passed in to further increase the damage by using setElementHealth() ?
  15. A couple of lines from my code: local tx = x - math.sin(math.rad(rz)) * radius local ty = y + math.cos(math.rad(rz)) * radius Where rz is your rotation in degrees e.g. from getPlayerRotation()
  16. tma

    Moving a gate

    I don't know what else is right/wrong but you've also getting the x,y,z values incorrectly and not actually using them. What you want is something like: . local x, y, z = getElementData( v, "posX" ), getElementData( v, "posY" ), getElementData( v, "posZ" ) local gateObject = createObject( 975, x,y,z) .
  17. tma

    Reading XML

    To count child nodes use xmlFindSubNode() with an increasing index. Once this function returns false, you've found all your subnodes i.e. start with index 0 and keep calling this function with 0,1,2,3 ... etc. until it fails.
  18. Try: function thrillcam ( theplayer, command ) local player = getLocalPlayer () local x,y,z = getElementPosition ( player ) setCameraMode ( player, "fixed" ) setTimer ( setCameraPosition, 100, 1, player, x + 10, y + 10, z + 10 ) setTimer ( setCameraLookAt, 100, 1, player, x, y, z ) setTimer ( setCameraMode, 3000, 1, player, "player" ) end Edit: setCameraMode() is server-only. You'll need toggleCameraFixedMode() maybe ? (I haven't done this kind of thing).
  19. There's no functions to animate the postion/angle of the camera so you need to do it yourself. For this to be smooth it needs to be done each frame - hence it needs to be client side. If the server was to issue client camera position/angle updates over time, they wouldn't be smooth (due to lag). So you need to write something that's hooked to the client renderer or a short period repeating timer - although I think the former would be better.
  20. tma

    Moving a gate

    Well you need to specify which objects are gates in some way. You might be best putting you own element type into a MAP file and creating your gates on loading it - then you could just do allObjects = getElementsByType ( "gate" ). If not, you could check for a certain model maybe and only move objects with the correct one - see getObjectModel().
  21. It's as this says: [15:01:19] SCRIPT ERROR: ...de programa/MTA San Andreas/server/mods/deathmatch/resources/cdm/cdm.lua:236: 'then' expected near 'destroyBlipsAttachedTo' Your previous line is an unclosed conditional block - there's no "then" or "end" connected with: if getElementData( killer, "score", getElementData( source, "score" ) == 2 ) You've also got socre[killer] when it should be score[killer].
  22. This: addCommandHandler("test", function(player,cmd) outputChatBox("I AM A FUNCTION") end ) addCommandHandler("test", function(player,cmd) outputChatBox("SO AM I") end ) outputs both lines to the chatbox - so yes, you can (assuming there's no difference in having the two test calls in the same resource).
  23. tma

    setting gravity

    Sorry I mis-read the doc for setGravity() - it doesn't affect players/vehicles. You'd need to do something like: function setGravityForPlayer(player) setPlayerGravity(player,0.0035) end addCommandHandler("setgravity", function(player,cmd) for _,player in pairs(getElementsByType("player")) do setGravityForPlayer(player) end end ) addEventHandler('onPlayerSpawn',getRootElement(), function() setTimer(setGravityForPlayer,1000,1,source) end ) The command now loops though the players and sets their gravity. Then each time a player spawns the same setting is made - this allows people who join after the command has been issued, to have their gravity set the same.
  24. tma

    setting gravity

    Just do this if you only want a specific level: setGravity(0.0035) The "level" parameter into your function is then redundant and can be removed.
  25. Save it to XML or SQL ?
×
×
  • Create New...