Jump to content


  • Posts

  • Joined

  • Last visited

About cheez3d

  • Birthday 01/01/1970

Recent Profile Visitors

701 profile views

cheez3d's Achievements


Pee-Wee (21/54)



  1. cheez3d


    addEventHandler("onPlayerChangeNick", getRootElement(), function(oldNick, newNick) if (newNick) then outputChatBox(""..oldNick.." --> "..newNick.."",getRootElement(), 255, 100, 100, true) local logFile = fileExists("logs/logs.log") and fileOpen("logs/logs.log") or fileCreate("logs/logs.log") if (logFile) then local size = fileGetSize(logFile) fileSetPos(logFile, size) fileWrite(logFile, ""..oldNick.." --> "..newNick.."") fileClose(logFile) end end end)
  2. local Table = {level = 1}; Table.maxcount = 1000+1000*Table.level
  3. And this should also be available for dxCreateShader!
  4. More like math.randomseed(getRealTime().timestamp);
  5. cheez3d


    Lua makes use of the C string formatting. %d represents a digit and %s represents an array of characters. http://www.cplusplus.com/reference/cstdio/printf/ When you do print(("%d"):format(10)) it will print 10 instead of %d (it replaces %d with 10). When you do print(("String: %s"):format("This is my string!")) it will print "String: This is my string!" instead of "String: %s".
  6. http://wiki.multitheftauto.com/wiki/Element_tree You could also make it even faster by only ataching the event to the menuButton instead of guiRoot. local RenderHandler = function() dxDrawImage(screenWidth/2.20,screenHeight/1.50,150,40,'images/exitmenu_hover.png'); end; local ButtonEnter = function() addEventHandler("onClientRender",root,RenderHandler); end; addEventHandler("onClientMouseEnter",menuButton,ButtonEnter,false); local ButtonExit = function() removeEventHandler("onClientRender",root,RenderHandler); end; addEventHandler("onClientMouseLeave",menuButton,ButtonExit,false) That 4th false in the addEventHandler will make sure the event will not propagate trough the parent and the children of the button.
  7. cheez3d


    local String = [[Name: %s UpTime: %s Occupation: %s Health: %d Group: %s Group Rank: %s Cash %d Wanted Level: %d Country: %s]]; guiSetText(GUIEditor.label[1],String:format(playername,getElementData(thePlayer,"UpTime"),getElementData(thePlayer,"Occupation"),getElementHealth(thePlayer),getElementData(thePlayer,"Group"),getElementData(thePlayer,"GroupRank"),getPlayerMoney(thePlayer),getPlayerWantedLevel(thePlayer),getElementData(thePlayer,"Country")));
  8. Stop posting if you don't know what you're talking about...
  9. No. Every resourceRoot has it's own guiRoot.
  10. Don't use root, use guiRoot.
  11. cheez3d

    Table :s

    local Punishments = {}; -- Table to store punishments; local PunishPlayer = function(punisher,player,type,time) -- Player to punish, type of punishment, time; if Punishments[player] then return false; -- Player is already punished; end; Punishments[player] = { Punisher = punisher, Time = time, Type = type; }; return Punishments[player]; end; addCommandHandler("punish",function(punisher,_,player,type,time) PunishPlayer(punisher,getPlayerFromName(player),type,time); end);
  12. tocolor() converts your numbers to Hex and then it converts that Hex back to one decimal number. tocolor(255,255,255) => 0xFFFFFF => 16777215 (without alpha); tocolor(255,255,255,255) => 0xFFFFFFFF => 4294967295 (with alpha); To get the Hex back from the decimal number just format the string "%x" like this: ("%x"):format(tocolor(r,g,b)) And that is your Hex. If you want to go deeper and convert that Hex back to 3 or 4 decimals you do it like this: local Hex = ("%x"):format(tocolor(r,g,b)); local Color = {}; for i = 1,6,2 do table.insert(Color,tonumber(Hex:sub(i,i+1),16)); -- supply 16 as an argument because we are converting from base 16; end; And that is your RGB.
  13. cheez3d

    Hex Color

    Or if you want to convert from 3 or 4 numbers without tocolor: local ConvertRGBToHex = function(r,g,b,a) if a then return ("%02x%02x%02x%02x"):format(r,g,b,a); end; return ("%02x%02x%02x"):format(r,g,b); end;
  14. addEventHandler("onPlayerWasted",root,function(_,killer) if killer and getElementType(killer) == "player" then local VictimX,VictimY,VictimZ = getElementPosition(source); local KillerX,KillerY,KillerZ = getElementPosition(killer); local Distance = getDistanceBetweenPoints3D(VictimX,VictimY,VictimZ,KillerX,KillerY,KillerZ); outputChatBox(getPlayerName(source).." was killed by "..getPlayerName(killer).." from a distance of "..tostring(Distance).."!",root,255,255,255); end; end);
  • Create New...