Advertisement
Mouamle

شرح كود عداد السرعة

Jun 1st, 2015
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.92 KB | None | 0 0
  1. addEventHandler("onClientResourceStart", resourceRoot,
  2.     function()
  3.             outputChatBox("Speed Meter By Mouamle Hassan")
  4.     end
  5. )
  6.  
  7.  
  8. -- جدول لل Label --
  9. GUIEditor = {
  10.     label = {}
  11. }
  12. -- جدول لل Label --
  13.  
  14.  
  15. -- لوحة اعدادات العداد --
  16. addEventHandler("onClientResourceStart", resourceRoot,
  17.     function()
  18.         local screenWidth, screenHeight = guiGetScreenSize() -- ياخذ احداثيات الشاشة مال اللاعب
  19.         local windowWidth, windowHeight = 157, 234 -- الطول والعرض للوحة مال اعدادات
  20.         local left = screenWidth/2 - windowWidth/2 -- يخلي اللوحة بالنص من جهة اليمين الى اليسار
  21.         local top = screenHeight/2 - windowHeight/2 -- يخلي اللوحة بالنص من فوق الى اعلا
  22.    
  23.  
  24.  
  25.         Main = guiCreateWindow(left, top, windowWidth, windowHeight, "{I.Q} Lions", false) -- يسوي نافذة (لوحة) الأعدادات
  26.         guiWindowSetSizable(Main, false) -- يخلي اللاعب ما يكدر يغير حجمها
  27.  
  28.         Exit = guiCreateButton(10, 196, 137, 28, "اغلاق", false, Main) -- يسوي زر اسمة اغلاق
  29.         GUIEditor.label[1] = guiCreateLabel(42, 119, 105, 16, "أقصى سرعة للأنذار", false, Main) -- يسوي ليبل
  30.         FullSpeed = guiCreateEdit(10, 135, 137, 17, "150", false, Main) -- يسوي صندوق نص حتى تحط بي السرعة القصوى لأشتغال الأنذار
  31.         XSpeed = guiCreateCheckBox(9, 24, 138, 16, "صوت اجتياز السرعة", true, false, Main) -- يسوي زر تحقق للتشغيل صوت عند عبور السرعة القصوى
  32.         XHealth = guiCreateCheckBox(9, 50, 138, 16, "صوت احتراق السيارة", true, false, Main) --  يسوي زر تحقق لتشغيل صوت عند احتراق السيارة
  33.         GUIEditor.label[2] = guiCreateLabel(14, 76, 28, 15, "BY:", false, Main) -- يسوي ليبل ثانية
  34.         GUIEditor.label[3] = guiCreateLabel(38, 77, 90, 14, "Mr.Mouamle", false, Main) -- يسوي ليبل ثالثة
  35.         guiSetVisible( Main, false ) -- يخلي اللوحة ما تطلع اول ما يشتغل المود او يطب اللاعب للسيرفر  
  36.     end
  37. )
  38. -- لوحة اعدادات العداد --
  39.  
  40.  
  41.  
  42. -- هذي الفنكشن تخلي اللوحة تطلع وتختفي بزر راج نسوية جوة --
  43.  
  44. function GuiShow ( ) -- فنكشن الي تطلع لوحة التحكم وتخفيها
  45.         if ( guiGetVisible ( Main ) == false ) then  -- يتحقق اذا جانت اللوحة ما موجودة          
  46.                 guiSetVisible( Main, true ) -- يفتح اللوحة
  47.                 showCursor( true ) -- يطلع الماوس
  48.         else -- اذا اللوحة موجودة اصلا
  49.                 guiSetVisible( Main, false ) -- يخفيها
  50.                 showCursor(false) -- ويخفي الماوس
  51.         end
  52. end
  53.  
  54. -- هذي الفنكشن تخلي اللوحة تطلع وتختفي بزر راج نسوية جوة --
  55.  
  56. bindKey ( "F9", "down", GuiShow ) -- ينادي فنكشن الي تخفي وتطلع اللوحة
  57.  
  58.  
  59. addEventHandler( "onClientGUIClick", root,  -- حدث لمن اللاعب يدوس على دكمة من اللوحة
  60.     function (  ) -- فنكشن
  61.         if ( source == Exit ) then -- يتحقق اذا اللاعب داس دكمة اسمها Exit
  62.             guiSetVisible( Main, false ) -- يخفي اللوحة مال اعدادات    
  63.             showCursor(false) -- يخفي الماوس
  64.         end -- ايند لل أف
  65.      end -- اند للفنكشن
  66. )-- قوس اغلاق الحدث
  67.  
  68.  
  69.  
  70.  
  71. -- هذا اكثر شي تعبت علية وهو الي يخلي العداد يشتغل وية كل الشاشات ويطلع الصوت ويغير لون السرعة بكل مستوى  --
  72. function Speed()  
  73.         Red = 255
  74.         Green = 255
  75.         Blue = 255
  76.  
  77.         mred = 255
  78.         mgreen = 255
  79.         mblue = 255
  80.  
  81.     speedx, speedy, speedz = getElementVelocity(getPedOccupiedVehicle(getLocalPlayer()))
  82.  
  83.     actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
  84.  
  85.     kmh = actualspeed * 180
  86.  
  87.     mph = actualspeed * 111.847
  88.  
  89.         CarHealth = getElementHealth(getPedOccupiedVehicle(getLocalPlayer()))
  90.  
  91.     H = CarHealth / 10
  92.  
  93.     guix, guiz = guiGetScreenSize(  )
  94.  
  95.         if ( H  >= 75 ) then
  96.             Red = 0
  97.             Green = 255
  98.             Blue = 0
  99.         elseif ( H >= 50 ) then
  100.             Red = 255
  101.             Green = 255
  102.             Blue = 0       
  103.         elseif ( H >= 25 ) then
  104.             Red = 211
  105.             Green = 84
  106.             Blue = 0  
  107.         elseif ( H >= 0 ) then
  108.             Red = 255
  109.             Green = 0
  110.             Blue = 0
  111.  
  112.             if ( guiCheckBoxGetSelected( XHealth )) then
  113.                 local sound = playSound("Bleep.mp3")
  114.                 setSoundVolume(sound, 1)
  115.             end
  116.         end
  117.  
  118.            
  119.         NumberX = guiGetText( FullSpeed )
  120.  
  121.         if ( math.floor(kmh) >=  tonumber(NumberX)) then
  122.  
  123.             if ( guiCheckBoxGetSelected ( XSpeed ) ) then
  124.                 local sound = playSound("Beep.mp3")
  125.                 setSoundVolume(sound, 0.5)
  126.             end
  127.             mred = 255
  128.             mgreen = 0
  129.             mblue = 0
  130.         elseif ( math.floor(kmh) >= 100 ) then
  131.             mred = 255
  132.             mgreen = 255
  133.             mblue = 0
  134.         elseif ( math.floor(kmh) >= 50 ) then
  135.             mred = 221
  136.             mgreen = 84
  137.             mblue = 0
  138.         elseif ( math.floor(kmh) >= 0 ) then
  139.             mred = 0
  140.             mgreen = 255
  141.             mblue = 0
  142.         end
  143.  
  144.  
  145.  
  146.     if ( guix == 1366 ) and ( guiz == 768 ) then
  147.         dxDrawRectangle(1185, 664, 175, 103, tocolor(0, 0, 0, 90), false)
  148.         dxDrawText("Kmh: " .. math.floor(kmh), 1195, 677, 1334, 704, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  149.         dxDrawText("Mph: " .. math.floor(mph), 1195, 714, 1334, 741, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  150.         dxDrawText("Health: " .. math.floor(H), 1195, 751, 1249, 767, tocolor(Red, Green, Blue, 255), 1.00, "default", "left", "top", false, false, false, false, false)
  151.     elseif ( guix == 1360 ) and ( guiz == 768 ) then
  152.         dxDrawRectangle(1185, 664, 175, 103, tocolor(0, 0, 0, 90), false)
  153.         dxDrawText("Kmh: " .. math.floor(kmh), 1195, 677, 1334, 704, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  154.         dxDrawText("Mph: " .. math.floor(mph), 1195, 714, 1334, 741, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  155.         dxDrawText("Health: " .. math.floor(H), 1195, 751, 1249, 767, tocolor(Red, Green, Blue, 255), 1.00, "default", "left", "top", false, false, false, false, false)
  156.     elseif ( guix == 1280 ) and ( guiz == 768 ) then
  157.         dxDrawRectangle(1105, 664, 175, 103, tocolor(0, 0, 0, 90), false)
  158.         dxDrawText("Kmh: " .. math.floor(kmh), 1115, 677, 1254, 704, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  159.         dxDrawText("Mph: " .. math.floor(mph), 1115, 714, 1254, 741, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  160.         dxDrawText("Health: " .. math.floor(H), 1115, 751, 1169, 767, tocolor(Red, Green, Blue, 255), 1.00, "default", "left", "top", false, false, false, false, false)
  161.     elseif ( guix == 1280 ) and ( guiz == 720 ) then
  162.         dxDrawRectangle(1105, 617, 175, 103, tocolor(0, 0, 0, 90), false)
  163.         dxDrawText("Kmh: " .. math.floor(kmh), 1115, 627, 1254, 654, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  164.         dxDrawText("Mph: "  .. math.floor(mph), 1115, 664, 1254, 691, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  165.         dxDrawText("Health: " .. math.floor(H), 1115, 701, 1169, 717, tocolor(Red, Green, Blue, 255), 1.00, "default", "left", "top", false, false, false, false, false)
  166.     elseif ( guix == 1280 ) and ( guiz == 600 ) then
  167.         dxDrawRectangle(1105, 497, 175, 103, tocolor(0, 0, 0, 90), false)
  168.         dxDrawText("Kmh: " .. math.floor(kmh), 1115, 507, 1254, 534, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  169.         dxDrawText("Mph: " .. math.floor(mph), 1115, 544, 1254, 571, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  170.         dxDrawText("Health: " .. math.floor(H), 1115, 581, 1169, 597, tocolor(Red, Green, Blue, 255), 1.00, "default", "left", "top", false, false, false, false, false)   
  171.     elseif (guix == 1024 ) and ( guiz == 768 ) then
  172.         dxDrawRectangle(849, 665, 175, 103, tocolor(0, 0, 0, 90), false)
  173.         dxDrawText("Kmh: " .. math.floor(kmh), 859, 675, 998, 702, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  174.         dxDrawText("Mph: " .. math.floor(mph), 859, 712, 998, 739, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  175.         dxDrawText("Health: " .. math.floor(H), 859, 749, 913, 765, tocolor(Red, Green, Blue, 255), 1.00, "default", "left", "top", false, false, false, false, false)    
  176.     elseif ( guix == 800 ) and ( guiz == 600 ) then
  177.         dxDrawRectangle(625, 497, 175, 103, tocolor(0, 0, 0, 90), false)
  178.         dxDrawText("Kmh: " .. math.floor(kmh), 635, 507, 774, 534, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  179.         dxDrawText("Mph: " .. math.floor(mph), 635, 544, 774, 571, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  180.         dxDrawText("Health: " .. math.floor(H), 635, 581, 689, 597, tocolor(Red, Green, Blue, 255), 1.00, "default", "left", "top", false, false, false, false, false)
  181.     else
  182.         dxDrawRectangle(1185, 664, 175, 103, tocolor(0, 0, 0, 90), false)
  183.         dxDrawText("Kmh: " .. math.floor(kmh), 1195, 677, 1334, 704, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  184.         dxDrawText("Mph: " .. math.floor(mph), 1195, 714, 1334, 741, tocolor(mred, mgreen, mblue, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
  185.         dxDrawText("Health: " .. math.floor(H), 1195, 751, 1249, 767, tocolor(Red, Green, Blue, 255), 1.00, "default", "left", "top", false, false, false, false, false)
  186.     end
  187.  
  188. end
  189. -- هذا اكثر شي تعبت علية وهو الي يخلي العداد يشتغل وية كل الشاشات ويطلع الصوت ويغير لون السرعة بكل مستوى  --
  190.  
  191.  
  192.  
  193. addEventHandler( "onClientPlayerVehicleEnter", root,  -- حدث لمن اللاعب يدخل بالسيارة يطلعلة العداد --
  194.         function() -- فنكشن
  195.                 CarHealth = getElementHealth(getPedOccupiedVehicle(getLocalPlayer())) -- يجيب دم السيارة
  196.             addEventHandler("onClientRender", root, Speed) -- يطلع العداد
  197.         end
  198.  )
  199.  
  200.  
  201.  
  202.  
  203. addEventHandler( "onClientPlayerVehicleExit", root,  -- حدث لمن اللاعب يطلع من السيارة
  204.         function() -- فنكشن
  205.             removeEventHandler("onClientRender", root, Speed) -- يخفي العداد
  206.         end
  207.  )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement