Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. Castillo

    Radar

    You can't change it, you must make a new one.
  2. That script will create the GUI everytime you hit the marker, so you should destroy these GUI elements once you click "Exit".
  3. It's really easy to add new hospitals, all you have to do is edit the "hospitals" table: local hospitals = { { -2654.5205078125 , 638.2412109375 , 14.453125, -2584.6865234375 , 568.95703125 , 40.101623535156,-2654.5205078125 , 638.2412109375 , 14.453125 }, -- SF { 1607.1494140625 , 1819.6416015625 , 10.828001022339, 1581.2802734375 , 1853.708984375 , 30.209064483643,1607.1494140625 , 1819.6416015625 , 10.828001022339 }, -- LV { 1177.5682373047, -1323.2587890625, 14.077121734619, 1208.8115234375 , -1287.755859375 , 38.246742248535 ,1177.5682373047, -1323.2587890625, 14.077121734619, }, -- LS { X, Y, Z, CameraX, CameraY, CameraZ, CameraLookX, CameraLookY, CameraLookZ }, } Edit: Because it also contains the camera position/look at.
  4. local hospitals = { { -2654.5205078125 , 638.2412109375 , 14.453125, -2584.6865234375 , 568.95703125 , 40.101623535156,-2654.5205078125 , 638.2412109375 , 14.453125 }, -- SF { 1607.1494140625 , 1819.6416015625 , 10.828001022339, 1581.2802734375 , 1853.708984375 , 30.209064483643,1607.1494140625 , 1819.6416015625 , 10.828001022339 }, -- LV { 1177.5682373047, -1323.2587890625, 14.077121734619, 1208.8115234375 , -1287.755859375 , 38.246742248535 ,1177.5682373047, -1323.2587890625, 14.077121734619, }, -- LS } for index = 1, #hospitals do createBlip ( hospitals [ index ] [ 1 ], hospitals [ index ] [ 2 ], hospitals [ index ] [ 3 ], 22, root ) end function getNearestHospital ( x, y ) local temp = { } -- Define a table to store our data. for index = 1, #hospitals do -- Loop from 1 to the total items in "hospitals" table. local dist = getDistanceBetweenPoints2D ( x, y, hospitals [ index ] [ 1 ], hospitals [ index ] [ 2 ] ) -- Get the distance between the hospital coordinates and the given coordinates. table.insert ( temp, { index = index, dist = dist } ) -- Insert it into our "temp" table. end table.sort ( -- Sort the "temp" table by lowest distance. temp, function ( a, b ) return ( ( a.dist or 0 ) < ( b.dist or 0 ) ) end ) return unpack ( hospitals [ temp [ 1 ].index ] ) -- Return coordinates from the nearest hospital. end addEventHandler ( "onPlayerWasted", root, function ( ) local x, y, z = getElementPosition ( source ) local hx, hy, hz, cx, cy, cz, clx, cly, clz = getNearestHospital ( x, y ) if ( hx and hy and hz ) then setTimer ( spawnPlayer, 15000, 1, source, hx, hy, hz ) setTimer ( setCameraMatrix, 5000, 1, source, cx, cy, cz, clx, cly, clz, 0, 70 ) end end ) addEventHandler ( "onPlayerWasted", root, function ( ) setTimer ( setCameraTarget, 15000,1, source, source ) end )
  5. There's no need to leave that output, it was just to see if it was being triggered or not.
  6. Even though someone else posted just before I was about to, I'll leave the code I had written which has comments so you know what each line does. local hospitals = { { -2654.5205078125 , 638.2412109375 , 14.453125 }, -- SF { 1607.1494140625 , 1819.6416015625 , 10.828001022339 }, -- LV { 1177.5682373047, -1323.2587890625, 14.077121734619 }, -- LS } function getNearestHospital ( x, y ) local temp = { } -- Define a table to store our data. for index = 1, #hospitals do -- Loop from 1 to the total items in "hospitals" table. local dist = getDistanceBetweenPoints2D ( x, y, hospitals [ index ] [ 1 ], hospitals [ index ] [ 2 ] ) -- Get the distance between the hospital coordinates and the given coordinates. table.insert ( temp, { index = index, dist = dist } ) -- Insert it into our "temp" table. end table.sort ( -- Sort the "temp" table by lowest distance. temp, function ( a, b ) return ( ( a.dist or 0 ) < ( b.dist or 0 ) ) end ) return unpack ( hospitals [ temp [ 1 ].index ] ) -- Return the X, Y and Z from the nearest hospital. end
  7. local cooldown = 5 -- the amount of time after the attack combo resets if no damage is detected anymore local timers = { } addEventHandler ( "onPlayerDamage", root, function ( attacker, weapon ) if ( isElement ( attacker ) and getElementType ( attacker ) == "player" ) then if ( getTeamName ( getPlayerTeam ( attacker ) ) == "Police" and weapon == 3 and getPlayerWantedLevel ( source ) >= 1 ) then if ( timers [ source ] ) then resetTimer ( timers [ source ] ) end local times = ( tonumber ( getElementData ( source,"times_attacked" ) ) or 0 ) setElementData ( source, "times_attacked", ( times + 1 ) ) if ( not timers [ source ] ) then timers [ source ] = setTimer ( function ( ) if getElementData ( source,"times_attacked" ) then removeElementData ( source,"times_attacked" ) timers [ source ] = nil end end ,( cooldown * 1000 ), 1 ) end if ( getElementData ( source, "times_attacked" ) >= 3 ) then if getElementData ( source,"times_attacked" ) then removeElementData ( source, "times_attacked" ) end if ( timers [ source ] ) then killTimer ( timers [ source ] ) timers [ source ] = nil end end end end end ) Try it. I changed the timer part, since you were using a global variable, which means if another player was attacked, the timer for the other players would be the same, so you had to use a table.
  8. Instead of making it like that, you could make a table with all the hospital positions, then make a loop to determine the nearest one.
  9. Castillo

    Spawnmenu

    Any errors in the debugscript? what exactly doesn't work?
  10. Awesome job! looking forward to check it out when it's released.
  11. 1º Un comando para dar dinero al jugador especificado. Funciones que necesitas: addCommandHandler getPlayerFromName getPlayerMoney givePlayerMoney takePlayerMoney outputChatBox 2º Una puerta que se abra y cierre al entrar o salir de su radio. Funciones que necesitas: createObject createColTube moveObject Eventos que necesitas: onColShapeHit onColShapeLeave 3º Un sistema de logueo basico con comando. Funciones que necesitas: addCommandHandler getAccount logIn outputChatBox Si se me ocurren mas ideas luego las posteo.
  12. Castillo

    Small problem

    function onPlayerDamage ( attacker ) if isPlayerInTeam ( source, "Police" ) then if ( getElementType ( attacker ) == "player" and getElementModel ( source ) == 280 ) then setPlayerWantedLevel ( attacker, 2 ) end end end addEventHandler ( "onPlayerDamage", getRootElement(), onPlayerDamage )
  13. Castillo

    Small problem

    And the problem is...?
  14. "..money"$" You forgot to add the dots after "money", like this: ".. money .."$"
  15. Castillo

    Spawnmenu

    Well, if you don't tell us what spawn menu is it, how do you expect to get help?
  16. Read about SQL injections, you should make your queries like this: dbQuery ( "SELECT * FROM myTable WHERE account = ?", "Castillo" )
  17. addEvent ( "onPlayerPickUpRacePickUp", true ) addEventHandler ( "onPlayerPickUpRacePickUp", getRootElement(), function ( pickupID, pickupType, vehicleModel ) if ( pickupType == "vehiclechange" ) then loadVehicleColor ( source ) outputChatBox ( "loadVehicleColor for ".. tostring ( getPlayerName ( source ) ) ) end end ) Use that and see what it says when you take a pickup.
  18. Any errors at the debugscript?
  19. Castillo

    Small problem

    Does it work as you wanted? or still having problems?
  20. Castillo

    Small problem

    function onPlayerTarget ( theCop ) local PoliceTeam = getTeamFromName ( "Police" ) if ( PoliceTeam ) then if ( getElementType ( theCop ) == "player" and getElementModel ( theCop ) == 280 ) and ( getPlayerWantedLevel ( source ) == 0 ) then setPlayerWantedLevel ( source, 1 ) end end end addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTarget ) By the way, why are you checking if the team exists? maybe you wanted to check if the player team was "Police"?
  21. Try adding this at the top of the script: addEvent ( "onPlayerPickUpRacePickUp", true Also, what is "onClientRender" doing in a server side script? this event is client side only.
  22. That query isn't really secure, it can lead to SQL injections.
  23. Creo que son estas: x: -1860.82, y: 59.74, z: 1062.14, id: 14
×
×
  • Create New...