Jump to content

Anderl

Members
  • Posts

    2,266
  • Joined

  • Last visited

Everything posted by Anderl

  1. My bad, I wrote '%d02' instead of '%02d'. I tested it with this correction, it works perfectly. print( msToStr( 2000 ) ); --Output: 00:00:02
  2. local aShot = { }; addEventHandler( 'onClientResourceStart', resourceRoot, function( ) for _, pUser in ipairs( getElementsByType 'player' ) do aShot[pUser] = 0; end -- addEventHandler( 'onClientPlayerDamage', root, onShot ); addEventHandler( 'onClientPlayerQuit', root, onLeave ); end ); onShot = function( pAttacker, iWeapon, iBPart ) if( pAttacker and iWeapon ) then if( aShot[pAttacker] ) then aShot[pAttacker] = aShot[pAttacker] + 1; end -- if( aShot[pAttacker] == 2 ) then if( iBPart == 7 ) then outputChatBox( 'You broke your left leg!', source, 255, 255, 255, false ); aShot[pAttacker] = 0; end end end end onLeave = function( ) if( aShot[source] ) then aShot[source] = nil; end end Not tested.
  3. https://wiki.multitheftauto.com/wiki/Element/Shader
  4. I'm not very good at maths and not very familiar with string.format but this should work: function msToStr( ms ) if( ms ) then return string.format( '%02d:%02d:%02d', ( tonumber( ms ) / ( 1000 * 60 * 60 ) ) % 60, ( tonumber( ms ) / ( 1000 * 60 ) ) % 60, ( tonumber( ms ) / 1000 ) % 60 ); end return false; end Example: msToStr( 2000 );
  5. I don't think I've seen anyone bother with Hungarian notation in Lua. Or... most languages, really. As long as the naming scheme makes sense, who cares. If that guy wants to use notation, then he should use it right otherwise it makes no sense of using it.
  6. Off-topic: Your prefix is wrong, actually should be "sz" and not "a" as the function returns a string not an array. Read Hungarian notation: http://en.wikipedia.org/wiki/Hungarian_notation On-topic: Here's a better code: addEventHandler( 'onPlayerChat', root, function( szMessage ) local pPlayer = getPlayerName( source ):gsub( '_', '' ); if( pPlayer ) then cancelEvent( ); outputChatBox( pPlayer .. '#FFFFFF: ' .. szMessage, root, 255, 255, 255, true ); outputServerLog( 'CHAT: ' .. pPlayer .. ': ' .. szMessage ); end end ); Note: This is a server-side code.
  7. That'll do the same. As CrystalMV said, it should be set as false after a short time..
  8. Not to start a discussion but there may be a lot of people who insults others, but we are not like them, which DDoS servers all the time ( some people in MTA:SA do that too, but they are few ) and also his sentence about MTA developers is wrong, actually Kalcon is the one which is "nutjob". SA:MP players = 11 y/o kids. Did MTA Team even get help from Rockstar?
  9. If he even have money to invest...
  10. You need to make a function to search for player element by a part of the name, otherwise using getPlayerFromName functions, you'll have to put full player name with color codes when using PM command.
  11. This is the worst "company" I ever saw. You can't even write "2012" properly.
  12. I know this may not be the right place, but as we are talking about website I would like to "suggest" a new website design. This one is a bit boring already, principally the forums theme, it seems like old sh*t. Anyway, it's up to you.
  13. It does. It was something with the OS itself, not compatibility problem or something like that.
  14. No. VPS is a virtual server on a physical machine. Gamehost is just a gameserver in a server ( almost all "companies" use VPS to host games which makes gameservers lag even more than using a physical machine because the VPS's hardware is shared with others ) and it may lag more than in a VPS because 14 y/o kids put 500 servers in a 1GB VPS. If you really need a good gamehost, get some dedicated server from a trusted company. Most hosts (like mine) don't use VPS, we use Dedicated Servers to run all our gameservers. Not really, almost all use VPS ( I'm not saying yours use so.. ).
  15. No. VPS is a virtual server on a physical machine. Gamehost is just a gameserver in a server ( almost all "companies" use VPS to host games which makes gameservers lag even more than using a physical machine because the VPS's hardware is shared with others ) and it may lag more than in a VPS because 14 y/o kids put 500 servers in a 1GB VPS. If you really need a good gamehost, get some dedicated server from a trusted company.
  16. Anderl

    Whats wrong?

    Solidsnake14 already explained you what you need, if you don't understand, you should learn Lua. Use wiki too: https://wiki.multitheftauto.com/
  17. getTickCount + conversão de ms para horas/minutos/segundos.
  18. Because it will be easier than making lots of functions for different texts or declaring lots of variables.
  19. It's probably that server-side requested the event but client-side is still not loaded.
  20. Where did you see that you need to unpack tables?
  21. And event is also server-side, but dxDrawText is client-side. Client-side: __dxDrawText = dxDrawText local _aDraws = { } function dxDrawText( ... ) if( ... ) then _aDraws[{ ... }] = true return true end return false end addEventHandler( 'onClientRender', root, function( ) for arg,v in pairs( _aDraws ) do while true do if( arg[1] == localPlayer ) then __dxDrawText( #arg => 2 and arg[2] or false, #arg => 3 and arg[3] or false, #arg => 4 and arg[4] or false, #arg => 5 and arg[5] or false, #arg => 6 and arg[6] or false, #arg => 7 and arg[7] or false, #arg => 8 and arg[8] or false, #arg => 9 and arg[9] or false, #arg => 10 and arg[10] or false, #arg => 11 and arg[11] or false, #arg => 12 and arg[12] or false, #arg => 13 and arg[13] or false, #arg => 14 and arg[14] or false, #arg => 15 and arg[15] or false, #arg => 16 and arg[16] or false; ) end break end end ) -- addEventHandler( 'onPlayerJoin', root, function( ) dxDrawText( root, 'Server: ' .. getPlayerName( source ) .. ' has joined the game!', 3, 0, 10, 10, tocolor( 0, 0, 0, 200 ), 0.3, 'default' ) end ) Server-side: addEventHandler( 'onPlayerJoin', root, function( ) triggerClientEvent( root, 'onPlayerJoin', source ) end ) Not tested.
  22. No, I meant explain in a proper english
×
×
  • Create New...