Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 16/12/19 in all areas

  1. https://wiki.multitheftauto.com/wiki/GetElementMatrix function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end
    1 point
  2. Utilize o botão <> do fórum para colar códigos. Não cole direto no texto.
    1 point
  3. Utilize o botão <> do fórum para postar códigos. Não cole direto no texto.
    1 point
  4. By doing this am I avoiding this deeeeep copy? local myTable = {} -- Some filled in table setTimer(function() callAnotherFunction(myTable) end, 1000, 1)
    1 point
  5. It is a limit. Timer are an async method. It requires a lot more work to keep temporary variables alive. So timers will make copies of the values rather managing the original values. - You can't pass functions in to a timer as argument. (They can't be copied) - You can pass tables in to a timer as argument, but they will become a (deep) copy.
    1 point
  6. Primeiro você tem que aprender o faço escrevendo da forma certa. Normalmente o script utiliza elementData com o level do player, veja como funciona para obter o level olhando o código do script, depois só puxar os dados pelo script da Hud. @NeoGM
    1 point
  7. Instead of setting every value invidually, I suggest using JSON to save the trouble and make it a little bit cleaner. Try the following, I tested it and seems to work just fine. function saveAccount( account ) local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) if ( account ) and ( not isGuestAccount( account ) ) then local x, y, z = getElementPosition( source ) local _, _, rotation = getElementRotation( source ) local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } local weapons = { } for i = 0, 12 do weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } end setAccountData( account, "account.position", toJSON( position ) ) setAccountData( account, "account.stats", toJSON( stats ) ) setAccountData( account, "account.weapons", toJSON( weapons ) ) end end addEventHandler( "onPlayerQuit", root, saveAccount ) addEventHandler( "onPlayerWasted", root, saveAccount ) addEventHandler( "onPlayerLogout", root, saveAccount ) addEventHandler( "onPlayerLogin", root, function( _, account ) local position = getAccountData( account, "account.position" ) if ( position ) then position = fromJSON( position ) spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) else spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) end setCameraTarget( source, source ) fadeCamera( source, true, 2.0 ) local stats = getAccountData( account, "account.stats" ) if ( stats ) then stats = fromJSON( stats ) setElementHealth( source, stats.health ) setPedArmor( source, stats.armor ) setPlayerMoney( source, stats.money ) end local weapons = getAccountData( account, "account.weapons" ) if ( weapons ) then weapons = fromJSON( weapons ) for i, data in pairs( weapons ) do giveWeapon( source, data.weapon, data.ammo, false ) end end end )
    1 point
  8. I've written this basic account data weapon saver, should get you started. function saveWeapons(player, account) if player and account then for i=0,12 do local weapon = getPedWeapon(player, i) local ammo = getPedTotalAmmo(player, i) setAccountData(account,"w"..tonumber(i), weapon) setAccountData(account,"a"..tonumber(i), ammo) end takeAllWeapons(player) end end addEventHandler("onPlayerQuit",root,function () saveWeapons(source, getPlayerAccount(source)) end) addEventHandler("onPlayerLogout",root,function(prev) saveWeapons(source, prev) end) addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if not account or isGuestAccount(account) then return end for i=0,12 do local weapon = getAccountData(account,"w"..tonumber(i)) local ammo = getAccountData(account,"a"..tonumber(i)) if weapon and ammo then setTimer(giveWeapon, 1000, 1, source, tonumber(weapon), tonumber(ammo), true) end end end)
    1 point
  9. Na verdade eu paguei por esse script, então creio que eu tenha alguma permissão para me basear a fazer outro script a partir desse... Mas agradeço a sugestão.
    0 points
×
×
  • Create New...