Jump to content

aka Blue

Members
  • Posts

    2,106
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by aka Blue

  1. aka Blue

    Pregunta...

    @Gaberiel function getMyData ( thePlayer, command ) local data = getAllElementData ( thePlayer ) -- get all the element data of the player who entered the command for k, v in pairs ( data ) do -- loop through the table that was returned outputConsole ( k .. ": " .. tostring ( v ) ) -- print the name (k) and value (v) of each element data, we need to make the value a string, since it can be of any data type end end addCommandHandler ( "elemdata", getMyData )
  2. Eso hago pero sigue apareciendo mal. Mi duda es, ¿qué hago? ¿lo sumo, lo resto, lo divido, lo multiplico? Porque las posiciones que hay puestas son las "buenas" que digamos, mas bien, las que tienen que quedar al final. Eso hago pero sigue apareciendo mal. Mi duda es, ¿qué hago? ¿lo sumo, lo resto, lo divido, lo multiplico? Porque las posiciones que hay puestas son las "buenas" que digamos, mas bien, las que tienen que quedar al final. Eso hago pero sigue apareciendo mal. Mi duda es, ¿qué hago? ¿lo sumo, lo resto, lo divido, lo multiplico? Porque las posiciones que hay puestas son las "buenas" que digamos, mas bien, las que tienen que quedar al final.
  3. Gracias @Tomas. Ya funcionó. Ahora mi duda es... el componente no se detecta como un elemento, pero, podría hacer un render en el cual, pudiese mover ese componente usando una variable para almacenarlo y en el render con distintos botones el movimiento del mismo?
  4. Vector en el argumento 4, got boolean me dice, no se puede ejecutar el getDistanceBetweenPoints3D function getClosestComponent( vehicle, x, y, z ) local a = { } for component in pairs( getVehicleComponents( vehicle ) ) do local cx, cy, cz = getVehicleComponentVisible( vehicle, component, "world" ) local distance = getDistanceBetweenPoints3D( x, y, z, cx, cy, cz ) if a[ distance ] then repeat offset = math.random( ) until not a[ distance+offset ] end a[ distance+( offset or 0 ) ] = { component, offset or 0 } end local least, leastComp = -math.huge, nil for dist, compData in pairs( a ) do local component, offset = unpack( compData ) if dist-offset > least then least = dist-offset leastComp = component end return component end end addEventHandler( "onClientClick", root, function( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if button == "left" and state == "down" then if getElementType( clickedElement ) == "vehicle" then local component = getClosestComponent( clickedElement, worldX, worldY, worldZ ) if component then outputChatBox( "si" ) else outputChatBox( "no" ) end end end end ) Vector en el argumento 4, got boolean me dice, no se puede ejecutar el getDistanceBetweenPoints3D function getClosestComponent( vehicle, x, y, z ) local a = { } for component in pairs( getVehicleComponents( vehicle ) ) do local cx, cy, cz = getVehicleComponentVisible( vehicle, component, "world" ) local distance = getDistanceBetweenPoints3D( x, y, z, cx, cy, cz ) if a[ distance ] then repeat offset = math.random( ) until not a[ distance+offset ] end a[ distance+( offset or 0 ) ] = { component, offset or 0 } end local least, leastComp = -math.huge, nil for dist, compData in pairs( a ) do local component, offset = unpack( compData ) if dist-offset > least then least = dist-offset leastComp = component end return component end end addEventHandler( "onClientClick", root, function( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if button == "left" and state == "down" then if getElementType( clickedElement ) == "vehicle" then local component = getClosestComponent( clickedElement, worldX, worldY, worldZ ) if component then outputChatBox( "si" ) else outputChatBox( "no" ) end end end end )
  5. Lo hice pero sigue dando problemas. Se mueve hacia la derecha y pues el texto queda algo fuera :c local font = dxCreateFont( "Lato.ttf" ) addEventHandler ( "onClientRender", root, function() local playersTable = getElementsByType( 'player' ) for i=1, #playersTable do local p = playersTable[ i ] -- Get the player --if isLoggedIn( p ) then local name = getPlayerName( p ) local px, py, pz = getElementPosition( p ) -- Get the position local cx, cy, cz = getCameraMatrix( ) -- Get the camera matrix local min_distance = getDistanceBetweenPoints3D( cx, cy, cz, px, py, pz ) -- Get the min distance between 3D points if min_distance < 15 then if isLineOfSightClear( cx, cy, cz, px, py, pz, true, false, false, true, false, false, false, localPlayer ) then local bx, by, bz = getPedBonePosition( p, 5 ) local x,y = getScreenFromWorldPosition( bx, by, bz + 0.3 ) local textWidth = dxGetTextWidth( name, 0.85 + ( 15 - min_distance ) * 0.03 , font) if x and y then dxDrawRectangle( x-54, y-10, textWidth+15, y/15, tocolor(0, 0, 0, 30) ) dxDrawText( name, x-10, y+2, x, y, tocolor(0, 0, 0), 0.85 + ( 15 - min_distance ) * 0.03, font, "center", "center", false, false, false, true ) dxDrawText( name, x-10, y, x, y, tocolor(255, 255, 255), 0.85 + ( 15 - min_distance ) * 0.03, font, "center", "center", false, false, false, true ) end end end --end end end)
  6. Bueno, como dice el título, estoy realizando unos pequeños cambios y lo que quiero hacer es crear nametags encima de la cabeza del jugador pero que los mismos tengan un rectángulo que se vaya poniendo más grande o más pequeño según la longitud del nombre con la función DxGetTextWidth. ¿Cómo podría hacerlo? Actualmente tengo ésto: local font = dxCreateFont( "Lato.ttf" ) addEventHandler ( "onClientRender", root, function() local playersTable = getElementsByType( 'player' ) for i=1, #playersTable do local p = playersTable[ i ] -- Get the player --if isLoggedIn( p ) then local px, py, pz = getElementPosition( p ) -- Get the position local cx, cy, cz = getCameraMatrix( ) -- Get the camera matrix local min_distance = getDistanceBetweenPoints3D( cx, cy, cz, px, py, pz ) -- Get the min distance between 3D points if min_distance < 15 then if isLineOfSightClear( cx, cy, cz, px, py, pz, true, false, false, true, false, false, false, localPlayer ) then local bx, by, bz = getPedBonePosition( p, 5 ) local x,y = getScreenFromWorldPosition( bx, by, bz + 0.3 ) if x and y then dxDrawRectangle( x-54, y-10, x/5, y/15, tocolor(0, 0, 0, 30) ) dxDrawText( "[Player] "..getPlayerName( p ), x-10, y+2, x, y, tocolor(0, 0, 0), 0.85 + ( 15 - min_distance ) * 0.03, font, "center", "center", false, false, false, true ) dxDrawText( "[#800000Player#ffffff] "..getPlayerName( p ), x-10, y, x, y, tocolor(255, 255, 255), 0.85 + ( 15 - min_distance ) * 0.03, font, "center", "center", false, false, false, true ) end end end --end end end) Cómo se ve:
  7. aka Blue

    Joinquit

    Lo que entiendo que quiere hacer es que aparezca un mensaje y al cabo de unos segundos se mueva. Quizás no lo haya entendido bien, @Tomas
  8. aka Blue

    Joinquit

    De todas formas, debes utilizar getTickCount para eso, que es lo más recomendable desde mi punto de vista, ya que, si metes un timer en un render, se crea un timer por cada frame y, bueno, bum pc xd.
  9. aka Blue

    Joinquit

    No uses un timer en un render xD. Para lo que tu quieres hacer se usa interpolateBetween, creo.
  10. aka Blue

    Admin logo

    You need to add a the bone that you want to get the position from: float float float getPedBonePosition ( ped thePed, int bone )
  11. I think that the actual scripting functions are more than sufficient to do an electronic speedometer.
  12. @Tomas ¿Y cómo debería utilizarlo correctamente? Pregunto debido a que retorna 2 datos, una llego a entender que es la posición (leastComp), pero la otra, ¿Es? ¿La distancia entre? Gracias
  13. ¿Cómo podría hacerlo? El de buscar el más cercano, me refiero.
  14. Hi everyone. My question is... ¿its possible to position of the vehicle component by clicking? ¿How can i do it? Thanks I wanna make a component moving script
  15. aka Blue

    Ayuda

    @TadMad De nada Dale like a la respuesta si te sirvió. PD: Suena muy YouTube eso, es para ganar los puntitos verdes xd.
  16. Ok, just use onClientPlayerWeaponFire and check if the weapon is the fire extng. If is, then create a projectile of granade function fireGranade( weapon, _, _, _, _, _, _ ) if ( weapon == 42 ) then cancelEvent( ) -- Cancel the event local x, y, z = getElementPosition( source ) -- Get the player position createProjectile( source, 16, x, y, z ) -- Create grenade projectile end end addEventHandler( "onClientPlayerWeaponFire", root, fireGranade ) I think it should work, not tested yet
  17. aka Blue

    Ayuda

    Debes eliminar el texto de render que tiene paradise. Para ello, edité un poco el código por mi mismo y me funcionó: Archivo: respawn_c.lua: addEvent ( "onBorrarTexto", true ) addEventHandler ( "onBorrarTexto", localPlayer, function ( ) respawnWait = false removeEventHandler( "onClientRender", root, drawRespawnText ) end ) Archivo: respawn.lua: addCommandHandler ( "reanimar", function ( player, commandName, otherPlayer ) local other, name = getFromName ( player, otherPlayer ) if hasObjectPermissionTo ( player, "command.kick", false ) or exports.factions:isPlayerInFaction ( player, 2 ) then if isElement ( other ) and isLoggedIn ( other ) and isPedDead ( other ) then if other == player then outputChatBox ( "No puedes reanimarte a ti mismo.", player, 255, 0, 0 ) else local x, y, z = getElementPosition ( player ) spawnPlayer ( other, x, y, z, 180, getElementModel ( other ), 0, 0 ) triggerClientEvent ( other, "onBorrarTexto", other ) fadeCamera ( other, true ) setCameraTarget ( other, other ) setCameraInterior ( other, 0 ) wastedTimes [ other ] = nil end end end end )
  18. Bueno, mi pregunta es, ¿puedo detectar si he clickeado el componente de un vehículo con el ratón client-side? Si es posible, ¿cómo debería hacerlo? Gracias.
  19. No te recomiendo guardarlo así. Guardalo tipo 1 o 0, 1 sería igual a completado y 0 a no completado. Y no, no uses executeSQLQuery porque esas funciones solo actúan para el registry.db como bien dice la wiki: NOTE: This function only acts upon registry.db. Use dbQuery to query a custom SQL databse. Te lo digo porque creo que no se pueden guardar variables en una base de datos. Simplemente antes del guardado, realiza una condicion, es decir, si la variable es true, entonces lo guardas como '1', y en caso de que no, pues como '0'. Algo así: --Client e = { t = triggerServerEvent, a = addEventHandler, l = addEvent } e.a( "onClientPlayerQuit", root, function( ) e.t( "test", localPlayer, completeAll ) end ) e.l( "loadDataAccount", true ) e.a( "loadDataAccount", root, function( tabla_variables ) variables = tabla_variables end ) e.a( "onClientRender", root, function( ) if variables then if variables[1]["logro_1"] == 1 then guiSetText(none10, "COMPLETADO") else guiSetText(none10, "NO COMPLETADO") end end end ) PD: Por favor, ordena un poco el código que no entiendo nada xd.
  20. Gracias @Gaberiel. Quiero preguntar... ayer hice lo siguiente, porque lo vi en un post de la sección inglesa. local sWidth, sHeight = guiGetScreenSize( ) local sx1, sy1 = sWidth/1024, sHeight/768 dxDrawRectangle( sx1*50, sy1*555, sx1*210, sy1*25, tocolor( 0, 0, 0, 50 ) ) Por lo visto se dibuja bien en todas las resoluciones (lo dibujé en 800 y lo testeé en 1024 y por lo visto, quedaba en la misma posición), aunque no estoy muy seguro. Y bueno, mi otra duda es hacerlo relativo con la posición del ratón, ya que, ahora tengo ésto: local sx, sy = guiGetScreenSize( ) local mx, my, worldx, worldy, worldz = getCursorPosition( ) dxDrawRectangle( sx*(1024/sx*mx-0.004), sy*(768/sy*my), sx*(1024/sx/5), sy*(768/sy/10+0.095), tocolor( 0, 0, 0, 80 ) ) dxDrawImage ( sx*mx+42, sy*my, sx/12, sy/10, 'tuerca.png', 0, 0, 0, tocolor( 255, 145, 0, 200 ) ) Ví en la wiki, exactamente en la explicación de guiGetScreenSize que lo que se tenía que dividir era la posición del rectángulo entre la resolución de la pantalla y después multiplicarlo.
  21. aka Blue

    Solucion

    Ya no se utiliza executeSQLQuery ni executeSQLUpdate. Debes usar las funciones db de MTA para tablas personalizadas. Hace poco le pasé este codigo a otro miembro de la comunidad, mira si e puedes guiar: -- Creamos la base de datos y la tabla principal addEventHandler( "onResourceStart", resourceRoot, function( ) sql = dbConnect ( "sqlite" , "accounts.db" ) -- Create the connection accountsTable = dbExec ( sql , "CREATE TABLE IF NOT EXISTS accounts (account TEXT,password TEXT,serial TEXT)" ) if fileExists( "accounts.db" ) and sql and accountsTable then outputDebugString( "Succefully connected SQLite resource" ) else outputDebugString( "Failed to connect SQLite" ) end end ) -- Comprobar si un SELECT FROM devuelve un resultado: local find_account = dbQuery ( sql , "SELECT * FROM accounts WHERE account = ?", username ) local result = dbPoll( find_account, -1 ) if result and #result > 0 then outputDebugString( "Account exists" ) else outputDebugString( "Account does not exists" ) end -- Uso de INSERT local qh = dbQuery ( sql , "INSERT INTO accounts (account,password,serial) VALUES (?,?,?)", username, md5(password), serial ) local result = dbPoll( qh, -1 ) if result then outputDebugString( "Registered" ) return true else outputDebugString( "Error, contact server admin" ) return end -- Uso de UPDATE local result = dbFree ( dbQuery ( sql , "UPDATE accounts SET password = ? WHERE account = ?" , md5(new_pass), account ) ) if result then outputDebugString( "New MD5 password = "..md5(new_pass) ) outputDebugString( "Without MD5 = "..tostring( new_pass ) ) else outputDebugString( "Error changing password" ) end
  22. Si. Solo que al loguearse haz un par de llamadas a SQLite para sacar los datos y triggealos.
×
×
  • Create New...