Jump to content

mouamle

Members
  • Posts

    303
  • Joined

  • Last visited

Everything posted by mouamle

  1. سويت فنكشنات بسيطه ( لا لحظة مو بسيطه ;-; ) ألمهم dxFrame, dxButton أني مبرمج جافا قبل كوني مبرمج Lua ما علينا نرجع للموضوع Frame function --[[ createFrame( x - أحداثي x للأطار y - أحداثي y للأطار w - عرض الأطار h - أرتفاع الأطار Title - عنوان الأطار Color - لون الأطار TitleBarColor - لون شريط العنوان ) ]] function createFrame( x, y, w, h, Title, Color, TitleBarColor ) MFrame = { x = 0, y = 0, w = 400, h = 250, Title = "Frame", Color = tocolor( 120, 120, 120, 150 ), Color = tocolor( 120, 120, 120, 255 ), components = { }, render = function () dxDrawRectangle( x, y, w, h, Color, false) dxDrawRectangle( x, y, w, 15, TitleBarColor, false) dxDrawText( Title, x + 5, y ) for k,v in pairs(MFrame.components) do v.render(); end end, add = function ( comp ) comp.setOfset(x, y) table.insert(MFrame.components, comp); end } function create() MFrame.x = x; MFrame.y = y; MFrame.w = w; MFrame.h = h; MFrame.Title = Title; MFrame.Color = Color; MFrame.TitleBarColor = TitleBarColor; return MFrame; end return create(); end Button function --[[ createButton( x - أحداثي x للزر y - أحداثي y للزر w - عرض الزر h - أرتفاع الزر text - النص اللي يضهر داخله Color - لون مربع الزر textColor - لون النص ) ]] function createButton( x, y, w, h, text, Color, textColor ) xOfset = 0; yOfset = 0; isVisableX = true; local MButton = { x = 0, y = 0, w = 80, h = 20, text = "Button", isVisable = isVisableX, textColor = tocolor( 236, 240, 241, 255 ), Color = tocolor( 231, 76, 60, 150 ), render = function () if ( isVisableX == true ) then dxDrawRectangle( x + xOfset, y + yOfset, w, h, Color ) dxDrawText( text, ( (x + xOfset) + (w/2) ) - (string.len(text)*3), ((y + yOfset) - 7) + (h/2) ) end end, setVisable = function ( visable ) isVisableX = visable; end, setTextColor = function ( color ) textColor = color; end, setTextColorRGBA = function ( r, g, b, a ) textColor = tocolor( r, g, b, a ) end, getText = function ( ) return text; end, setText = function ( text2 ) text = text2; end, setColor = function ( Color2 ) Color = Color2; end, setColorRGBA = function ( r, g, b, a ) Color = tocolor( r, g, b, a ) end, setOfset = function ( ofx, ofy ) xOfset = ofx; yOfset = ofy; end, setX = function (x2) x = x2 end, getX = function () return x; end, setY = function (y2) y = y2 end, getY = function () return y; end, setW = function (w2) w = w2 end, getW = function () return w; end, setH = function (h2) h = h2 end, getH = function () return h; end } local create = function () MButton.x = x; MButton.y = y; MButton.w = w; MButton.h = h; MButton.text = text; MButton.Color = Color; MButton.textColor = textColor; return MButton; end return create() end من تسوي زر راح تتوفر عندك الفنكشنات التاليه render() -- ما راح تحتاجها أصلاً setX(newX) -- تغيير أحداثي x للزر setText(newText) -- تغيير النص setOfset(xOfset, yOfset) -- في الأغلب ما راح تحتاجها بس مجرد تغير احداثيات ال x,y اللي راح يبدأ منها الزر ( ما اتوقع وصلتها صح ) setTextColorRGBA(r, g, b, a) -- تغيير لون النص getH() -- ترجع قيمة ارتفاع الزر setH(newHeight) -- تغيير ارتفاع الزر setVisable(visable) -- أضهار الزر وأخفائه setColor(Color) -- تغيير لون الزر setW(newWidth) -- تغيير عرض الزر getY() -- ترجع y للزر setY(newY) -- تغيير قيمة y للزر setColorRGBA(r, g, b, a) -- تغيير لون الزر getX() -- ترجع x للزر getW() -- ترجع عرض الزر setTextColor(Color) -- تغيير لون النص getText() -- ترجع النص داخل الزر وبالنسبه للأطار عندك هذي الفنكشنات render() -- ما راح تحتاجها add(component) -- أضافة العنصر كـ الزر أو بقية العناصر اللي راح اسويها مستقبلاً : ) طريقة الأستعمال local Frame; -- نسوي متغير أساسي للأطار local b1; -- ومتغير للزر function renderer ( ) Frame.render(); -- عرض الأطار end function init() ButtonColor = tocolor( 231, 76, 60, 255 ) -- نسوي متغير يعبر عن اللون textColor = tocolor( 236, 240, 241, 255 ) -- متغير ثاني يعبر عن لون الخط b1 = createButton( 10, 20, 80, 40, "Test Test", color, textColor ) -- أنشاء الزر FrameColor = tocolor( 231, 76, 60, 120 ) -- نسوي لون للأطار Frame = createFrame( 400, 400, 450, 250, "Frame", color, color ); -- أنشاء الأطار Frame.add(b1) -- أضافة الزر الى الأطار addEventHandler ( "onClientRender", root, renderer ) end addEventHandler ( "onClientResourceStart", resourceRoot, init ) الناتج أذا عندك أي استفسار أكدر اجاوبك
  2. شوف قائمة التشغيل هذي تفيدك
  3. mouamle

    OOP ?

    طلب شرح مو كود على العموم شكرا <3
  4. mouamle

    OOP ?

    ألسلام عليكم أستفسار حول OOP أو Object Orientated Programming in MTA ممكن أحد يعطينه مقدمه بسيطه عنها ؟ وشكرا
  5. البيد عندة rotation وحدة وهيه ال Z صح ؟ ال rx, ry وش راح يكون ال return حقهم ؟
  6. محتاج مساعدة لما اللاعب يدخل للسيرفر يودية لمكان محدد واذا بالسيرفر اكثر من 5 ينقل اللاعب لغير مكان واذا بالسيرفر اكثر من 10 ينقلة لغير مكان حاولت وهذا اجة وياية Spawns = { {2487.6459960938, -1667.2342529297, 14}, {2473.6359863281, -1682.9650878906, 14} } function greetPlayer ( thePlayer ) local Count = getPlayerCount( ) if ( Count >= 0 ) then for k, v in pairs(Spawns) do setElementPosition( thePlayer, v[1], v[2], v[3], false ) end end end addEventHandler ( "onPlayerJoin", getRootElement(), greetPlayer, thePlayer )
  7. السلام عليكم فنكشن setPedWalkingStyle setPedWalkingStyle اذا حطيتها كلنت اللاعب اللي راح تتطبق علية وحدة يشوفها بس اذا حطيتها سيرفر كل اللاعبين راح يشوفونها ؟ صح ؟
  8. حاول -- Events onClientGUIClick onClientMouseEnter onClientMouseLeave -- functions Client side guiCreateStaticImage() guiSetAlpha()
  9. جرب واحنة نساعدك -- Server Side setTimer() givePlayerMoney()
  10. يعني فارغ أو لا شيء أو هيه القيمة الأفتراضية ( الأساسية ) لأي متغير يعني مثلا print(x) -- > nil راح يطلعلك nil لأن أي متغير بلغة Lua قيمتة nil رد Mr.Tn6eL مختصر ومفيد بس حبيت افهمك كيف صارت nil
  11. ليه مسوي ترايقر ؟ لأن addEvent( "CarCreated", true ) addEventHandler( "CarCreated", getRootElement( ), function( Car1 ) destroyElement(weapon) theVehicle = getPedOccupiedVehicle(getLocalPlayer( )) outputChatBox( "تم اعطائك همر بنجاح", 102, 255, 0 ) weapon = createWeapon("minigun", x, y, z ) setWeaponClipAmmo(weapon, 99999) setWeaponProperty(weapon, "fire_rotation", 0, 0, 0) x1, y1, z1 = getElementPosition( theVehicle ) attachElements( weapon, Car1, 0, 1.8, 0, 0, 0, 90 ) bindKey ( "mouse1", "up", function() setWeaponState ( weapon, "ready" ) end ) bindKey ( "mouse1", "down", function() setWeaponState ( weapon, "firing" ) end ) end )
  12. مشكور حليتها واذا تبي الاكواد سيرفر addEvent( "SpawnCar", true ) addEventHandler( "SpawnCar", getRootElement( ), function(x2, y2, z2, DaPlayer) if ( isElement(Car1) ) then destroyElement(Car1) end Car1 = createVehicle ( 470, x2, y2, z2 + 10 ) PEDX = warpPedIntoVehicle( DaPlayer, Car1, 0 ) setVehicleDamageProof( Car1, true ) if ( PEDX ) then triggerClientEvent( "CarCreated", getRootElement( ), Car1) end end ) كلنت addCommandHandler( "همر", function() x2, y2, z2 = getElementPosition( getLocalPlayer() ) DaPlayer = getLocalPlayer( ) triggerServerEvent( "SpawnCar", getRootElement( ), x2, y2, z2, DaPlayer ) end )
  13. ابي لما اللاعب ياخذ سيارة وينزل منها ويروح ياخذ سيارة ثانية تنمسح السيارة الأولى ال trigger صحيح مسوية بس المشكلة بالسيارة
  14. السلام عليكم ذا الكود -- Client Side addEvent( "CarCreated", true ) addEventHandler( "CarCreated", getRootElement( ), function( Car[source] ) end ) addEvent( "SpawnCar", true ) addEventHandler( "SpawnCar", getRootElement( ), function(x2, y2, z2, DaPlayer) if ( isElement(Car[source]) ) then destroyElement(Car[source]) end Car[source] = createVehicle ( 470, x2, y2, z2 + 10 ) PEDX = warpPedIntoVehicle( DaPlayer, Car[source], 0 ) setVehicleDamageProof( Car[source], true ) if ( PEDX ) then triggerClientEvent( "CarCreated", getRootElement( ), Car[source]) end end ) كل شي تمام بس لما اشغل المود 12 ')' expected near '[' وين المشكلة ؟
  15. شكرا بس جربت يصير السلاح على جانب اللاعب ما يجي امام اللاعب Edit: صارت شكرا
  16. السلام عليكم ذي الفنكشن createWeapon https://wiki.multitheftauto.com/wiki/CreateWeapon تسوي سلاح حاولت بذا الكود اسوي السلاح يجي مع اللاعب addEventHandler( "onClientRender", getRootElement( ), function() x, y, z = getElementPosition( getLocalPlayer() ) end ) function createMinigunWeapon() x, y, z = getElementPosition( getLocalPlayer() ) weapon = createWeapon("minigun", x, y, z + 3 ) setWeaponClipAmmo(weapon, 99999) setWeaponState(weapon, "firing") setWeaponProperty(weapon, "fire_rotation", 0, -30, 0) end بس في طريقة اخلي السلاح يدور مع زاوية دوران اللاعب ؟ جربت getElementRotation ما نجحت
  17. شكرا راحا اخليها لما يكون ال Rotation > 90 ما تنفجر يغلق
  18. السلام عليكم في طريقة اخلي السيارة ما تنفجر من تنقلب ؟
  19. شكرا تمت الأفادة يغلق
  20. السلام عليكم عندي جدول فية ايديات السيارات مثلا local CarsTable = {411, 421, 320 } -- الارقام مجرد امثلة المهم وش هيه الفنكشنات الي احتاجها حتى اخلي ال loop يرتبهم بال Gridlist ?
  21. جرب هذا ما اتذكر من وين نسختة بس المهم يشتغل function renderIng( ) local x, y, z = getCameraMatrix( ) local dimension = getElementDimension( localPlayer ) for key, marker in ipairs ( getElementsByType( "marker", resourceRoot ) ) do if getElementDimension( marker ) == dimension then local px, py, pz = getElementPosition( marker ) local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z ) if distance <= 50 then local text = getElementData( marker, "message" ) if text and ( distance < 3 or isLineOfSightClear( x, y, z, px, py, pz + 1.7, true, true, true, true, false, false, true, localPlayer ) ) then local sx, sy = getScreenFromWorldPosition( px, py, pz + 1.7 ) if sx and sy then local w = dxGetTextWidth( tostring( text ) ) local h = ( text and 3 or 1 ) * dxGetFontHeight( ) dxDrawText( tostring( text ), sx, sy, sx, sy, tocolor( 255, 255, 255, 255 ), 4, "Tahoma", "center", "center" ) end end end end end end addEventHandler( "onClientRender", getRootElement( ),renderIng) Marker = createMarker ( x, y, z, "cylinder", s, r, g, b, a ) setElementData(Marker,"message","الكتابة")
×
×
  • Create New...