• Content count

  • Joined

  • Last visited

Community Reputation

13 Decent

1 Follower

About Awang

  • Rank


  • Location
  • Interests
    Lua, HTML5, CSS3, JQuery, PHP
  1. Coding for TimeLeft,

    local Timer = 12300 function timer setTimer(function() Timer = Timer-2300 outputChatBox("Time is:".. Timer) timer() end, 2300,1) end Thats what you can do with setTimer()
  2. Coding for TimeLeft,

    You should use setTimer(), set 5 minute to execute and make a recursive algorithm with an outside counter. If the counter reach the 12 value, it means you reach the 1 hour... And you can decrease your variable in each loop and write out into the chat...
  3. render 3D objects in window (dx)

    You may want like @Ren_712's object viewer can do... You should check the resource:
  4. Unlimited oxygen.

    I think it's a better way to cancel this damage, than use a client render for it... function stopDrown ( attacker, damage_type) if ( damage_type == 53 ) then -- if the damage type is drowning, check the wiki for more id cancelEvent() --cancel the event end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopDrown ) Always think about the client's cpu, when you use ClientRender...
  5. [Question]: fpslimit

    An other example for this: In a race server is a quite big problem the different fps... Like who have more fps will be faster than the others, thats why we fix the limit. I usually use 45-50...
  6. Editing client scripts for hack?

    Instead of using Luac, you could delete the file, when it's starting to run from the harddrive, because it's already loaded into the memory... I say this, because there are some guy, who can encrypt your luac file...
  7. Smooth moving health bar

    local dx_healt = getElementHealth(localPlayer) local healt = getElementHealth(localPlayer) function setHealth(_type,_value) if _value >= 5 then if _type == "add" then dx_healt = dx_healt + 5 else dx_healt = dx_healt - 5 end setTimer(function() setHealth(_type,_value-5) end,500,1) elseif _value > 0 then if _type == "add" then dx_healt = dx_healt + _value else dx_healt = dx_healt - _value end end end function healthChecker() if getElementHealth(localPlayer) < healt then setHealth("add",healt-getElementHealth(localPlayer)) elseif getElementHealth(localPlayer) > healt then setHealth("loss",getElementHealth(localPlayer)-healt) end setTimer(function() healthChecker() end,500,1) end addEventHandler("onClientResourceStart",resourceRoot,function() healthChecker() end) Now you can use dx_health variable to draw the animated health for your bar... I used recursive timer instead of "onClientPlayerDamege" because you can detect if the player get an HP and animate the bar filling up... you can change the animation speed and rate by change the Timer milisecond value and the "dx_healt = dx_healt + 5" or "dx_healt = dx_healt - 5" number parameter... Otherway, you should think about what if the player get other damage, while the animation still in progress... Code not tested, maybe you need to correct it...
  8. You can split the string with the basic Lua function, call string.sub(). If I were you, I store the colored name in an elementData, and if the localPlayer set able to see the colors, I used the strings from the elementData, otherway the strings from getPlayerName() function. And if there is a colorcoded nickname, you can use this: function removeHex( s ) return s:gsub( '#%x%x%x%x%x%x', '' ) or s end
  9. I see... Then you need to split the characters which you want to be colored and go ahead with hexameter colors. For the nametag, you should do a trick with the getScreenFromWorldPosition() wich can help you to calculate screen position from World postion and make a feel that is in the 3D world, but actually, its not....
  10. You can use Hexameter colorcodes in the string, for example: dxDrawBorderedText("#F44242@#FFFFFF"..getPlayerName(player), x - w / 2 + 35, y - h + 6, w, h, tocolor(255,255,255,255), scale, font, "left", "top", false, false, false, true, false) For the automatically change you can use a string variable to store the actually color code for the changing part: local colorcode = "#F44242" dxDrawBorderedText(colorcode.."@#FFFFFF"..getPlayerName(player), x - w / 2 + 35, y - h + 6, w, h, tocolor(255,255,255,255), scale, font, "left", "top", false, false, false, true, false) And by change the value of 'colorcode' variable, you can do, want you want...
  11. What will affect performance the most?

    With these instructions, I think, if you calculate in client side, you should only calculate peds, which are in the streamed zone. Use an if branching with isElementStreamedIn(), or if you really want to reduce the peds table, you should use "onClientElementStreamedIn" and "onClientElementStreamedOut" events and a table, where you push and remove the peds. Good to know, that if you restart the resource while you have peds already in the srteamed zone, they will not trigger this event, so you need to loop peds table with getElementsByType("ped",root,true), where the last param choose you only the streamed peds, then you can add to the table. Anyway, making AIs in Mta is very interesting, have a good luck with this!
  12. onClientPlayerQuit is not working!

    Because this event can't use detect if the player quit and this player is himself... This event can use to detect other clients quite in client side... With onClientResourceStop () you can do it, if you want to push the local data to serverside, in this case: --- Client side items = {1,2} function saveItems() triggerServerEvent ("listItems", localPlayer, items) end addEventHandler ("onClientResourceStop", resourceRoot, saveItems) Serverside should be good, but I have doubt about get the player name... Anyway, you can read all of these usefull advice in wiki, It's good to use it... You can read also great examples and I'ts always uptodate.
  13. Teams and markers

    Or in clientside: addEventHandler("onClientMarkerHit",theMarker,function(hitPlayer, matchingDimension) if matchingDimension and hitPlayer == localPlayer then if getPlayerTeam(localPlayer) == team1 then outputChatbox("You are in team 1") elseif getPlayerTeam(localPlayer) == team2 then outputChatbox("You are in team 2") elseif getPlayerTeam(localPlayer) == false then outputChatbox("You are not member of any team") end end end)
  14. [Question] Reduce the damage

    You shuld check this by matematically... For example, the loss is 10, 10/50 will not the 50% of 10.... if you really want to do with percent parameter, you need to use like this: local reductionPercent = 50 addEventHandler('onClientPlayerDamage',root,function(attacker,weapon,bodypart,loss) if loss then local health = getElementHealth(localplayer) setElementHealth(localplayer,health+(loss*(reductionPercent/100)) end end) Still I think, cancel the root damage and recalculate it will be the simpliest way to understand how this event work... Even the question was reduce the damage for a specific player, not for everbody... With elementData you can change it real time in the server, like an admin can take this ability or give it to a player by using setElementData()
  15. [Question] Reduce the damage

    Or if you add a specific elementData, you can write something like this: addEventHandler("onClientPlayerDamage",root,function(attacker, weapon, bodypart,loss) if source == localPlayer and getElementData(localPlayer,"less.damage") == true then cancelEvent() setElementHealt(localPlayer,getElementHealt(localPlayer)-loss*0.8) end end) For the player, who have the elementData will only get the 80% of the real damage.