Jump to content

bovine3dom

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by bovine3dom

  1. Yes, just change the "change camera" button in MTA's control options.
  2. Done in 0.1.2 - if you press change_camera (V by default afaik), you can cycle through views as you would normally (bodged it so that my camera pretends to be another mode). Thanks for the feedback Mr.Hankey: I have looked at that script, but the maths in it is going to take a rainy day for me to work through - so thanks, it is still on my to-do list.
  3. Genuine thanks for that link, I'm sure I'll learn lots from it - you do it very very differently to me. Version 0.0.3 out, fixes a few cockpits and now uses the default binds for look left/right/behind EDIT: 0.0.4 released, adds camera roll (toggleable). EDIT: 0.1.0 released - fixes the bug which stopped it from working well with the race gamemodes. hurrah! EDIT: 0.1.1 released, fixes a few bugs, cockpits and adds some binding options to fix conflicts with aircraft rudders.
  4. It will be my next project, once I've finished this one.
  5. Having had a nosy around the Valhalla server, I have to say I prefer my manually-set cockpits - yours don't work perfectly with every car, and the camera moves around with the neck - so it might not be the right function for me. I love your first person view, though (on foot).
  6. Mr. Hankey - that's a great idea, thanks (if only I'd known about the function before I spent all weekend setting up every cockpit by hand ). I'll have a punt at it tomorrow, when I'm more awake. 0.0.2 released, includes look left/right/behind binds (defaulted to q, e and c).
  7. Changelog: 0.1.2 Huge improvements to bike cockpits and changed the way the cockpit is accessed (now it pretends to just be another camera mode). I've tweaked the way the camera rolls too, now it feels a bit more fluid and natural rather than being solidly fixed. 0.1.1 Fixed a bug where the cockpit camera wasn't disabling in vehicles in which it wasn't enabled; added a new command (aircraftcompat) which allows you to bind the look commands to 'special_control' ones, fixed some cockpits. 0.1.0 Fixed the bug where cockpits didn't change when your vehicle did - i.e. the script should now work with the race gamemode! :DD 0.0.4 Added camera roll, fixed a few cockpits. 0.0.3 Changed controls as requested - they now use the default vehicle_look_[left/right/behind] binds. You need to set three controls though, I haven't yet figured out how to do get look left + right to make look behind. Also altered a few cockpits to correct incorrect camera position. 0.0.2 Added look left/right/behind commands bound to q, e, and c respectively. https://community.multitheftauto.com/index.php?p= ... ils&id=844 It should now work with the race gamemodes.
  8. I think I'll skip most of the maths and just use a 'fly on the nose' (i.e. create an invisible object, attach it to the train and have the camera look at that). That way I don't have to worry about the angle of elevation either, and it should be less resource hungry. Btw, the solution to this problem is to use tan(Z) to find the x co-ordinate for -45 Cheers to Doomed_Space_Marine, I didn't realise that the function worked that way. Code I'm using now (for those interested) function trainCam() local x, y, z = getElementPosition(gnat) local cx, cy, cz = getElementPosition(fly) setCameraMatrix(x, y, z, cx, cy, cz) end function trainStart(theVehicle, seat) if ((seat == 0) and (getElementModel(theVehicle) == 449)) then local x, y, z = getElementPosition(getLocalPlayer()) fly = createObject(3803, x, y, z) setElementAlpha(fly, 0) gnat = createObject(3803, x, y, z) setElementAlpha(gnat, 0) attachElements(fly, theVehicle, 0.7, 5, 0.6) attachElements(gnat, theVehicle, 0.7, 3.5, 0.6) addEventHandler("onClientPreRender", getRootElement(), trainCam) else end end addEventHandler("onClientPlayerVehicleEnter", getLocalPlayer(), trainStart) function trainStop(theVehicle, seat) if ((seat == 0) and (getElementModel(theVehicle) == 449)) then removeEventHandler("onClientPreRender", getRootElement(), trainCam) setCameraTarget(getLocalPlayer()) destroyElement(fly) destroyElement(gnat) else end end addEventHandler("onClientPlayerVehicleExit", getLocalPlayer(), trainStop)
  9. I'm trying to create a cockpit camera (like http://www.ps3informer.com/playstation- ... t-view.jpg ) for a tram. Here's the code so far: (This is all clientside btw) function trainCam() local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) local x, y, z = getElementPosition(getLocalPlayer()) local rx, ry, rz = getElementRotation(getLocalPlayer()) local ry = y+1 local rx = x+(math.tan(math.deg(rz))) setCameraMatrix(x, y, z+1, rx, ry, z+1) end function trainStart(theVehicle, seat) if ((seat == 0) and (getElementModel(theVehicle) == 449)) then addEventHandler("onClientRender", getRootElement(), trainCam) else end end addEventHandler("onClientPlayerVehicleEnter", getLocalPlayer(), trainStart) function trainStop(theVehicle, seat) if ((seat == 0) and (getElementModel(theVehicle) == 449)) then removeEventHandler("onClientRender", getRootElement(), trainCam) setCameraTarget(getLocalPlayer()) else end end addEventHandler("onClientPlayerVehicleExit", getLocalPlayer(), trainStop) It kind of works along 0* and 90* lines (although it seems to go in fairly random directions), but when you go around a corner, it spins around crazyily. I can't see why though The logic behind the maths: http://j.imagehost.org/0403/MTA.png Where the point (a,b) is the x and y position of the tram, and (a+tan(Z), b+1) is a second point along the direction of travel. I know I haven't made any allowances for instances where the direction of travel is 90* Any ideas/solutions? Thanks.
  10. Thehookerkiller01: It's possible, but right now I have neither the time nor the ability to do so. LordAzamath: Thanks for the heads up but I had put it there so that people could hopefully learn a bit from my code (otherwise I wouldn't have defined it anywhere as a variable; I would have just put it in as an argument). I might make getNearbyPlayers() Nevermore: is it reproducible? It won't do it for me. I suspect that you have another resource that is stopping the cancelEvent() or that you have edited it by accident.
  11. Basically, it just uses string.find to find stuff within your message. <3 Download: https://community.multitheftauto.com/index.html?p ... ils&id=251 EDIT: 1.2.1 released
  12. Thanks Mr.Hankey, I was wondering why the accounts were dissappearing! Unfortunately, not all is well - on occasion, the stingers decide to sting the person who released them when someone else runs over the stingers - and sometimes the time is set to 0:00 when someone runs over the stingers. Also, the "Stingers Released!" is global i.e. everyone can see it. - Why? -- Stinger Release function releaseStingers ( thePlayer, commandName ) local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) if (theVehicle ~= false) then x,y,z = getElementPosition ( theVehicle ) -- stores the location of the car rx, ry, rz = getVehicleRotation ( theVehicle ) -- stores the rotation of the car setTimer ( delayedStingerCreation, 100, 1, stingdc) -- make a timer using the delay time from above to start the function "delayedStingerCreation" else outputChatBox ( "You fail!" , source, 255, 0, 0 ) end end addCommandHandler ( "sting", releaseStingers ) function delayedStingerCreation ( source, stingdc) local z = z - 0.55 stingerCol = createColCuboid ( x, y, z, 1000.0, 1000.0, 500.0 ) addEventHandler ( "onColShapeHit", stingerCol, stingerHit ) -- When you hit a collision box, perform function "stingerHit" local rz = rz + 90 stingerObj = createObject( 2899, x, y, z, 0, 0, rz ) -- create the stinger (2892) outputChatBox ( "Stingers released!" , source, 0, 255, 0 ) setTimer (delayedStingerDeletion, 5000.0, 1, stingdd) end function delayedStingerDeletion (source, stingdd) destroyElement( stingerCol ) destroyElement( stingerObj ) end -- Stinger Collision! function stingerHit ( thePlayer, st ) -- If in a vehicle, make it spin out of control and pop all the tyres local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) local r1 = randInt ( 1, 2 ) local r2 = randInt ( 1, 2 ) local r3 = randInt ( 1, 1 ) local r4 = randInt ( 1, 1 ) setVehicleWheelStates ( theVehicle, r1, r2, r3, r4 ) local velocityx,velocityy,velocityz = getElementVelocity ( thePlayer ) local speed = (velocityx^2 + velocityy^2 + velocityz^2)^(0.5) local turnvelocity = speed/5 local spin = randInt ( 0, 1 ) if (spin == 1 ) then setVehicleTurnVelocity ( theVehicle, 0, 0, turnvelocity ) else local turnvelocity = turnvelocity * -1 setVehicleTurnVelocity ( theVehicle, 0, 0, turnvelocity ) end end
  13. I'm getting there! Now I only get ERROR: Bad argument @ 'spawnPlayer' - line 13 EDIT: All working! thanks for all your help
  14. Thanks! I'm using DP2.3, my stingers work great now - and ranged chat doesn't set them off However, although your suggestion for 3. was definitely part of the problem - /setjob now works - it still doesn't make me a cop when I log in and for some reason, my accounts.xml gets wiped every now and then. EDIT: I get bad "client" pointer @ line 4 and bad "element" pointer @ line 5
  15. No. 1; customised handling for a high-speed pursuit police car function resourceStarted() handling = createHandling() -- create a new handling element handlingSetEngineAcceleration(handling, 40)-- change its acceleration property handlingSetABS(handling, 1) handlingSetMass(handling, 1000) handlingSetTractionMultiplier(handling, 1.0) handlingSetTractionBias(handling, 0.6) handlingSetDriveType(handling, awd) addDefaultHandling(597, handling) -- attach it to the SFPD ID end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resourceStarted) Gives me the error "attempt to call global 'createHandling' ( a nil value ). I don't quite understand why this doesn't work, I pretty much copy-pasted it from the wiki . No. 2; a stinger that you can release from a car (I'll make it police cars only later) function releaseStingers ( thePlayer, commandName ) local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) if (theVehicle ~= false) then x,y,z = getElementPosition ( theVehicle ) -- stores the location of the car rx, ry, rz = getVehicleRotation ( theVehicle ) -- stores the rotation of the car setTimer ( delayedStingerCreation, 100, 1, stingdc) -- make a timer using the delay time from above to start the function "delayedStingerCreation" else outputChatBox ( "You fail!" , source, 255, 0, 0 ) end end addCommandHandler ( "sting", releaseStingers ) function delayedStingerCreation ( source, stingdc) local z = z - 0.55 stingerCol = createColCuboid ( x, y, z, 1000.0, 1000.0, 500.0 ) local rz = rz + 90 stingerObj = createObject( 2899, x, y, z, 0, 0, rz ) -- create the stinger (2892) outputChatBox ( "Stingers released!" , source, 0, 255, 0 ) setTimer (delayedStingerDeletion, 5000.0, 1, stingdd) end function delayedStingerDeletion (source, stingdd) destroyElement( stingerCol ) destroyElement( stingerObj ) end -- Stinger Collision! function stingerHit ( thePlayer, st ) -- If in a vehicle, make it spin out of control and pop all the tyres local theVehicle = getPlayerOccupiedVehicle ( thePlayer ) local r1 = randInt ( 1, 2 ) local r2 = randInt ( 1, 2 ) local r3 = randInt ( 1, 1 ) local r4 = randInt ( 1, 1 ) setVehicleWheelStates ( theVehicle, r1, r2, r3, r4 ) local velocityx,velocityy,velocityz = getElementVelocity ( thePlayer ) local speed = (velocityx^2 + velocityy^2 + velocityz^2)^(0.5) local turnvelocity = speed/5 setVehicleTurnVelocity ( theVehicle, 0, 0, turnvelocity ) end addEventHandler ( "onColShapeHit", getRootElement(), stingerHit ) -- When you hit a collision box, perform function "stingerHit" Whilst this works, what can I use other than getRootElement() because if I change it to stingerCol, nothing happens - and getRootElement() is highly impractical, because all collision boxes trigger the stinger collision. No 3; A police job -- Logging into an account function onLogIn() local playerAccount = getClientAccount ( source ) local x, y, z = getElementPosition ( source ) if ( playerAccount ) then local playerMoney = getAccountData ( playerAccount, "rp.money" ) if ( playerMoney ) then setPlayerMoney ( source, playerMoney ) end local job = getAccountData ( playerAccount, "job" ) if ( job == "cop" ) then spawnPlayer ( thePlayer, x, y, z, 90, randInt (280, 284), 0, 0, 0, Police ) giveWeapon ( source, 22, 400 ) -- Gives them a pistol with 400 ammo giveWeapon ( source, 17, 5 ) -- Gives them 5 teargas 'nades giveWeapon ( source, 33, 40 ) -- Gives the a rifle with 40 ammo end end end addEventHandler ( "onClientLogin", getRootElement(), onLogIn ) -- stop noobs stealing cop cars function policeLock ( player, seat, jacked ) --when a player enters a vehicle local policeVehicles = { [598]=true,[596]=true,[597]=true,[599]=true } local playerAccount = getClientAccount ( source ) local job = getAccountData ( playerAccount, job ) if ( policeVehicles[getVehicleID(source)] ) and ( job ~= cop ) then -- if the car is a police car, and the player isn't a cop, don't let 'em in. cancelEvent() outputChatBox ( "Only policemen can enter police cars!", player ) --and tell the player why end end addEventHandler ( "onVehicleStartEnter", getRootElement(), policeLock ) function setJob ( thePlayer, commandName, targetPlayerName, job) local playerAccount = getClientAccount ( targetPlayerName ) if ( playerAccount ) then setAccountData (playerAccount, "job", job) end end addCommandHandler( "setjob", setJob) The /setjob [playername] [job] command doesn't work, and even if I go into the account data and set it through there, when I log in, my skin doesn't change and I don't get any guns - and I still can't enter cop cars. Thanks in advance and I apologise for my indoubtedly buggy and poorly written code, but you must forgive me; I only started coding on Saturday. I'm using DP 2.3, couldn't figure out how to get nightly builds to work.
  16. Aww, shame Can't wait for it to be fixed
  17. After using the trusty search function, I've found only one ancient post asking whether it is possible to modify the handling of vehicles, en masse, with a custom handling.cfg. I ask because I should like to create a script which uses 6mik's excellent handling mod ( http://www.gtaforums.com/index.php?show ... &hl=_6mik_ ) - and I don't fancy the prospect of babyfeeding it to the script with http://development.mtasa.com/index.php?title=CreateHandling as it would take me aeons and roughly 5,400 lines of code(( ~25 handling attributes + 5 mandatory lines per vehicle) * ~180 vehicles). Thanks in advance! P.S. If this is possible, could also be part of a good cheat-prevention (not anti-cheat - that merely detects and kicks/bans whereas this would rectify the problem) system - you'd be able to force the players to use vanilla handling.cfg's
×
×
  • Create New...