Jump to content

Bierbuikje

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by Bierbuikje

  1. Make another variable that checks if it already added a lap and create a greater radius it has to leave so it goes back to the beginning situation. I made some alterations: local sx,sy = guiGetScreenSize() fontLCD22 = dxCreateFont("lcd.ttf", 22) local lap = 1 local x, y, z = false local a, b, c = false local dist = false local newLap = false function updateDisplay() a, b, c = getElementPosition(localPlayer) if x and y and z then dist = getDistanceBetweenPoints3D(x, y, z, a, b, c) end if getElementData(localPlayer, "race.checkpoint") == nil then return end if getElementData(localPlayer, "race.checkpoint") >= 4 then if dist and dist < 40 then if newLap == false then setElementData(localPlayer, "lap", lap+1) lap = lap+1 newLap = true end elseif dist and dist > 50 then if newLap then newLap = false end end end local target = localPlayer if getElementData(localPlayer, "race.spectating") then target = getVehicleOccupant(getCameraTarget(localPlayer), 0) end dxDrawText("Lap: "..tostring(getElementData(target, "lap")), sx - 90, sy- 155, 40, 30, tocolor(255, 255, 255, 255), 0.6, fontLCD22, "left", "top", false, false, false) end addEventHandler("onClientRender", getRootElement(), updateDisplay) addEvent("onClientMapStarting", true) function onMapStart() if getElementData(localPlayer, "lap") ~= 1 then setElementData(localPlayer, "lap", 1) end x, y, z = getElementPosition(localPlayer) end addEventHandler("onClientMapStarting", root, onMapStart) function onClientResStart() if getElementData(localPlayer, "lap") ~= lap then setElementData(localPlayer, "lap", lap) end end addEventHandler("onClientResourceStart", resourceRoot, onClientResStart) This way it only adds once and only triggers again if the player leaves the radius of 50 and goes back to the radius of 40 around the start/finish.
  2. Thanks to both of you! I needed both adjustments to make the script working.
  3. Hello, recently I've picked up MTA map editing again with the lua scripting that comes with it. Right now I'm creating a race and in this race I want to teleport the player to a location as soon as it hits a previously created marker. For simplification and testing purposes I changed it so that the player will teleport when it hits any marker on the map. But when testing the map it doesn't work. When I enter a marker it doesn't teleport to the specified location. I tried various, for example changing the 'player' variable to other names, but I can't get it to work. I suppose I have missed something obvious. This is the code: function resourceStart() nep1 = createMarker(1450, 1250, 10, "checkpoint", 10, 0, 0, 255, 255) nep2 = createMarker(1450, 1450, 10, "checkpoint", 10, 0, 0, 255, 255) end function MarkerHit() setElementPosition(player, 1500, 1250, 10) end addEventHandler("onClientMarkerHit",getRootElement(),MarkerHit) addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),resourceStart) Does anyone know what I have missed? Thanks in advance! Bierbuikje
  4. Thanks both! And imagine the following situation. At day 1 someone enters the server with the name Sam. He registers and leaves. At day 2 another person enters the server, also with the same name Sam and he registers too. How to prevent that the account of Day 1 Sam will be overwritten? I wan't to tell Day 2 Sam that his name is already registered and it would be nice to rename himself.
  5. Is it possible to check if a player is logged in on his account? And if it is, how? Thanks!
  6. Hello all, I have a server and the errors keep coming with my new script. Right now I try a script where it should fire a heat seeking rocket at you in a 50.0 sphere from 354.43, 2028.49, 25.4141 if you are 30.0 in z-coords. When that is true it should fire a heat-seeking rocket on you (like happens in single player if you are flying above area 69). Right now I have a script. I made a colSphere with a radius of 50.0, I check if the player is in the colSpher. If it is true it should throw a heat seeking rocket at the player. Sad enough it doesn't work. The isn't created a projectile (at least I didn't regocnize it), and if it did wasn't fired on the player's vehicle (an airplane or helicopter in most cases). Does anyone know what the problem is in this script? The whole script is client-sided. function join() local Rzone1 = createColSphere(354.43, 2028.49, 22.4141, 50.0) end addEventHandler( "onClientResourceStart", getRootElement( ), join) function boem() local target = getPedOccupiedVehicle(player) local bom = createProjectile(getLocalPlayer(), 20, 354.43, 2028.49, 25.4141, 1.0, target) end function boemRadius(player, a) local x,y,z = getElementPosition(player) if (z >= 30) then if (boem_first) then setTimer(boem, 3000, 1) else local target = getPedOccupiedVehicle(player) local bom = createProjectile(player, 20, 354.43, 2028.49, 25.4141, 1.0, target, 0, 0, 0, 0, 0, 0) local boem_first = 1 end end end addEventHandler("onColShapeHit", Rzone1, boemRadius)
  7. Thank you! =D But why did you use 'getAllVehicles'? According to the mta wiki that function doesn't exist. And what does the part 'for _,vehicle in pairs ( getAllVehicles ( ) )' mean?
  8. Hello, I have some questions about freezing a vehicle. I make a server and with a .map file I create vehicles. What I want is when the server starts all the vehicles should be frozen immediately. But how to do this? I know I can get the vehicle by the following line: local vehicle = getElementByID("vehicle") And I know I can freeze the vehicle with the following line: setVehicleFrozen(vehicle,true) But how to run this immediately when the server starts? Thanks a lot! Bierbuikje
×
×
  • Create New...