Jump to content

STR6

Members
  • Posts

    5
  • Joined

  • Last visited

4 Followers

Details

  • Gang
    STR

Recent Profile Visitors

1,819 profile views

STR6's Achievements

Vic

Vic (3/54)

4

Reputation

  1. 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. can you delete ? https://community.multitheftauto.com/?p=resources&amp;s=details&amp;id=15707 DONE
  4. string.sub(getPlayerName(getLocalPlayer()), 1, 3) .. "..."
×
×
  • Create New...