-
Posts
100 -
Joined
-
Last visited
Everything posted by Soapbosnia
-
Hey MTA Community.I've tried to edit the Chatbubbles script so it shows messages from my custom global chat too, it shows the message in the bubble but the problem is the message doesnt stack on the other bubbles, i mean the normal chat bubbles Code: local selfVisible = true -- Want to see your own message? local messages = {} local globalmessages = {} local textures = {} local timeVisible = 13500 local distanceVisible = 50 local bubble = true -- Rounded rectangle(true) or not(false) function addBubble(text, player, tick) if (not messages[player]) then messages[player] = {} end local width = dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), 1, "default-bold") local _texture = dxCreateRoundedTexture(width+16,20,100) table.insert(messages[player], {["text"] = text, ["player"] = player, ["tick"] = tick, ["endTime"] = tick + 2000, ["alpha"] = 0, ["texture"] = _texture}) end function addGlobalBubble(text, player, tick) if (not globalmessages[player]) then globalmessages[player] = {} end local width = dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), 1, "default-bold") local _texture = dxCreateRoundedTexture(width+16,20,100) table.insert(globalmessages[player], {["text"] = text, ["player"] = player, ["tick"] = tick, ["endTime"] = tick + 2000, ["alpha"] = 0, ["texture"] = _texture}) end function removeBubble() table.remove(messages) end function removeGlobalBubble() table.remove(globalmessages) end local pi = math.pi function outElastic(t, b, c, d, a, p) if t == 0 then return b end t = t / d if t == 1 then return b + c end if not p then p = d * 0.3 end local s if not a or a < math.abs(c) then a = c s = p / 4 else s = p / (2 * pi) * math.asin(c/a) end return a * math.pow(2, -10 * t) * math.sin((t * d - s) * (2 * pi) / p) + c + b end addEventHandler("onClientRender", root, function() local tick = getTickCount() local x, y, z = getElementPosition(localPlayer) for _, pMessage in pairs(messages) do for i, v in ipairs(pMessage) do if isElement(v.player) then if tick-v.tick < timeVisible then local px, py, pz = getElementPosition(v.player) if getDistanceBetweenPoints3D(x, y, z, px, py, pz) < distanceVisible and isLineOfSightClear ( x, y, z, px, py, pz, true, not isPedInVehicle(v.player), false, true) then v.alpha = v.alpha < 200 and v.alpha + 5 or v.alpha local bx, by, bz = getPedBonePosition(v.player, 6) local sx, sy = getScreenFromWorldPosition(bx, by, bz) local elapsedTime = tick - v.tick local duration = v.endTime - v.tick local progress = elapsedTime / duration if sx and sy then if not v.yPos then v.yPos = sy end width = dxGetTextWidth(v.text:gsub("#%x%x%x%x%x%x", ""), 1, "default-bold") yPos = outElastic(elapsedTime, v.yPos, ( sy - 22*i ) - v.yPos, duration, 5) if bubble then dxDrawImage ( sx-width/2-10, yPos - 16, width+16, 20, v.texture, nil, nil, tocolor(0, 0, 0, v.alpha) ) else dxDrawRectangle(sx-width/2-10, yPos - 16, width+16, 20, tocolor(0, 0, 0, v.alpha)) end dxDrawText(v.text, sx-width/2-2, yPos - 14, width, 20, tocolor( 255, 255, 255, v.alpha+50), 1, "default-bold", "left", "top", false, false, false, true) end end else table.remove(messages[v.player], i) end else table.remove(messages[v.player], i) end end end end ) addEvent("onChatIncome", true) addEventHandler("onChatIncome", root, function(message, messagetype) if source ~= localPlayer then addBubble(message, source, getTickCount()) elseif selfVisible then addBubble(message, source, getTickCount()) end end ) function triggerIt(thePlayer,message) addGlobalBubble(message, thePlayer, getTickCount()) end addEvent("globalBubble",true) addEventHandler("globalBubble",root,triggerIt) addEventHandler("onClientRender", root, function() local tick = getTickCount() local x, y, z = getElementPosition(localPlayer) for _, pMessage in pairs(globalmessages) do for i, v in ipairs(pMessage) do if isElement(v.player) then if tick-v.tick < timeVisible then local px, py, pz = getElementPosition(v.player) if getDistanceBetweenPoints3D(x, y, z, px, py, pz) < distanceVisible and isLineOfSightClear ( x, y, z, px, py, pz, true, not isPedInVehicle(v.player), false, true) then v.alpha = v.alpha < 200 and v.alpha + 5 or v.alpha local bx, by, bz = getPedBonePosition(v.player, 6) local sx, sy = getScreenFromWorldPosition(bx, by, bz) local elapsedTime = tick - v.tick local duration = v.endTime - v.tick local progress = elapsedTime / duration if sx and sy then if not v.yPos then v.yPos = sy end local width = dxGetTextWidth(v.text:gsub("#%x%x%x%x%x%x", ""), 1, "default-bold") local yPos = outElastic(elapsedTime, v.yPos, ( sy - 22*i ) - v.yPos, duration, 5) if bubble then dxDrawImage ( sx-width/2-10, yPos - 16, width+16, 20, v.texture, nil, nil, tocolor(0, 0, 0, v.alpha) ) else dxDrawRectangle(sx-width/2-10, yPos - 16, width+16, 20, tocolor(0, 0, 0, v.alpha)) end dxDrawText(v.text, sx-width/2-2, yPos - 14, width, 20, tocolor( 191, 140, 236, v.alpha+50), 1, "default-bold", "left", "top", false, false, false, true) end end else table.remove(globalmessages[v.player], i) end else table.remove(globalmessages[v.player], i) end end end end )
-
Thank you guys, it works
-
Hey MTA Community, i was trying to make a rectangle which shows player health and it should decrease/increase slowly when u lose/earn health, but it only increases when the script starts Code: function updateStuff() theHealth = getElementHealth(localPlayer) end addEventHandler("onClientRender",root,updateStuff) local tick = getTickCount()/5 addEventHandler("onClientRender", root, function() local progress = ((getTickCount()/5 - tick)/1000) local cX, cY = interpolateBetween(0, 0, 0, 0, theHealth, 0, progress, "Linear") dxDrawRectangle(450, 0, 100 * 4, 30, tocolor(0,0,0,150)) dxDrawRectangle(450, 0, cY * 4, 30, tocolor(100,0,0,255)) end )
-
Balkan MTA zajednica (predlog) / Balkans MTA Community (sug)
Soapbosnia replied to .:DoA:.Backflip's topic in Balkan
Ovo je moj server IP: mtasa://145.239.38.24:27010 -
Ok,thanks man
-
Hi guys,i never tried this and idk what to use for this but,how do i make a image on the screen spin? Thanks.
-
Ok,@MrTasty @Mohamed Nightmare Thanks to both of you <3
-
Did what you told me,same debug error
-
I get this error in debug.Kill/Script.lua:12: attempt to call a number value Client: function dieHandler(p) addEventHandler ("onClientRender", getRootElement(), dieDx) setTimer(function() removeEventHandler("onClientRender",getRootElement(),dieDx) end,7000,1) end addEvent ("onType", true) addEventHandler ("onType", root, dieHandler) sWidth,sHeight = guiGetScreenSize() function dieDx () timer = setTimer(function() end, 7000, 1) remaining = getTimerDetails(timer) dxDrawText("You will be killed in #FFFFFF"..( math.floor(remaining/1000))" #640000seconds", sWidth(310/1024), sHeight(250/768), sWidth(1221/1280), sHeight(92/720), tocolor(100, 0, 0, 255), 1.5, "pricedown", "left", "top", false, false, true, true, false) end Server: addCommandHandler('killme', function(p) wlevel = getPlayerWantedLevel ( p ) if (wlevel == 0) then setTimer(killPed, 7000, 1, p) toggleAllControls ( p, false ) triggerClientEvent (p, "onType", p) setTimer ( toggleAllControls, 7000, 1, p, true ) end end )
-
@NeverUnbeatableOk thanks,il keep that in mind
-
[HELP]How do i draw a image in the freeroam panel
Soapbosnia replied to Soapbosnia's topic in Scripting
@LilDawageYou mean the text on top of the F1 Window ? The name is Freeroam Console -
[HELP]How do i draw a image in the freeroam panel
Soapbosnia replied to Soapbosnia's topic in Scripting
@LilDawageWhat do i need to put where it says F1 panel -
Hi guys,i got a question,how do i draw a image in the freeroam (F1) Panel ? Thanks
-
@Patrick2562Thank you so much bro it works <3
-
WARNING:Wasted/server.lua:5:Bad argument "addEventHandler" [Expected element at argument 2,got nil]. The code: function respawnOnWasted () spawnPlayer (source, 0, 0, 5, 0, math.random (0,288), 0, 0) end addEventHandler( "onPlayerWasted", thePlayer, function() bindKey ( player, "F", "both", respawnOnWasted ) end )
-
Hello mta community,today i edited my hud a bit,and now when i create a custom font my game freezes and crashes,but before that the text dissapears,Heres the part of the code: local zone = getZoneName (getElementPosition(getLocalPlayer())) myfont = dxCreateFont("medusagothic.ttf",15) dxDrawText(zone, sWidth*(-10/1024), sHeight*(725/768), tocolor(254, 254, 254, 255), myfont, "center", "top", false, false, true, true, false)
-
I did evrything u said bro,still all ports closed.Please help
-
Ok bro il try. And your pic Lmao xDDD
-
Here it is,Sorry for late reply
-
Im not using Wi Fi,Please help
-
Bro still all ports closed,please help
-
You mean change port 27015 to 27016?In the mtaserver.conf?And then port forward again with that port?
-
The ipv4 is same as it was,Please Help im begging you
-
Hello MTA Team,so i put my router to defaults and lost my port forward,now i port forwarded again but when i start my MTA Server console says that all ports are closed.Please help me i cant fix it its very annoying. Thank you
-
Thanks
