Jump to content

Adolfram

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by Adolfram

  1. well, i used this on my notification functions and never was troubled: timeToFade = getTickCount () + #text * 150; for exports, there are two ways. one: setting variables on resource start and check if variable is assigned to a value on render and use it if it does. two: creating a local function in your exported function and pass the arguments you need to render (i prefer this one because variables are nasty-looking). so, the new code should look like this: local displayWidth, displayHeight = guiGetScreenSize(); local borderDistance = 20 local tipBox = { } local boxX, boxY = borderDistance * displayWidth / displayWidth, borderDistance * displayHeight / displayHeight local boxPadding = 10 local lineHeight = dxGetFontHeight( 1, "default-bold" ) local minimumWidth = 350 local offsetWidth = 25 local tick = 0 addEventHandler( "onClientRender", root, function( ) if tipBox.string then local lines = 0 local wordbreak = false local lineWidth = dxGetTextWidth( tipBox.string, 1, "default-bold" ) while ( lineWidth + offsetWidth > minimumWidth ) do lineWidth = lineWidth - minimumWidth lines = lines + 1 wordbreak = true end local boxWidth, boxHeight = minimumWidth + ( boxPadding * 3 ), ( lineHeight * ( lines + 1 ) ) + ( boxPadding * 2 ) dxDrawRectangle( boxX, boxY, boxWidth, boxHeight, tocolor( 0, 0, 0, 180 ), true ) dxDrawRectangle( boxX, boxY+boxHeight, boxWidth, 4, tocolor( 200, 0, 100, 255 ), true ) local textX, textY = boxX + boxPadding, boxY + boxPadding local textWidth, textHeight = textX + minimumWidth + boxPadding, textY + lineHeight + boxPadding dxDrawText( tipBox.string, textX, textY, textWidth, textHeight, tocolor( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", false, wordbreak, true ) if getTickCount () >= tick then alpha = alpha - 25; if alpha <= 0 then alpha = 0; tipBox.string = nil; end end end end ) function notificate (text) --declare your function tipBox.string = text; tick = getTickCount () + (#text * 150); alpha = 255; --if you want it to fade end notificate ("shakalaka boom"); --testing i haven't tried it
  2. well, you gotta replace those functions with mta built functions. it's all pretty much convertable
  3. you'll use arguments, it's all well explained on wiki. takes some time to understand though. here are related wiki links: https://wiki.multitheftauto.com/wiki/TriggerServerEvent https://wiki.multitheftauto.com/wiki/TriggerClientEvent it's like passing arguments to a function. pretty handy stuff really you'll use arguments, it's all well explained on wiki. takes some time to understand though. here are related wiki links: https://wiki.multitheftauto.com/wiki/TriggerServerEvent https://wiki.multitheftauto.com/wiki/TriggerClientEvent it's like passing arguments to a function. pretty handy stuff really. here's an example for you: --serverside addEvent ("myEvent"); --add your event addEventHandler ("myEvent", root, --and its handler function (data) --argument of your data outputChatBox (tostring (data)); --execute end ); --clientside triggerServerEvent ("myEvent", resourceRoot, "My name is Jeff"); --this triggers "myEvent" event added on serverside and outputs "My name is Jeff" on serverside
  4. if everything is clientside it might be cheeky because players can edit xml files when it's added on clientside. this is prolly the source of the issue because you might be trying to reach a server xml file on clientside and it naturally cannot reach the file. try serverside
  5. have you tried to set z position lower? it might help avoid the cause of explosion
  6. all you have to do is using sql functions... it's all detailed in the link @pa3ck sent
  7. is there any way to convert a date format to timestamp? i tried to require someone's script but it said it was an unsafe function, also os class won't work
×
×
  • Create New...