stranger6

Members
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

3 Neutral

4 Followers

About stranger6

  • Rank
    Vic

Details

  • Gang
    STR

Recent Profile Visitors

593 profile views
  1. stranger6

    [AJUDA] Uso de Vector3

    JSON é uma linguagem de programação. Com toJSON você pode converter um valor para string, e com fromJSON o você converte um valor que já está em JSON para o valor original novamente. addEventHandler( "onResourceStart", resourceRoot, function( ) executeSQLQuery( "CREATE TABLE IF NOT EXISTS save ( account TEXT, pos TEXT )" ); end ); function savePosition( player ) local account = getPlayerAccount( player ); if ( not isGuestAccount( account ) ) then local account_name = getAccountName( account ); local result = executeSQLQuery( "SELECT pos FROM save WHERE account = ? LIMIT 1", account_name ); local x, y, z = getElementPosition( player ); local pos = toJSON( { x, y, z } ); if ( table.maxn( result ) == 0 ) then executeSQLQuery( "INSERT INTO save ( account, pos ) VALUES ( ?, ? )", account_name, pos ); else executeSQLQuery( "UPDATE save SET pos = ? WHERE account = ?", pos, account_name ); end end end function loadPosition( player ) local account = getPlayerAccount( player ); if ( not isGuestAccount( account ) ) then local account_name = getAccountName( account ); local result = executeSQLQuery( "SELECT pos FROM save WHERE account = ? LIMIT 1", account_name ); if ( table.maxn( result ) > 0 ) then local x, y, z = fromJSON( result[ 1 ][ "pos" ] ); setElementPosition( player, x, y, z + 1 ); end end end split separa uma string em substrings, você especifica um caractere que sera usado como separador, ele ira retornar uma table com as substrings. local string = "a;b"; local table_ = split( string, ";" ); -- table_ está com o valor de uma tabela, com duas substrings. { "a", "b" }; for _, character in ipairs( table_ ) do outputChatBox( character ); end -- result; --> a; --> b; unpack separa todos os valores que estão na table. local pos = { 0, 0, 0 }; addCommandHandler( "gotozero", function( ply ) local x, y, z = unpack( pos ); -- { 0, 0, 0 } to 0, 0, 0; setElementPosition( ply, x, y, z ); end ); Acho que consegui explicar corretamente ;x
  2. local hospitais = { { x, y, z }, { x, y, z }, } function getNewSpawn( player ) local hospitais_ = { } local x, y, z = getElementPosition( player ) for i=1, #hospitais do table.insert( hospitais_, { distance = getDistanceBetweenPoints3D( x, y, z, hospitais[ i ][ 1 ], hospitais[ i ][ 2 ], hospitais[ i ][ 3 ] ), id = i } ) end table.sort( hospitais_, function( a, b ) return a.distance < b.distance end ) local id = hospitais_[ 1 ].id return hospitais[ id ][ 1 ], hospitais[ id ][ 2 ], hospitais[ id ][ 3 ] end --[[ local x, y, z = getNewSpawn( player ) ]]--
  3. stranger6

    Report community resources here!

    can you delete ? https://community.multitheftauto.com/?p=resources&amp;s=details&amp;id=15707 DONE
  4. stranger6

    Encurtar nome

    string.sub(getPlayerName(getLocalPlayer()), 1, 3) .. "..."