Jump to content

kieran

Members
  • Posts

    367
  • Joined

  • Last visited

Everything posted by kieran

  1. I tried something but it went wrong Server function SpawnTruck(hitElement) if getElementType (hitElement) == "player" then truck = createVehicle (515, 2779.6, -2437.2, 14.7, 0, 0, 90) setVehicleLocked (truck, true) player = hitElement warpPedIntoVehicle (hitElement, truck) end end addEvent( "SpawnTheTrucks", true ) addEventHandler( "SpawnTheTrucks", resourceRoot, SpawnTruck ) function SpawnTrailers() trailer = createVehicle (450, 2789.2, -2437.1, 14.2, 0, 0, 90) end addEvent( "SpawnTheTrailers", true ) addEventHandler( "SpawnTheTrailers", resourceRoot, SpawnTrailers ) Client --// Made by: MoPoMaN --//Tables and other stuff tableLocationsX = {} tableLocationsY = {} tableLocationsZ = {} tableMoney = {} locationCount = 3 --//Location 1 tableLocationsX[1] = 2253.7 tableLocationsY[1] = -84.0 tableLocationsZ[1] = 25.3 tableMoney[1] = 500 --//Location 2 tableLocationsX[2] = 1093.7 tableLocationsY[2] = -931.6 tableLocationsZ[2] = 41.9 tableMoney[2] = 550 --//Location3 tableLocationsX[3] = -47.3 tableLocationsY[3] = -1137.5 tableLocationsZ[3] = 0.07 tableMoney[3] = 500 function startScript () --Marker marker = createMarker (2776.6, -2425.5, 12.6, "cylinder", 1.1, 0, 255, 0) addEventHandler ("onClientMarkerHit", marker, startMission) --Objects and Ped ped = createPed (302, 2776.7, -2428.1, 13.6) tableObj = createObject (2205, 2775.9, -2426.8, 12.6) chairObj = createObject (2309, 2776.7, -2427.4, 12.6) addEventHandler ("onClientPedWasted", getRootElement(), respawnPed) --Blip startBlip = createBlip (2776.9, -2423.9, 12.7, 51) end function startMission (hitElement) if getElementType (hitElement) == "player" then truck = triggerServerEvent ( "SpawnTheTrucks", resourceRoot ) trailer = triggerServerEvent ( "SpawnTrailers", resourceRoot ) randomLoc = math.random (1, locationCount) finish = createMarker (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], "cylinder", 3, 0, 200, 55, 255, hitElement) blip = createBlip (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], 0, 2, 255, 0, 0, 255, 0, 10000, hitElement) --addEventHandlers addEventHandler ("onClientTrailerDetach", getRootElement(), trailerDetach) addEventHandler ("onClientVehicleExit", getRootElement(), vehicleExit) addEventHandler ("onClientMarkerHit", finish, reward) addEventHandler ("onClientPlayerQuit", getRootElement(), onQuit) --other destroyElement (startBlip) outputChatBox ("#ffaa00***#ffffffDrive to the red blip on the map #ffaa00***", 255, 255, 255, true) setElementPosition (marker, -406, -64, 2.4) -- end else return false end end function trailerDetach () if source == trailer then --destroyThings outputChatBox ("#ffffffMission failed, go back for more cargo!", 255, 255, 255, true) destroyElement (trailer) destroyElement (finish) destroyElement (blip) --removeEventHandlers removeEventHandler ("onClientTrailerDetach", getRootElement(), trailerDetach) removeEventHandler ("onClientVehicleExit", getRootElement(), vehicleExit) removeEventHandler ("onClientPlayerQuit", getRootElement(), onQuit) --other startBlip = createBlip (2776.9, -2423.9, 12.7, 51) setElementPosition (marker, 2776.6, -2425.5, 12.6) else return false end end function vehicleExit (leaver) if source == truck and leaver == player then setVehicleLocked (truck, false) outputChatBox ("#ffaa00// #ffffffGo back to the truck in 10 seconds!", 255, 255, 255, true) destroyTimer = setTimer (destroyVehicle, 10000, 1) addEventHandler ("onClientVehicleEnter", getRootElement(), destrTimer) else return false end end function destrTimer (thePlayer) if source == truck and thePlayer == player then local team = getPlayerTeam (thePlayer) if getTeamName (team) == "Freeroam" or getTeamName (team) == "The Police" then return false else killTimer (destroyTimer) removeEventHandler ("onClientVehicleEnter", getRootElement(), destrTimer) setVehicleLocked (truck, true) end else return false end end function destroyVehicle () if destroyTimer then --destroyThings destroyElement (trailer) destroyElement (finish) destroyElement (blip) --removeEventHandlers removeEventHandler ("onClientTrailerDetach", getRootElement(), trailerDetach) removeEventHandler ("onClientVehicleExit", getRootElement(), vehicleExit) removeEventHandler ("onClientVehicleEnter", getRootElement(), destrTimer) removeEventHandler ("onClientPlayerQuit", getRootElement(), onQuit) --other startBlip = createBlip (2776.9, -2423.9, 12.7, 51) setElementPosition (marker, 2776.6, -2425.5, 12.6) else return false end end function onQuit () if source == player then --destroyThings destroyElement (truck) destroyElement (trailer) destroyElement (finish) destroyElement (blip) --removeEventHandlers removeEventHandler ("onClientTrailerDetach", getRootElement(), trailerDetach) removeEventHandler ("onClientVehicleExit", getRootElement(), vehicleExit) removeEventHandler ("onClientPlayerQuit", getRootElement(), onQuit) --other startBlip = createBlip (2776.9, -2423.9, 12.7, 51) setElementPosition (marker, 2776.6, -2425.5, 12.6) end end function reward (hitElement) if hitElement == truck then --other startBlip = createBlip (2776.9, -2423.9, 12.7, 51) outputChatBox ("#ffaa00// #ffffffGood job! You've been rewarded " .. tableMoney[randomLoc] .. "$", 255, 255, 255, true) setElementPosition (marker, 2776.6, -2425.5, 12.6) occupant = getVehicleOccupant (truck, 0) givePlayerMoney (occupant, tableMoney[randomLoc]) --destroyThings destroyElement (trailer) destroyElement (finish) destroyElement (blip) --removeEventHandlers removeEventHandler ("onClientTrailerDetach", getRootElement(), trailerDetach) removeEventHandler ("onClientVehicleExit", getRootElement(), vehicleExit) removeEventHandler ("onClientPlayerQuit", getRootElement(), onQuit) else return false end end function respawnPed () if source == ped then timer = setTimer (pedRespawn, 5000, 1) else return false end end function pedRespawn () killTimer (timer) destroyElement (ped) ped = createPed (302, 2776.7, -2428.1, 13.6) end addEventHandler ("onClientResourceStart", getResourceRootElement(getThisResource()), startScript) Tweaked it a little and added server events, but now it won't spawn vehicle sorry for being so nub only place I used event handlers was on my login panel...
  2. @Ayush Rathore It sort of worked, started mission, spawned truck etc... but doesn't like warpPedIntoVehicle it says it will only work with client created peds and vehicles, is there any other way to warp him into vehicle?
  3. So I found a script on resources for trucker, server side though, and I am trying to tweak it to be client side, code is in spoiler because it kinda "medium sized"... But the problem on my debugscript 3 it says nothing when I hit spawn marker, marker is there, but no vehicle spawns, nothing happens... Any help at all is good had this sitting there for weeks now and kept meaning to make it better :3 All made by NoPoMaN, but as I say, it is server side, so worried there will be loads of problems with markers etc So tryna change to client
  4. kieran

    Help me

    I would ask a CIT staff member (looks like CIT) or post issue on there forum, if all else fails, just reinstall MTA
  5. so how can it already be on a event? The way I understand it is that if you set the camera matrix of a player and put the onPlayerWasted handler on the function your camera will be set to that exact position as it would (in theory) over ride the original respawnPlayer.... Just try it and see what happens, kinda hard with no script or explanation to how you made the script.
  6. shake effect, so you'll be able to set your own camera, make it zoom out, or make it zoom in :3 also if you want no screen at all you can just fadeCamera
  7. Haha, well you're much better than me then still my first month on lua.... Anyways, hope you manage to get your script working, it sounds like it will be awesome finished!
  8. No, SetCameraTarget only sets a target for the camera, SetCameraMatrix will set the position of the camera, this giving the possibility to stop swaying when you die, have a look at this tutorial I found on YouTube, it is for a login panel, but much the same idea, instead just get the players x, y and z when he dies
  9. kieran

    Money

    What are you saying? do you mean like setting on there HUD or using a command to give cash?
  10. Amazingly, I know the functions you are looking for, but not how to make the script haha, so first of all you want getVehiclePanelState as mentioned above, but ALSO, you may want to try getVehicleLightState. I'll explain these a bit further, the panel state one gets doors, bumpers, all the metal on your car basically but the light state will allow you to check if your lights have been broken or if they are working, you then will want to use setVehiclePanelState and setVehicleLightState once you save the information somewhere (xml file or database, account data strings are not recommended) The script you want is a little above my understanding (for now) but the wiki sort of explains it ^.^ hope this helps!
  11. kieran

    Delete LV

    Remember deleting world models (buildings) will leave behind lights at night. Currently I have no idea on how to disable this, I believe there's a chance they're hard coded into it....
  12. This is a resource related question, not scripting.... Basically I messed up my MTA deleting a few things that other maps need, I copied my internal.db and registry.db already (I don't use mysql) if I done a full uninstall and copied the files I have over to the same folder, would my account info still be there? Topic Closed Answer is simple, reinstall MTA without deleting it
  13. Oh thanks! I really gotta start getting used to GUI's they make a server, anyway, thank you for help.
  14. You must have been wrongly informed the text stays the same size and also stays at the same exact location using pixels to calculate it kinda weird, I know it is possible to keep its position as many servers have it down the bottom right... I found out on GUIEditor you can make it snap right, now I just gotta understand exactly how it keeps right. local screenW, screenH = guiGetScreenSize() addEventHandler("onClientRender", root, function() dxDrawText("Test", screenW - 64 - 10, (screenH - 10) / 2, (screenW - 64 - 10) + 64, ( (screenH - 10) / 2) + 10, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) end ) --Amazingly this centers it to right.... WTF does this mean? "screenW - 64 - 10, (screenH - 10) / 2, (screenW - 64 - 10) + 64, ( (screenH - 10) / 2) + 10" So far this is the ONLY WAY it worked, I know nothing about the maths used in lua, to me it looks like it's getting screen width, taking off 64, then 10, then taking away 10 from height then dividing it by 2, this is of course not what it's doing, does anyone understand it? EDIT I somehow magically found out how by messing around with above code, is probably wrong way and looks bad, but it is below... local screenW, screenH = guiGetScreenSize() addEventHandler("onClientRender", root, function() dxDrawText("Test 1.0.0", screenW - 70 - 10, (screenH - 10) / 1.04, (screenW - 64 - 10) + 64, ( (screenH - 10) / 1.04) + 10, tocolor(166, 251, 244, 111), 1.00, "default-bold", "center", "center", false, false, false, false, false) end ) It more or less stays there, just needs Y adjusted same way x has been...
  15. Thanks, but the link explaining it is already there
  16. Problem with the positioning... The above shows the issue, it's resolution is 640 x 480 x 32 The below is what position I am looking for on all resolutions, the spoiler below is 800 x 600 x 32 The red box is drawn in so you know what you are looking at, it is NOT in the code. Here is code local screenW, screenH = guiGetScreenSize() addEventHandler("onClientRender", root, function() dxDrawText("Test 1.0", (screenW * 0.8975) + 1, (screenH * 0.9533) + 1, (screenW * 0.9950) + 1, (screenH * 0.9767) + 1, tocolor(0, 0, 0, 255), 1.00, "default", "left", "top", false, false, false, false, false) dxDrawText("Test 1.0", screenW * 0.8975, screenH * 0.9533, screenW * 0.9950, screenH * 0.9767, tocolor(92, 253, 248, 170), 1.00, "default", "left", "top", false, false, false, false, false) end ) Please help? EDIT In case I haven't been clear in result I am hoping for, I am looking for a way to automatically move text AND resize it to remain in line with "MTA:SA 1.5.4" Do I need to do some more complicated stuff? Can anyone direct me to a page about the maths used? being honest I don't know the name of maths functions used in any language, the only one I excelled in was html and that's what started the love of writing text to do stuff
  17. @Infinity# I tried before, but think was absolute, if I get any problems can you help? You seem like you know what you're talking about And sorry, I forgot that R3mp made GUIEditor even though I use it a lot
  18. Thanks, is this like guieditor? Can I see what the code is
  19. Before anyone says look at wiki... I have, for around 5 hours Anyway... I can not figure out how to set the x and y on dxDrawText to stay in place across all resolutions. function createText ( ) local sx,sy = guiGetScreenSize() local px,py = 1366,768 local x,y = (sx/px), (sy/py) dxDrawText(" Test", x*1140, y*715, x*1351, y*735, tocolor(166, 251, 244, 111), 1.00, "default-bold", "center", "center", false, false, false, false, false) end function HandleTheRendering ( ) addEventHandler ( "onClientPreRender", root, createText ) end addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) Basically I want to position text exactly above MTA:SA in bottom right and auto resize it on all resolutions. What am I doing wrong? Am I multiplying my second x and y wrong or just missing a few things? Why is there even 2 x positions and 2 y positions?
  20. Thank you so much for this tutorial @Hale (and @koragg ) I have been wondering for so long how to scale text for all resolutions using dxDrawText.
  21. @Legend<3 idk a thing about projectiles, I will try make script though.
  22. function shootProjectile() vehicle = getPedOccupiedVehicle(Player) if ( getElementDimension ( vehicle ) == 1 ) then if(vehicle)then x, y, z = getElementPosition(vehicle) createProjectile(vehicle, 19, x, y, z) end end end bindKey("vehicle_fire", "down", shootProjectile) Works now?
×
×
  • Create New...