Jump to content

مساعده بكود عقارات


Recommended Posts

سلام عليكم ورحمة الله وبركاته معليش على الازعاج الدائم شباب اليوم عندي استفسار وهو حبيت اسوي مود عقارات

لمود البيوت المنشور

طبعا الكل

يعرفه اتوقع

فيا ليت تفيدوني وش استخدم في الاكواد اللي بصنعها لو تقدرو

Link to comment
7 minutes ago, [6ArH]#~Ecoo~ said:

setElementData -- سوي عالبيوت الغير مباعة داتا 

getElementData -- جيب البيوت الغير مباعة بالقريد ليست
 

 

طيب وكيف اجلب البيوت الغير مباعه من الجدول؟

 

السكل

وكيف اجيب احداثياتها ارجو وضع اجابه اوضح شوي لو تقدر

Edited by Master_MTA
Link to comment
3 hours ago, [6ArH]#~Ecoo~ said:

setElementData -- سوي عالبيوت الغير مباعة داتا 

getElementData -- جيب البيوت الغير مباعة بالقريد ليست
 

 

 

ما يصلح داتا للحفظ فـ نظام عقارات, لأنها راح تروح كل مرة يصير ريستارت للمود

لذلك لازم قواعد بيانات 

Link to comment

اذا سويت داتا 

طيب مود البيوت يحفظ علي قاعد البيانات

اذا سويت ريستارت لمود البيوت + مود للعقارات

كل اللي في الجريد ليست بيروح + البيوت الغير مباعة بتفضل  

Link to comment
16 minutes ago, MR.NaiF-MTA said:

اذا سويت داتا 

طيب مود البيوت يحفظ علي قاعد البيانات

اذا سويت ريستارت لمود البيوت + مود للعقارات

كل اللي في الجريد ليست بيروح + البيوت الغير مباعة بتفضل  

مود البيوت يستخدم الداتا 

اتوقع اسمه كذا createHouse فيه فنكشن

هذا اذا انضاف بيت جديد او تشغل السكربت راح يسوي داتا على البيوت المباعة وتكون قيمتها معلومات مثل المالك والباسوورد

يعني ماراح يواجه مشكلة بالناحيه هذي , بس صعبة عليه يعدل وتوه مبتدأ 

Link to comment
14 hours ago, MR.NaiF-MTA said:

اذا سويت داتا 

طيب مود البيوت يحفظ علي قاعد البيانات

اذا سويت ريستارت لمود البيوت + مود للعقارات

كل اللي في الجريد ليست بيروح + البيوت الغير مباعة بتفضل  

طيب اخوي هل تنصحني اربطها بالخادم حقي phpmyadmin

ولكن انا ما اعرف شي بالبرمجه الخاصه ب phpmyadmin

#Edit:

14 hours ago, Abdul KariM said:

مود البيوت يستخدم الداتا 

اتوقع اسمه كذا createHouse فيه فنكشن

هذا اذا انضاف بيت جديد او تشغل السكربت راح يسوي داتا على البيوت المباعة وتكون قيمتها معلومات مثل المالك والباسوورد

يعني ماراح يواجه مشكلة بالناحيه هذي , بس صعبة عليه يعدل وتوه مبتدأ 

طيب اخوي كيف تنصحني اسوي

Link to comment
2 minutes ago, 3NAD said:

وش تقصد بالعقارات ؟

ايش تبيه يصير؟

 اخي ابي البيوت الغير مباعه تظهر في جريد ليست وجمبها احداثياتها وفي الاخر الاونر

حق البيت

Edited by Master_MTA
Link to comment
4 minutes ago, 3NAD said:

اطرح المود + اكواد الجريد لست اللي تبيه يظهر فيه

اخي اطرح كل اكواد المود ؟ كلنت وسيرفر؟

 

تفضل اكواد اللوحه اخوي

 


        wnd = guiCreateWindow(382, 139, 551, 436, "العقارات", false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        grid12 = guiCreateGridList(59, 31, 450, 248, false, wnd)
        guiGridListAddColumn(grid12, "ID", 0.2)
        guiGridListAddColumn(grid12, "House", 0.2)
        guiGridListAddColumn(grid12, "X,Y,Z", 0.2)
        guiGridListAddColumn(grid12, "Owner", 0.2)
        btn1 = guiCreateButton(36, 323, 192, 72, "انتقل", false, wnd)
        btn2 = guiCreateButton(327, 323, 192, 72, "اغلاق", false, wnd)    
   

---------------------------------------------

اما بالنسبه للمود حق البيوت تفضل اخي

 

 

 

 

---------------------------------------------

 

 

client

outputChatBox("تم تشغيل مود شراء البيوت|لرؤية أماكن البيوت اضغط حرف خ[o]",255,0,0,true)

local me       = getLocalPlayer();
local scX, scY = guiGetScreenSize();

local hc_gui   = {}; --house construction
local hc_edit  = {}; --edit fields
local hm_gui   = {}; --management

addEventHandler( 'onClientResourceStart', resourceRoot, function()
  hc_gui['main'] = guiCreateWindow( scX-310, scY/2-450/2, 300, 450, 'House creating', false );
  guiSetAlpha( hc_gui['main'], 1.0 );
  --Entrance--
  hc_gui['label_ec'] = guiCreateLabel( 0.042, 0.05, 0.4, 0.1, 'الاحداثيات بجانب الباب', true, hc_gui['main'] );
  guiLabelSetHorizontalAlign( hc_gui['label_ec'], 'center', true );
  hc_edit['edit_ec_X'] = guiCreateEdit( 0.063, 0.15, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_ec_Y'] = guiCreateEdit( 0.063, 0.22, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_ec_Z'] = guiCreateEdit( 0.063, 0.29, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_gui['btn_ecPick'] = guiCreateButton( 0.063, 0.36, 0.39, 0.06, 'وضع الاحدثيات', true, hc_gui['main'] ); --1
  
  --Entrance teleport--
  hc_gui['label_etc'] = guiCreateLabel( 0.009, 0.45, 0.5, 0.1, 'الاحداثيا داخل البيت', true, hc_gui['main'] );
  guiLabelSetHorizontalAlign( hc_gui['label_etc'], 'center', true );
  hc_edit['edit_etc_X'] = guiCreateEdit( 0.063, 0.55, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_etc_Y'] = guiCreateEdit( 0.063, 0.62, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_etc_Z'] = guiCreateEdit( 0.063, 0.69, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_gui['btn_etcPick'] = guiCreateButton( 0.063, 0.76, 0.39, 0.06, 'وضع الاحداثيات', true, hc_gui['main'] ); --2
  
  --Exit--
  hc_gui['label_exc'] = guiCreateLabel( 0.55, 0.05, 0.4, 0.1, 'احداثيات الخروج', true, hc_gui['main'] );
  guiLabelSetHorizontalAlign( hc_gui['label_exc'], 'center', true );
  hc_edit['edit_exc_X'] = guiCreateEdit( 0.55, 0.15, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_exc_Y'] = guiCreateEdit( 0.55, 0.22, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_exc_Z'] = guiCreateEdit( 0.55, 0.29, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_gui['btn_excPick'] = guiCreateButton( 0.55, 0.36, 0.39, 0.06, 'وضع الاحداثيات', true, hc_gui['main'] ); --3
  
  --Exit teleport--
  hc_gui['label_extc'] = guiCreateLabel( 0.51, 0.45, 0.47, 0.1, 'احداثيات خارج البيت', true, hc_gui['main'] );
  guiLabelSetHorizontalAlign( hc_gui['label_extc'], 'center', true );
  hc_edit['edit_extc_X'] = guiCreateEdit( 0.55, 0.55, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_extc_Y'] = guiCreateEdit( 0.55, 0.62, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_extc_Z'] = guiCreateEdit( 0.55, 0.69, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_gui['btn_extcPick'] = guiCreateButton( 0.55, 0.76, 0.39, 0.06, 'وضع الاحداثيات', true, hc_gui['main'] ); --4
  
  for i, v in pairs( hc_edit ) do guiEditSetReadOnly( v, true ); end;
  
  hc_gui['btn_close'] = guiCreateButton( 0.88, 0.915, 0.09, 0.05, 'X', true, hc_gui['main'] );
  hc_gui['btn_reset'] = guiCreateButton( 0.88-0.21, 0.915, 0.2, 0.05, 'مسح', true, hc_gui['main'] );
  hc_gui['btn_create'] = guiCreateButton( 0.0, 0.915, 0.3, 0.05, 'موافق', true, hc_gui['main'] );
  
  hc_gui['main_add'] = guiCreateWindow( scX-310-200, (scY/2-250/2)-450/4.5, 200, 250, 'معلومات', false );
  
  hc_gui['edit_intID'] = guiCreateEdit( 0.09, 0.1, 0.35, 0.1, '', true, hc_gui['main_add'] );
  hc_gui['label_intID'] = guiCreateLabel( 0.57, 0.09, 0.3, 0.1, 'ID-Interior', true, hc_gui['main_add'] );
  guiLabelSetVerticalAlign( hc_gui['label_intID'], 'center' );
  
  hc_gui['edit_dim'] = guiCreateEdit( 0.09, 0.25, 0.35, 0.1, '', true, hc_gui['main_add'] );
  hc_gui['label_dim'] = guiCreateLabel( 0.57, 0.249, 0.3, 0.1, 'Dimensionه', true, hc_gui['main_add'] );
  guiLabelSetVerticalAlign( hc_gui['label_dim'], 'center' );
  
  hc_gui['edit_cost'] = guiCreateEdit( 0.09, 0.4, 0.45, 0.1, '', true, hc_gui['main_add'] );
  hc_gui['label_cost'] = guiCreateLabel( 0.57, 0.399, 0.3, 0.1, 'السعر $$$', true, hc_gui['main_add'] );
  guiLabelSetVerticalAlign( hc_gui['label_cost'], 'center' );
  
  for i, v in pairs( hc_gui ) do
    guiSetFont( v, 'default-bold-small' );
    if getElementType( v ) == 'gui-button' then
      guiButtonSetColor( v, '0099FFFF' );
    end;
    if getElementType( v ) == 'gui-window' then
      guiWindowSetMovable( v, false );
      guiWindowSetSizable( v, false );
    end;
  end;
  
  guiSetVisible( hc_gui['main'], false );
  guiSetVisible( hc_gui['main_add'], false );
  
  addEventHandler( 'onClientGUIClick', hc_gui['btn_close'], function( btn )
    if btn ~= 'left' then return false; end;
    triggerEvent( 'HP_SetVisible', me, false );
  end, false );
    
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hc_gui['btn_ecPick'] then
      local x, y, z = getElementPosition( me );
      guiSetText( hc_edit['edit_ec_X'], x );
      guiSetText( hc_edit['edit_ec_Y'], y );
      guiSetText( hc_edit['edit_ec_Z'], z );
    elseif source == hc_gui['btn_etcPick'] then
      local x, y, z = getElementPosition( me );
      guiSetText( hc_edit['edit_etc_X'], x );
      guiSetText( hc_edit['edit_etc_Y'], y );
      guiSetText( hc_edit['edit_etc_Z'], z );
    elseif source == hc_gui['btn_excPick'] then
      local x, y, z = getElementPosition( me );
      guiSetText( hc_edit['edit_exc_X'], x );
      guiSetText( hc_edit['edit_exc_Y'], y );
      guiSetText( hc_edit['edit_exc_Z'], z );
    elseif source == hc_gui['btn_extcPick'] then
      local x, y, z = getElementPosition( me );
      guiSetText( hc_edit['edit_extc_X'], x );
      guiSetText( hc_edit['edit_extc_Y'], y );
      guiSetText( hc_edit['edit_extc_Z'], z );
    end;
  end );
  
  addEventHandler( 'onClientGUIClick', hc_gui['btn_reset'], function( btn )
    if btn ~= 'left' then return false; end;
    for i, v in pairs( hc_edit ) do
      guiSetText( v, '' );
    end;
    for i, v in pairs( hc_gui ) do
      if getElementType( v ) == 'gui-edit' then
        guiSetText( v, '' );
      end;
    end;
  end, false );
  
  addEventHandler( 'onClientGUIChanged', root, function()
    if source == hc_gui['edit_intID'] or source == hc_gui['edit_dim'] or source == hc_gui['edit_cost'] then
      local currText = guiGetText( source );
      local newText = string.gsub( currText, '[^0-9]', '' );
      if newText ~= currText then
        guiSetText( source, newText );
      end;
    end;
  end );
  
  addEventHandler( 'onClientGUIClick', hc_gui['btn_create'], function( btn )
    if btn ~= 'left' then return false; end;
    for i, v in pairs( hc_edit ) do
      if guiGetText( v ) == '' then
        outputChatBox( '* All edit fields must be filled in!', 255, 51, 36 );
        return false;
      end;
    end;
    for i, v in pairs( hc_gui ) do
      if getElementType( v ) == 'gui-edit' and guiGetText( v ) == '' then
        outputChatBox( '* All edit fields must be filled in!', 255, 51, 36 );
        return false;
      end;
    end;
    
    local tableToSend = {
      [1] = guiGetText( hc_edit['edit_ec_X'] ), [4] = guiGetText( hc_edit['edit_etc_X'] ),
      [2] = guiGetText( hc_edit['edit_ec_Y'] ), [5] = guiGetText( hc_edit['edit_etc_Y'] ),
      [3] = guiGetText( hc_edit['edit_ec_Z'] ), [6] = guiGetText( hc_edit['edit_etc_Z'] ),
      
      [7] = guiGetText( hc_edit['edit_exc_X'] ), [10] = guiGetText( hc_edit['edit_extc_X'] ),
      [8] = guiGetText( hc_edit['edit_exc_Y'] ), [11] = guiGetText( hc_edit['edit_extc_Y'] ),
      [9] = guiGetText( hc_edit['edit_exc_Z'] ), [12] = guiGetText( hc_edit['edit_extc_Z'] ),
      
      [13] = guiGetText( hc_gui['edit_intID'] ),
      [14] = guiGetText( hc_gui['edit_dim'] ),
      [15] = guiGetText( hc_gui['edit_cost'] )
    };
    
    for i, v in ipairs( tableToSend ) do tableToSend[ i ] = tonumber( tableToSend[ i ] ); end;
    
    triggerServerEvent( 'onPlayerAttemptCreateHouse', me, tableToSend );
    triggerEvent( 'HP_SetVisible', me, false );
    
  end, false );
  
  hm_gui['main'] = guiCreateWindow( scX-360, scY-360, 350, 350, 'قائمة البيت', false );
  guiSetAlpha( hm_gui['main'], 1.0 );
  
  hm_gui['label_buy'] = guiCreateLabel( 0.03, 0.08, 0.255, 0.1, 'شراء هذا البيت', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_buy'], 'center', true );
  guiLabelSetColor( hm_gui['label_buy'], 0, 153, 255 );
  hm_gui['bck_buy'] = guiCreateGridList( 0.03, 0.15, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_buy'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_buy.png', true, hm_gui['bck_buy'] );
  
  hm_gui['label_sale'] = guiCreateLabel( 0.365, 0.08, 0.255, 0.1, 'بيع هذا البيت', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_sale'], 'center', true );
  guiLabelSetColor( hm_gui['label_sale'], 0, 153, 255 );
  hm_gui['bck_sale'] = guiCreateGridList( 0.365, 0.15, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_sale'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_sale.png', true, hm_gui['bck_sale'] );
  
  hm_gui['label_key'] = guiCreateLabel( 0.7, 0.08, 0.255, 0.1, 'وضع رقم سري', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_key'], 'center', true );
  guiLabelSetColor( hm_gui['label_key'], 0, 153, 255 );
  hm_gui['bck_key'] = guiCreateGridList( 0.7, 0.15, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_key'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_key.png', true, hm_gui['bck_key'] );
  
  hm_gui['label_enter'] = guiCreateLabel( 0.03, 0.45, 0.265, 0.1, 'فتح البيت', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_enter'], 'center', true );
  guiLabelSetColor( hm_gui['label_enter'], 0, 153, 255 );
  hm_gui['bck_enter'] = guiCreateGridList( 0.03, 0.53, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_enter'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_enter.png', true, hm_gui['bck_enter'] );
  
  hm_gui['label_newowner'] = guiCreateLabel( 0.365, 0.45, 0.255, 0.1, 'مالك جديد', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_newowner'], 'center', true );
  guiLabelSetColor( hm_gui['label_newowner'], 0, 153, 255 );
  hm_gui['bck_newowner'] = guiCreateGridList( 0.365, 0.53, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_newowner'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_newowner.png', true, hm_gui['bck_newowner'] );
  
  hm_gui['label_destroy'] = guiCreateLabel( 0.68, 0.45, 0.295, 0.1, 'حذف هذا البيت', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_destroy'], 'center', true );
  guiLabelSetColor( hm_gui['label_destroy'], 0, 153, 255 );
  hm_gui['bck_destroy'] = guiCreateGridList( 0.7, 0.53, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_destroy'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_destroy.png', true, hm_gui['bck_destroy'] );
  
  addEventHandler( 'onClientMouseEnter', root, function()
    for i, v in ipairs( { 'buy', 'sale', 'key', 'enter', 'newowner', 'destroy' } ) do
      if source == hm_gui['bck_'..v] or source == hm_gui['icon_'..v] then
        guiSetAlpha( hm_gui['icon_'..v], 0.5 );
        break;
      end;
    end;
  end );
  
  addEventHandler( 'onClientMouseLeave', root, function()
    for i, v in ipairs( { 'buy', 'sale', 'key', 'enter', 'newowner', 'destroy' } ) do
      if source == hm_gui['bck_'..v] or source == hm_gui['icon_'..v] then
        guiSetAlpha( hm_gui['icon_'..v], 1.0 );
        break;
      end;
    end;
  end );
  
  hm_gui['label_ID'] = guiCreateLabel( 0.05, 0.82, 0.25, 0.1, 'رقم البيت: ', true, hm_gui['main'] );
  hm_gui['label_owner'] = guiCreateLabel( 0.05, 0.88, 0.25, 0.1, 'اسم المالك: ', true, hm_gui['main'] );
  hm_gui['label_price'] = guiCreateLabel( 0.4, 0.82, 0.25, 0.1, 'سعر البيت $: ', true, hm_gui['main'] );
  
  hm_gui['label_ID_dyn'] = guiCreateLabel( 0.22, 0.82, 0.25, 0.1, '0', true, hm_gui['main'] );
  hm_gui['label_owner_dyn'] = guiCreateLabel( 0.29, 0.88, 0.49, 0.1, 'none', true, hm_gui['main'] );
  hm_gui['label_price_dyn'] = guiCreateLabel( 0.64, 0.82, 0.35, 0.1, '0', true, hm_gui['main'] );
  
  hm_gui['btn_close'] = guiCreateButton( 0.89, 0.89, 0.07, 0.07, 'X', true, hm_gui['main'] );
  
  guiSetVisible( hm_gui['main'], false );
  
  addEventHandler( 'onClientGUIClick', hm_gui['btn_close'], function( btn )
    if btn ~= 'left' then return false; end;
    guiSetVisible( hm_gui['main'], false );
    triggerServerEvent( 'setFrozen', me, false );
    showCursor( false );
  end, false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['icon_buy'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onBuy'], true );
      guiSetText( hm_gui['onBuy_edit'], 'Key' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['icon_sale'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onSale'], true );
      guiSetText( hm_gui['onSale_edit'], 'Key' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['icon_key'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onChange'], true );
      guiSetText( hm_gui['onChange_edit_Old'], 'رقمك القديم' );
      guiSetText( hm_gui['onChange_edit_New'], 'رقمك الجديد' );
      guiSetText( hm_gui['onChange_edit_RepeatNew'], 'اعادة الرقم الجديد' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['icon_newowner'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onNewOwner'], true );
      guiSetText( hm_gui['onNewOwner_keyEdit'], 'رقم بيتك السري' );
      guiSetText( hm_gui['onNewOwner_nameEdit'], 'اسم حسابه' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['icon_destroy'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_onDestroy'], true );
      playSound( 'sounds/click_icon.wav' );
    end;
  end );
  
  --Buy
  hm_gui['wnd_key_onBuy'] = guiCreateWindow( scX/2-250/2, scY/2-150/2, 250, 150, 'الرقم | السري', false );
  guiSetAlpha( hm_gui['wnd_key_onBuy'], 1.0 );
  hm_gui['onBuy_label'] = guiCreateLabel( 0.05, 0.15, 0.9, 0.4, "انت الان سوف تشتري البيت اكتب الرقم السري الرجاء عدم نسيانه!", true, hm_gui['wnd_key_onBuy'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onBuy_label'], 'center', true );
  guiLabelSetColor( hm_gui['onBuy_label'], 0, 153, 255 );
  hm_gui['onBuy_edit'] = guiCreateEdit( 0.14, 0.5, 0.7, 0.15, '', true, hm_gui['wnd_key_onBuy'] );
  hm_gui['onBuy_confirm'] = guiCreateButton( 0.2, 0.75, 0.2, 0.15, 'موافق', true, hm_gui['wnd_key_onBuy'] );
  hm_gui['onBuy_cancel'] = guiCreateButton( 0.57, 0.75, 0.2, 0.15, 'اغلاق', true, hm_gui['wnd_key_onBuy'] );
  guiSetVisible( hm_gui['wnd_key_onBuy'], false );
  
  --Sale
  hm_gui['wnd_key_onSale'] = guiCreateWindow( scX/2-250/2, scY/2-150/2, 250, 150, 'الرقم | السري', false );
  guiSetAlpha( hm_gui['wnd_key_onSale'], 1.0 );
  hm_gui['onSale_label'] = guiCreateLabel( 0.05, 0.15, 0.9, 0.4, "انت الان تقوم ببيع البيت بنصف السعر اكتب الرقم السري للتأكد بأنك المالك الحقيقي.", true, hm_gui['wnd_key_onSale'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onSale_label'], 'center', true );
  guiLabelSetColor( hm_gui['onSale_label'], 0, 153, 255 );
  hm_gui['onSale_edit'] = guiCreateEdit( 0.14, 0.5, 0.7, 0.15, '', true, hm_gui['wnd_key_onSale'] );
  hm_gui['onSale_confirm'] = guiCreateButton( 0.2, 0.75, 0.2, 0.15, 'موافق', true, hm_gui['wnd_key_onSale'] );
  hm_gui['onSale_cancel'] = guiCreateButton( 0.57, 0.75, 0.2, 0.15, 'اغلاق', true, hm_gui['wnd_key_onSale'] );
  guiSetVisible( hm_gui['wnd_key_onSale'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onBuy_edit'] then guiSetText( hm_gui['onBuy_edit'], '' ); end;
    if source == hm_gui['onBuy_confirm'] then
      local passTxt = guiGetText( hm_gui['onBuy_edit'] );
      if #passTxt >= getElementData( me, 'k_len' ) then
        if not passTxt:find( ' ' ) then
          triggerServerEvent( 'HOUSE_Buy', me, guiGetText( hm_gui['label_price_dyn'] ), guiGetText( hm_gui['onBuy_edit'] ) );
          guiSetText( hm_gui['onBuy_edit'], '' );
          guiSetVisible( hm_gui['wnd_key_onBuy'], false );
          showCursor( false );
          playSound( 'sounds/click_confirm.wav' );
          guiSetInputEnabled( false );
        else
          outputChatBox( '* يجب الرقم السري لايحتوي على مسافات!', 255, 51, 36 );
        end;
      else
        outputChatBox( '* يجب ان يكون من اربع حروف واكثر '..tostring( getElementData( me, 'k_len' ) )..' characters long!', 255, 51, 36 );
      end;
    elseif source == hm_gui['onBuy_cancel'] then
      guiSetText( hm_gui['onBuy_edit'], '' );
      guiSetVisible( hm_gui['wnd_key_onBuy'], false );
      guiSetVisible( hm_gui['main'], true );
      guiSetInputEnabled( false );
    end;
  end );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onSale_edit'] then guiSetText( hm_gui['onSale_edit'], '' ); end;
    if source == hm_gui['onSale_confirm'] then
      local mrk = getHouseByID( getElementData( me, 'mrk_in' ) );
      if guiGetText( hm_gui['onSale_edit'] ) == getElementData( mrk, 'HS_INFO' )[8] then
        triggerServerEvent( 'HOUSE_Sell', me );
        outputChatBox( '*تم بيع البيت بنصف السعر !', 255, 255, 0 );
        guiSetText( hm_gui['onSale_edit'], '' );
        guiSetVisible( hm_gui['wnd_key_onSale'], false );
        playSound( 'sounds/click_confirm.wav' );
        guiSetInputEnabled( false );
      else
        outputChatBox( '* Invalid key!', 255, 51, 36 );
      end;
    elseif source == hm_gui['onSale_cancel'] then
      guiSetText( hm_gui['onSale_edit'], '' );
      guiSetVisible( hm_gui['wnd_key_onSale'], false );
      guiSetVisible( hm_gui['main'], true );
      guiSetInputEnabled( false );
    end;
  end );
  
  hm_gui['wnd_key_onChange'] = guiCreateWindow( scX/2-250/2, scY/2-250/2, 250, 250, 'الرقم | السري', false );
  guiSetAlpha( hm_gui['wnd_key_onChange'], 1.0 );
  hm_gui['onChange_label'] = guiCreateLabel( 0.05, 0.15, 0.9, 0.4, "لتغير رقمك السري اكتب الرقم القديم وثم الرقم الجديد.", true, hm_gui['wnd_key_onChange'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onChange_label'], 'center', true );
  guiLabelSetColor( hm_gui['onChange_label'], 0, 153, 255 );
  hm_gui['onChange_edit_Old'] = guiCreateEdit( 0.14, 0.3, 0.7, 0.1, 'الرقم القديم', true, hm_gui['wnd_key_onChange'] );
  hm_gui['onChange_edit_New'] = guiCreateEdit( 0.14, 0.45, 0.7, 0.1, 'الرقم الجديد', true, hm_gui['wnd_key_onChange'] );
  hm_gui['onChange_edit_RepeatNew'] = guiCreateEdit( 0.14, 0.6, 0.7, 0.1, 'الرقم الجديد', true, hm_gui['wnd_key_onChange'] );
  hm_gui['onChange_confirm'] = guiCreateButton( 0.2, 0.75, 0.23, 0.11, 'موافق', true, hm_gui['wnd_key_onChange'] );
  hm_gui['onChange_cancel'] = guiCreateButton( 0.525, 0.75, 0.23, 0.11, 'اغلاق', true, hm_gui['wnd_key_onChange'] );
  guiSetVisible( hm_gui['wnd_key_onChange'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onChange_edit_Old'] or source == hm_gui['onChange_edit_New'] or source == hm_gui['onChange_edit_RepeatNew'] then
      guiSetText( source, '' );
    elseif source == hm_gui['onChange_confirm'] then
      local mrk = getHouseByID( getElementData( me, 'mrk_in' ) );
      local currKey = getElementData( mrk, 'HS_INFO' )[8];
      if guiGetText( hm_gui['onChange_edit_Old'] ) == currKey then
        if #guiGetText( hm_gui['onChange_edit_New'] ) >= getElementData( me, 'k_len' ) then
          if guiGetText( hm_gui['onChange_edit_New'] ) == guiGetText( hm_gui['onChange_edit_RepeatNew'] ) then
            triggerServerEvent( 'HOUSE_ChangeKey', me, guiGetText( hm_gui['onChange_edit_RepeatNew'] ) );
            outputChatBox( '* New Key has been set to #00FF00'..guiGetText( hm_gui['onChange_edit_RepeatNew'] ), 255, 51, 36, true );
            guiSetText( hm_gui['onChange_edit_Old'], '' );
            guiSetText( hm_gui['onChange_edit_New'], '' );
            guiSetText( hm_gui['onChange_edit_RepeatNew'], '' );
            guiSetVisible( hm_gui['wnd_key_onChange'], false );
            guiSetVisible( hm_gui['main'], true );
            playSound( 'sounds/click_confirm.wav' );
            guiSetInputEnabled( false );
          else
            outputChatBox( '* الرقم السري الجديد مختلف الرجاء التأكد!', 255, 51, 36 );
          end;
        else
          outputChatBox( '* يجب ان يكون الرقم السري '..tostring( getElementData( me, 'k_len' ) )..' ارقام!', 255, 51, 36 );
        end;
      else
        outputChatBox( '* الرقم القديم خاطيء!', 255, 51, 36 );
      end;
    elseif source == hm_gui['onChange_cancel'] then
      guiSetVisible( hm_gui['wnd_key_onChange'], false );
      guiSetText( hm_gui['onChange_edit_Old'], '' );
      guiSetText( hm_gui['onChange_edit_New'], '' );
      guiSetText( hm_gui['onChange_edit_RepeatNew'], '' );
      guiSetVisible( hm_gui['main'], true );
      guiSetInputEnabled( false );
    end;
  end );
  
  hm_gui['wnd_key_onNewOwner'] = guiCreateWindow( scX/2-250/2, scY/2-250/2, 250, 250, "مشتري جديد", false );
  guiSetAlpha( hm_gui['wnd_key_onNewOwner'], 1.0 );
  hm_gui['onNewOwner_label'] = guiCreateLabel( 0.05, 0.11, 0.9, 0.4, "اكتب حساب المشتري الجديد والرقم السري للبيت!", true, hm_gui['wnd_key_onNewOwner'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onNewOwner_label'], 'center', true );
  guiLabelSetColor( hm_gui['onNewOwner_label'], 0, 153, 255 );
  hm_gui['onNewOwner_keyEdit'] = guiCreateEdit( 0.14, 0.45, 0.7, 0.1, 'الرقم', true, hm_gui['wnd_key_onNewOwner'] );
  hm_gui['onNewOwner_nameEdit'] = guiCreateEdit( 0.14, 0.6, 0.7, 0.1, 'اسم حسابه', true, hm_gui['wnd_key_onNewOwner'] );
  hm_gui['onNewOwner_confirm'] = guiCreateButton( 0.2, 0.75, 0.27, 0.11, 'موافق', true, hm_gui['wnd_key_onNewOwner'] );
  hm_gui['onNewOwner_cancel'] = guiCreateButton( 0.5, 0.75, 0.27, 0.11, 'اغلاق', true, hm_gui['wnd_key_onNewOwner'] );
  guiSetVisible( hm_gui['wnd_key_onNewOwner'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onNewOwner_keyEdit'] or source == hm_gui['onNewOwner_nameEdit'] then
      guiSetText( source, '' );
    end;
  end );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onNewOwner_confirm'] then
      if not guiGetText( hm_gui['onNewOwner_nameEdit'] ):find( ' ' ) then
        if guiGetText( hm_gui['onNewOwner_nameEdit'] ) ~= getPlayerName( me ) then
          if getPlayerByAccountName( guiGetText( hm_gui['onNewOwner_nameEdit'] ) ) then
            if guiGetText( hm_gui['onNewOwner_keyEdit'] ) == getElementData( getHouseByID( getElementData( me, 'mrk_in' ) ), 'HS_INFO' )[8] then
              triggerServerEvent( 'HOUSE_ChangeOwner', me, guiGetText( hm_gui['onNewOwner_nameEdit'] ) );
              outputChatBox( '* [المالك الجديد لهذا البيت] #00FF00'..guiGetText( hm_gui['onNewOwner_nameEdit'] ):gsub( "%x%x%x%x%x%x", "" )..' الأن!', 255, 51, 36, true );
              guiSetText( hm_gui['onNewOwner_nameEdit'], '' );
              guiSetVisible( hm_gui['wnd_key_onNewOwner'], false );
			  showCursor( false );
			  guiSetInputEnabled( false );
              playSound( 'sounds/click_confirm.wav' );
			  triggerServerEvent( 'setFrozen', me, false );
            else
              outputChatBox( '* رقم خاطيء حاول مرة اخرى.', 255, 51, 36 );
              guiSetText( hm_gui['onNewOwner_nameEdit'], '' );
              guiSetText( hm_gui['onNewOwner_keyEdit'], '' );
			  guiSetInputEnabled( false );
            end;
          else
            outputChatBox( '* لم يتم ايجاد اي لاعب!', 255, 51, 36 );
          end;
        end;
      else
        outputChatBox( "* المشتري الجديد يجيب ان لايكون اسمه يحتوي على مسافة", 255, 51, 36 );
      end;
    elseif source == hm_gui['onNewOwner_cancel'] then
      guiSetText( hm_gui['onNewOwner_keyEdit'], '' );
      guiSetText( hm_gui['onNewOwner_nameEdit'], '' );
      guiSetVisible( hm_gui['wnd_key_onNewOwner'], false );
      guiSetVisible( hm_gui['main'], false );
	  triggerServerEvent( 'setFrozen', me, false );
	  showCursor( false );
	  guiSetInputEnabled( false );
    end;
  end );
  
  hm_gui['wnd_onDestroy'] = guiCreateWindow( scX/2-250/2, scY/2-150/2, 250, 150, 'Destroy the House', false );
  guiSetAlpha( hm_gui['wnd_onDestroy'], 1.0 );
  hm_gui['onDestroy_label'] = guiCreateLabel( 0.05, 0.23, 0.9, 0.4, 'هل انت متأكد من حذف هذا البيت?', true, hm_gui['wnd_onDestroy'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onDestroy_label'], 'center', true );
  guiLabelSetColor( hm_gui['onDestroy_label'], 0, 153, 255 );
  hm_gui['onDestroy_confirm'] = guiCreateButton( 0.2, 0.65, 0.2, 0.15, 'موافق', true, hm_gui['wnd_onDestroy'] );
  hm_gui['onDestroy_cancel'] = guiCreateButton( 0.57, 0.65, 0.2, 0.15, 'اغلاق', true, hm_gui['wnd_onDestroy'] );
  guiSetVisible( hm_gui['wnd_onDestroy'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onDestroy_confirm'] then
      triggerServerEvent( 'HOUSE_Destroy', me );
      guiSetVisible( hm_gui['wnd_onDestroy'], false );
      showCursor( false );
      playSound( 'sounds/click_confirm.wav' );
    elseif source == hm_gui['onDestroy_cancel'] then
      guiSetVisible( hm_gui['wnd_onDestroy'], false );
      guiSetVisible( hm_gui['main'], true );
    end;
  end );
  
  hm_gui['wnd_key_onEnter'] = guiCreateWindow( scX/2-250/2, scY/2-150/2, 250, 150, 'الرقم | السري', false );
  guiSetAlpha( hm_gui['wnd_key_onEnter'], 1.0 );
  hm_gui['onEnter_label'] = guiCreateLabel( 0.05, 0.15, 0.9, 0.4, "انت تريد فتح البيت اكتب الرقم السري:", true, hm_gui['wnd_key_onEnter'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onEnter_label'], 'center', true );
  guiLabelSetColor( hm_gui['onEnter_label'], 0, 153, 255 );
  hm_gui['onEnter_edit'] = guiCreateEdit( 0.14, 0.5, 0.7, 0.15, '', true, hm_gui['wnd_key_onEnter'] );
  hm_gui['onEnter_confirm'] = guiCreateButton( 0.2, 0.75, 0.2, 0.15, 'موافق', true, hm_gui['wnd_key_onEnter'] );
  hm_gui['onEnter_cancel'] = guiCreateButton( 0.57, 0.75, 0.2, 0.15, 'اغلاق', true, hm_gui['wnd_key_onEnter'] );
  guiSetVisible( hm_gui['wnd_key_onEnter'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onEnter_edit'] then guiSetText( hm_gui['onEnter_edit'], '' ); end;
    if source == hm_gui['icon_enter'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onEnter'], true );
      guiSetText( hm_gui['onEnter_edit'], 'Key' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['onEnter_confirm'] then
      local mrk = getHouseByID( getElementData( me, 'mrk_in' ) );
      if guiGetText( hm_gui['onEnter_edit'] ) == getElementData( mrk, 'HS_INFO' )[8] then
        guiSetVisible( hm_gui['wnd_key_onEnter'], false );
        showCursor( false );
        triggerServerEvent( 'HOUSE_Enter', me );
        playSound( 'sounds/click_confirm.wav' );
        guiSetInputEnabled( false );
      else
        outputChatBox( '* Invalid key!', 255, 51, 36 );
      end;
    elseif source == hm_gui['onEnter_cancel'] then
      guiSetVisible( hm_gui['wnd_key_onEnter'], false );
      guiSetVisible( hm_gui['main'], true );
      guiSetInputEnabled( false );
    end;
  end );
  
  for i, v in pairs( hm_gui ) do
    guiSetFont( v, 'default-bold-small' );
    if getElementType( v ) == 'gui-button' then
      guiButtonSetColor( v, '0099FFFF' );
    end;
    if getElementType( v ) == 'gui-window' then
      guiWindowSetMovable( v, false );
      guiWindowSetSizable( v, false );
    end;
  end;
  
  setElementData( me, 'HP_Opened', false );
  if getElementData( me, 'mrk_in' ) then triggerServerEvent( 'setFrozen', me, false ); end;
end );

addEventHandler( 'onClientResourceStop', resourceRoot, function()
  if getElementData( me, 'mrk_in' ) then triggerServerEvent( 'setFrozen', me, false ); end;
end );

function getPlayerByAccountName( name )
  for i, v in ipairs( getElementsByType( 'player' ) ) do
    if getElementData( v, 'HS_accountName' ) == name then
      return v;
    end;
  end;
  return false;
end;

function guiButtonSetColor( btn, hex )
  guiSetProperty( btn, "HoverTextColour", string.sub( hex, 7, 8 )..string.sub( hex, 1, 6 ) );
end;

addEvent( 'HP_SetVisible', true );
addEventHandler( 'HP_SetVisible', root, function( state )
  guiSetVisible( hc_gui['main'], state );
  guiSetVisible( hc_gui['main_add'], state );
  showCursor( state );
  setElementData( me, 'HP_Opened', state );
  if state then
    bindKey( 'mouse2', 'down', showHide );
  else
    unbindKey( 'mouse2', 'down', showHide );
  end;
end );

function showHide()
  showCursor( not isCursorShowing() );
end;

local cursorOverGUI = false;
addEventHandler( 'onClientMouseEnter', root, function() cursorOverGUI = true; end );
addEventHandler( 'onClientMouseLeave', root, function() cursorOverGUI = false; end );

addEventHandler( 'onClientElementDataChange', me, function( name )
  if name == 'HP_Opened' then
    if getElementData( me, name ) then
      addEventHandler( 'onClientRender', root, drawCrsrInfo );
    else
      removeEventHandler( 'onClientRender', root, drawCrsrInfo );
    end;
  end;
end );

function drawCrsrInfo()
  if isCursorShowing() and not cursorOverGUI then
    local x, y = getCursorPosition();
    if x and y then
      dxDrawText( 'RMB to show/hide cursor', scX * x + 10, scY * y - 10, scX, scY, tocolor( 255, 255, 255, 255 ), 1, 'default', 'left', 'top', false, false, true );
    end;
  end;
end;

addEvent( 'openHouseManagementWnd', true );
addEventHandler('openHouseManagementWnd', root, function( rt, cursor )
  for i, cname in ipairs( { 'buy', 'sale', 'key', 'enter', 'newowner', 'destroy' } ) do
    guiSetEnabled( hm_gui['bck_'..cname], rt[i] );
    guiSetEnabled( hm_gui['icon_'..cname], rt[i] );
    if not rt[i] then
      guiSetAlpha( hm_gui['icon_'..cname], 0.3 );
    else
      guiSetAlpha( hm_gui['icon_'..cname], 1.0 );
    end;
  end;
  guiSetText( hm_gui['label_ID_dyn'], rt[7] );
  guiSetText( hm_gui['label_owner_dyn'], rt[8] );
  guiSetText( hm_gui['label_price_dyn'], rt[9] );
  guiSetVisible( hm_gui['main'], true );
  if cursor then showCursor( true ); end;
end );

addEventHandler( 'onClientPlayerWasted', me, function()
  for i, v in pairs( hc_gui ) do if getElementType( hc_gui[ i ] ) == 'gui-window' then guiSetVisible( hc_gui[ i ], false ); end; end;
  for i, v in pairs( hm_gui ) do if getElementType( hm_gui[ i ] ) == 'gui-window' then guiSetVisible( hm_gui[ i ], false ); end; end;
  if isCursorShowing() then showCursor( false ); end;
  triggerEvent( 'HP_SetVisible', me, false );
  guiSetInputEnabled( false );
end );

local l_w      = 64;
local l_h      = 64;
local l_ratio  = l_w / l_h;
local lscale_w = 1920 / scX;
l_w            = l_w / lscale_w;
l_h            = l_w / l_ratio;

addEventHandler( 'onClientRender', root, function()
  for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement(), true ) ) do
    if getElementData( v, 'HS_INFO' ) then
      local x, y, z = getElementPosition( v );
      local cx, cy, cz = getCameraMatrix();
      if isLineOfSightClear( cx, cy, cz, x, y, z, false, false, false, false, false, false, false, v ) then
        local dist = getDistanceBetweenPoints3D( cx, cy, cz, x, y, z );
        if dist >= 5 and dist <= 15 then
          local px, py = getScreenFromWorldPosition( x, y, z + 1.8, 0.06 );
          if px then
            local owner = getElementData( v, 'HS_INFO' )[7];
            local price = getElementData( v, 'HS_INFO' )[6];
            local r, g, b = getMarkerColor( v );
            if r == 0 and g == 153 and b == 255 then
              r, g, b = 255, 255, 255;
            end;
            if owner then
              if owner == '' then owner = 'none'; end;
              dxDrawText( 'المالك: '..owner, px + 1, py + scY/38, px + 1, py + 1, tocolor( 0, 0, 0, 255 ), 1, 'default-bold', 'center', 'center', false, false );
              dxDrawText( 'المالك: '..owner, px, py + scY/38, px, py, tocolor( 255, 255, 255, 255 ), 1, 'default-bold', 'center', 'center', false, false );
              dxDrawText( 'السعر: $ '..tostring( price ), px + 1, py + scY/15, px + 1, py + 1, tocolor( 0, 0, 0, 255 ), 1, 'default-bold', 'center', 'center', false, false );
              dxDrawText( 'السعر: $ '..tostring( price ), px, py + scY/15, px, py, tocolor( 255, 255, 255, 255 ), 1, 'default-bold', 'center', 'center', false, false );
              dxDrawImage( px-l_w/2, py - scY/17, l_w, l_h, 'images/script/house_.png', 0, 0, 0, tocolor( r, g, b, 255 ) );
            end;
          end;
        end;
      end;
    end;
  end;
end );

function getHouseByID( ID )
  for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
    if getElementData( v, 'HS_INFO' ) then
      if getElementData( v, 'HS_INFO' )[9] == ID then
        return v;
      end;
    end;
  end;
  return false;
end;

bindKey( 'O', 'both', function( key, keyState )
  if keyState == 'down' then
    for k, v in ipairs ( getElementsByType( 'marker', getResourceRootElement() ) ) do
      if getElementData( v, 'HS_INFO' ) and getElementData( v, 'HS_INFO' )[7] then
        if getElementData( v, 'HS_INFO' )[7] ~= '' then
          createBlipAttachedTo( v, 32 );
        else
          createBlipAttachedTo( v, 31 );
        end;
      end;
    end;
  else
    for k, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
      if getElementData( v, 'HS_INFO' ) then
        for k, elem in ipairs( getAttachedElements( v ) ) do
          if getElementType( elem ) == 'blip' then
            destroyElement( elem );
          end;
        end;
      end;
    end;
  end;
end );

 

 

 

 

server

 

local sql = { Query = executeSQLQuery };

addEventHandler( 'onResourceStart', resourceRoot, function()
  sql.Query( "CREATE TABLE IF NOT EXISTS house_data (\
    ID INTEGER, en_X REAL, en_Y REAL, en_Z REAL,\
    en_tX REAL, en_tY REAL, en_tZ REAL,\
    ex_X REAL, ex_Y REAL, ex_Z REAL,\
    ex_tX REAL, ex_tY REAL, ex_tZ REAL,\
    int INTEGER, dim INTEGER, cost INTEGER, owner TEXT, key TEXT )"
  );
  for i, v in ipairs( getElementsByType( 'player' ) ) do
    setElementData( v, 'k_len', tonumber( get( 'keyLength' ) ) );
    local acc = getPlayerAccount( v );
    if not isGuestAccount( acc ) then
      setElementData( v, 'HS_accountName', getAccountName( acc ) );
    end;
    setElementData( v, 'mrk_in', nil );
  end;
  local hr = sql.Query( "SELECT * FROM house_data" );
  for i = 1, #hr do
    createHouse( false, hr[i].ID, hr[i].owner, hr[i].key, hr[i].en_X, hr[i].en_Y, hr[i].en_Z, hr[i].en_tX, hr[i].en_tY, hr[i].en_tZ, hr[i].ex_X, hr[i].ex_Y, hr[i].ex_Z, hr[i].ex_tX, hr[i].ex_tY, hr[i].ex_tZ, hr[i].int, hr[i].dim, hr[i].cost );
  end;
end );

addEventHandler( 'onResourceStop', resourceRoot, function()
  for i, v in ipairs( getElementsByType( 'player' ) ) do
    setElementData( v, 'k_len', nil );
    setElementData( v, 'HS_accountName', nil );
  end;
end );

addEventHandler( 'onPlayerJoin', root, function()
  setElementData( source, 'k_len', tonumber( get( 'keyLength' ) ) );
end );

addEventHandler( 'onPlayerLogin', root, function( _, acc )
  setElementData( source, 'HS_accountName', getAccountName( acc ) );
end );

addEventHandler( 'onPlayerLoout', root, function( _, acc )
  setElementData( source, 'HS_accountName', nil );
end );

addCommandHandler( 'hpanel', function( player )
  if isObjectInACLGroup( 'user.'..getAccountName( getPlayerAccount( player ) ), aclGetGroup( 'Admin' ) ) or hasObjectPermissionTo( player, 'function.banPlayer', false ) then
    if not getElementData( player, 'HP_Opened' ) and not getElementData( player, 'mrk_in' ) then
      triggerClientEvent( player, 'HP_SetVisible', root, true );
    end;
  else
    outputChatBox( '* Access denied for this command!', player, 255, 36, 51 );
  end;
end );

addEvent( 'onPlayerAttemptCreateHouse', true );
addEventHandler( 'onPlayerAttemptCreateHouse', root, function( rt )
  createHouse( true, #sql.Query( "SELECT * FROM house_data" ) + 1, '', '', unpack( rt ) );
  outputChatBox( '* تهانينا تم تكوين بيت جديد!', client, 255, 255, 0 );
end );

function createHouse( add, ID, owner, key, eX, eY, eZ, etX, etY, etZ, exX, exY, exZ, extX, extY, extZ, int, dim, cost )
  if add then
    sql.Query( "INSERT INTO house_data ( ID, en_X, en_Y, en_Z, en_tX, en_tY, en_tZ, ex_X, ex_Y, ex_Z, ex_tX, ex_tY, ex_tZ, int, dim, cost, owner, key ) VALUES ( "..ID..", "..eX..", "..eY..", "..eZ..", "..etX..", "..etY..", "..etZ..", "..exX..", "..exY..", "..exZ..", "..extX..", "..extY..", "..extZ..", "..int..", "..dim..", "..cost..", '', '' )" );
  end;
  
  local m_Enter = createMarker( eX, eY, eZ - 1, 'cylinder', 1.25, 0, 153, 255, 150 );
  setElementData( m_Enter, 'HS_INFO', { etX, etY, etZ, int, dim, cost, owner, key, ID } );
  
  if getElementData( m_Enter, 'HS_INFO' )[7] ~= '' then
    setMarkerColor( m_Enter, 255, 51, 36, 150 );
  end;
  
  addEventHandler( 'onMarkerHit', m_Enter, function( player )
    if getElementType( player ) == 'player' and not getPedOccupiedVehicle( player ) then
      if not getElementData( player, 'HP_Opened' ) then
        if not isGuestAccount( getPlayerAccount( player ) ) then
          setElementData( player, 'mrk_in', getElementData( source, 'HS_INFO' )[9] );
          onPlayerHouseMarkerHit( player, source, true );
          setPedFrozen( player, true );
        else
          outputChatBox( '* يجب عليك تسجيل دخولك!', player, 255, 51, 36 );
        end;
      end;
    end;
  end );
  
  addEventHandler( 'onMarkerLeave', m_Enter, function( player )
    if getElementType( player ) == 'player' and not getPedOccupiedVehicle( player ) then
      setElementData( player, 'mrk_in', nil );
    end;
  end );
  
  local m_Exit = createMarker( exX, exY, exZ - 1, 'cylinder', 1.25, 0, 153, 255, 150 );
  setElementData( m_Exit, 'parent', m_Enter );
  setElementInterior( m_Exit, int );
  setElementDimension( m_Exit, dim );
  
  setElementData( m_Exit, 'extX', extX );
  setElementData( m_Exit, 'extY', extY );
  setElementData( m_Exit, 'extZ', extZ );
  
  addEventHandler( 'onMarkerHit', m_Exit, function( player, dim )
    if getElementType( player ) == 'player' and dim then
        toggleControl( player, "fire", true );
        toggleControl( player, "next_weapon", true );
        toggleControl( player, "previous_weapon", true );
        toggleControl( player, "aim_weapon", true );
	    toggleControl( player, "weapon", true );
        toggleControl( player, "next_weapon", true );
        toggleControl( player, "vehicle_fire", true );
        toggleControl( player, "vehicle_secondary_fire", true );
        showPlayerHudComponent (player, "ammo", true );
        showPlayerHudComponent (player, "weapon", true );	      
		fadeCamera( player, false );
      setTimer( function( player, mrk )
        if getPedOccupiedVehicle( player ) then removePedFromVehicle( player ); end;
        local x, y, z = getElementData( mrk, 'extX' ), getElementData( mrk, 'extY' ), getElementData( mrk, 'extZ' );
        setElementPosition( player, x, y, z );
        setElementInterior( player, 0 );
        setElementDimension( player, 0 );
        toggleControl( player, "fire", true );
        toggleControl( player, "next_weapon", true );
        toggleControl( player, "previous_weapon", true );
        toggleControl( player, "aim_weapon", true );
	    toggleControl( player, "weapon", true );
        toggleControl( player, "next_weapon", true );
        toggleControl( player, "vehicle_fire", true );
        toggleControl( player, "vehicle_secondary_fire", true );
        showPlayerHudComponent (player, "ammo", true );
        showPlayerHudComponent (player, "weapon", true );	
        fadeCamera( player, true );
      end, 1200, 1, player, source );
    end;
  end );
end;

function onPlayerHouseMarkerHit( player, mrk, cursor )
  local acc = getPlayerAccount( player );
  if isGuestAccount( acc ) then
    outputChatBox( '* يجب عليك التسجيل لشراء هذا البيت!', player, 255, 51, 36 );
    setElementData( player, 'mrk_in', nil );
    setPedFrozen( player, false );
    return false;
  end;
  local tts = { [1] = true, [2] = false, [3] = false, [4] = true, [5] = false, [6] = false };
  if isObjectInACLGroup( 'user.'..getAccountName( acc ), aclGetGroup( 'Admin' ) ) or hasObjectPermissionTo( player, 'function.banPlayer', false ) then
    tts[6] = true;
  end;
  local owner = getElementData( mrk, 'HS_INFO' )[7];
  local accName = getAccountName( acc );
  if owner == accName then
    tts[1] = false;
    tts[2] = true;
    tts[3] = true;
    tts[4] = true;
    tts[5] = true;
  end;
  if owner ~= accName and owner ~= '' then
    tts[1] = false;
  end;
  if owner == '' then
    if isObjectInACLGroup( 'user.'..getAccountName( acc ), aclGetGroup( 'Admin' ) ) or hasObjectPermissionTo( player, 'function.banPlayer', false ) then
      tts[4] = true;
    else
      tts[4] = false;
    end;
  end;
  tts[7] = getElementData( mrk, 'HS_INFO' )[9];
  tts[8] = getElementData( mrk, 'HS_INFO' )[7];
  tts[9] = getElementData( mrk, 'HS_INFO' )[6];
  triggerClientEvent( player, 'openHouseManagementWnd', root, tts, cursor );
end;

addEvent( 'HOUSE_Buy', true );
addEventHandler( 'HOUSE_Buy', root, function( cost, key )
  local accName = getAccountName( getPlayerAccount( client ) );
  local houseCounter = 0;
  for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
    if getElementData( v, 'HS_INFO' ) then
      local owner = getElementData( v, 'HS_INFO' )[7];
      if owner == accName then
        houseCounter = houseCounter + 1;
      end;
    end;
  end;
  if houseCounter >= tonumber( get( 'playerHouseCounter' ) ) then
    outputChatBox( '* You can not buy more than #00FF00'..get( 'playerHouseCounter' )..' house(-s)#FF3324 at the same time!', client, 255, 51, 36, true );
    setPedFrozen( client, false );
    return false;
  end;
  if getPlayerMoney( client ) >= tonumber( cost ) then
    outputChatBox( '* الرقم السري الرجاء عد نسيانه to #00FF00'..key, client, 255, 51, 36, true );
    outputChatBox( '* تهانينا تم شراء البيت بنجاح!', client, 255, 255, 0 );
    sql.Query( "UPDATE house_data SET owner = '"..accName.."', key = '"..key.."' WHERE ID = ?", getElementData( client, 'mrk_in' ) );
    takePlayerMoney( client, cost );
    local mrk = getHouseByID( getElementData( client, 'mrk_in' ) );
    local t = {};
    for i = 1, 6 do
      t[i] = getElementData( mrk, 'HS_INFO' )[i];
    end;
    t[7] = accName;
    t[8] = key;
    t[9] = getElementData( client, 'mrk_in' );
    setElementData( mrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } );
    setMarkerColor( mrk, 255, 51, 36, 150 );
    setTimer( onPlayerHouseMarkerHit, 50, 1, client, mrk, true );
  else
    outputChatBox( '* ليس لديك مال كافي لشراء البيت!', client, 255, 51, 36 );
    onPlayerHouseMarkerHit( client, getHouseByID( getElementData( client, 'mrk_in' ) ), true );
  end;
end );

addEvent( 'HOUSE_Sell', true );
addEventHandler( 'HOUSE_Sell', root, function()
  sql.Query( "UPDATE house_data SET owner = '', key = '' WHERE ID = ?", getElementData( client, 'mrk_in' ) );
    local mrk = getHouseByID( getElementData( client, 'mrk_in' ) );
    givePlayerMoney( client, getElementData( mrk, 'HS_INFO' )[6] / 2 );
    local t = {};
    for i = 1, 6 do
      t[i] = getElementData( mrk, 'HS_INFO' )[i];
    end;
    t[7] = '';
    t[8] = '';
    t[9] = getElementData( client, 'mrk_in' );
    setElementData( mrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } );
    setMarkerColor( mrk, 0, 153, 255, 150 );
    setTimer( onPlayerHouseMarkerHit, 50, 1, client, mrk, false );
  end
);

addEvent( 'HOUSE_Enter', true );
addEventHandler( 'HOUSE_Enter', root, function()
  setPedFrozen( client, false );
  local mrk = getHouseByID( getElementData( client, 'mrk_in' ) );
  local t = {};
  for i = 1, 5 do
    t[i] = getElementData( mrk, 'HS_INFO' )[i];
  end;
  fadeCamera( client, false );
  toggleAllControls( client, false );
  setTimer( function( player, t )
    if getPedOccupiedVehicle( player ) then removePedFromVehicle( player ); end;
    setElementInterior( player, t[4], t[1], t[2], t[3] );
    setElementDimension( player, t[5] );
    toggleAllControls( player, true );
    fadeCamera( player, true );
    setElementData( player, 'mrk_in', nil )
  end, 1200, 1, client, t );
end );

addEvent( 'HOUSE_ChangeKey', true );
addEventHandler( 'HOUSE_ChangeKey', root, function( newKey )
  local mrk = getHouseByID( getElementData( client, 'mrk_in' ) );
  sql.Query( "UPDATE house_data SET key = '"..newKey.."' WHERE ID = ?", getElementData( client, 'mrk_in' ) );
  local t = {};
  for i = 1, 6 do
    t[i] = getElementData( mrk, 'HS_INFO' )[i];
  end;
  t[7] = getAccountName( getPlayerAccount( client ) );
  t[8] = newKey;
  t[9] = getElementData( client, 'mrk_in' );
  setElementData( mrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } );
end );

addEvent( 'HOUSE_ChangeOwner', true );
addEventHandler( 'HOUSE_ChangeOwner', root, function( name )
  local mrk = getHouseByID( getElementData( client, 'mrk_in' ) );
  local accName = getAccountName( getPlayerAccount( getPlayerFromName( name ) ) );
  sql.Query( "UPDATE house_data SET owner = '"..accName.."' WHERE ID = ?", getElementData( client, 'mrk_in' ) );
  local res = sql.Query( "SELECT key, owner FROM house_data WHERE ID = ?", getElementData( client, 'mrk_in' ) );
  local t = {};
  for i = 1, 6 do
    t[i] = getElementData( mrk, 'HS_INFO' )[i];
  end;
  t[7] = res[1].owner;
  t[8] = res[1].key;
  t[9] = getElementData( client, 'mrk_in' );
  setElementData( mrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } );
  setTimer( onPlayerHouseMarkerHit, 50, 1, client, mrk, false );
  outputChatBox( '* #FFFF00'..getPlayerName( client )..'#00FF00 هذا اللاعب اعطاك بيته!', getPlayerFromName( name ), 0, 255, 0, true );
end );

addEvent( 'HOUSE_Destroy', true );
addEventHandler( 'HOUSE_Destroy', root, function()
  local mrk = getHouseByID( getElementData( client, 'mrk_in' ) );
  for ii, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
    if getElementData( v, 'parent' ) == mrk then
      destroyElement( v );
    end;
  end;
  local hr = sql.Query( "SELECT * FROM house_data" );
  for i = getElementData( source, 'mrk_in' ), #hr do
    if getHouseByID( i ) ~= mrk then
      sql.Query( "UPDATE house_data SET ID = "..( i - 1 ).." WHERE ID = ?", i );
      local res = sql.Query( "SELECT owner, key FROM house_data WHERE ID = ?", i - 1 );
      local nextMrk = getHouseByID( i );
      local t = {};
      for i = 1, 6 do
        t[i] = getElementData( nextMrk, 'HS_INFO' )[i];
      end;
      t[7] = res[1].owner;
      t[8] = res[1].key;
      t[9] = i - 1;
      setElementData( nextMrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } );
      local player = getPlayerByHouseID( i - 1 );
      setElementData( player, 'mrk_in', i - 1 );
    else
      sql.Query( "DELETE FROM house_data WHERE ID = ?", i );
      destroyElement( mrk );
    end;
  end;
  outputChatBox( '* تم #'..getElementData( source, 'mrk_in' )..' حذف هذا البيت!', source, 255, 255, 0 );
  setPedFrozen( source, false );
  setElementData( source, 'mrk_in', nil );
end );

function getHouseByID( id )
  for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
    if getElementData( v, 'HS_INFO' ) and getElementData( v, 'HS_INFO' )[9] == id then
      return v;
    end;
  end;
  return false;
end;

function getPlayerByHouseID( id )
  for i, v in ipairs( getElementsByType( 'player' ) ) do
    if getElementData( v, 'mrk_in' ) == id then
      return v;
    end;
  end;
  return false;
end;

addEvent( 'setFrozen', true );
addEventHandler( 'setFrozen', root, function( state )
  setPedFrozen( client, state );
end );

addEventHandler( 'onPlayerWasted', root, function()
  if getElementData( source, 'mrk_in' ) then
    setElementData( source, 'mrk_in', nil );
    setPedFrozen( source, false );
  end;
end );

 

Link to comment
56 minutes ago, Default said:

مافهمت عليك انا مكان كولمن الـ House 

وش تبي يكون فيه ؟

#Edit:

http://up.top4top.net/downloadf-313v2k9h1-zip.html

ترا انا سويته كل وشلت كولمن House

لان م ادري وش كنت تبي تسوي فيه

يعطيك العافيه اخوي لو تقدر تعرضه وانا بحاول اعدله بكون شاكر

Link to comment
outputChatBox("تم تشغيل مود شراء البيوت|لرؤية أماكن البيوت اضغط حرف خ[o]",255,0,0,true)

local me       = getLocalPlayer();
local scX, scY = guiGetScreenSize();

local hc_gui   = {}; --house construction
local hc_edit  = {}; --edit fields
local hm_gui   = {}; --management

addEventHandler( 'onClientResourceStart', resourceRoot, function()
  hc_gui['main'] = guiCreateWindow( scX-310, scY/2-450/2, 300, 450, 'House creating', false );
  guiSetAlpha( hc_gui['main'], 1.0 );
  --Entrance--
  hc_gui['label_ec'] = guiCreateLabel( 0.042, 0.05, 0.4, 0.1, 'الاحداثيات بجانب الباب', true, hc_gui['main'] );
  guiLabelSetHorizontalAlign( hc_gui['label_ec'], 'center', true );
  hc_edit['edit_ec_X'] = guiCreateEdit( 0.063, 0.15, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_ec_Y'] = guiCreateEdit( 0.063, 0.22, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_ec_Z'] = guiCreateEdit( 0.063, 0.29, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_gui['btn_ecPick'] = guiCreateButton( 0.063, 0.36, 0.39, 0.06, 'وضع الاحدثيات', true, hc_gui['main'] ); --1
  
  --Entrance teleport--
  hc_gui['label_etc'] = guiCreateLabel( 0.009, 0.45, 0.5, 0.1, 'الاحداثيا داخل البيت', true, hc_gui['main'] );
  guiLabelSetHorizontalAlign( hc_gui['label_etc'], 'center', true );
  hc_edit['edit_etc_X'] = guiCreateEdit( 0.063, 0.55, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_etc_Y'] = guiCreateEdit( 0.063, 0.62, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_etc_Z'] = guiCreateEdit( 0.063, 0.69, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_gui['btn_etcPick'] = guiCreateButton( 0.063, 0.76, 0.39, 0.06, 'وضع الاحداثيات', true, hc_gui['main'] ); --2
  
  --Exit--
  hc_gui['label_exc'] = guiCreateLabel( 0.55, 0.05, 0.4, 0.1, 'احداثيات الخروج', true, hc_gui['main'] );
  guiLabelSetHorizontalAlign( hc_gui['label_exc'], 'center', true );
  hc_edit['edit_exc_X'] = guiCreateEdit( 0.55, 0.15, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_exc_Y'] = guiCreateEdit( 0.55, 0.22, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_exc_Z'] = guiCreateEdit( 0.55, 0.29, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_gui['btn_excPick'] = guiCreateButton( 0.55, 0.36, 0.39, 0.06, 'وضع الاحداثيات', true, hc_gui['main'] ); --3
  
  --Exit teleport--
  hc_gui['label_extc'] = guiCreateLabel( 0.51, 0.45, 0.47, 0.1, 'احداثيات خارج البيت', true, hc_gui['main'] );
  guiLabelSetHorizontalAlign( hc_gui['label_extc'], 'center', true );
  hc_edit['edit_extc_X'] = guiCreateEdit( 0.55, 0.55, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_extc_Y'] = guiCreateEdit( 0.55, 0.62, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_edit['edit_extc_Z'] = guiCreateEdit( 0.55, 0.69, 0.39, 0.06, '', true, hc_gui['main'] );
  hc_gui['btn_extcPick'] = guiCreateButton( 0.55, 0.76, 0.39, 0.06, 'وضع الاحداثيات', true, hc_gui['main'] ); --4
  
  for i, v in pairs( hc_edit ) do guiEditSetReadOnly( v, true ); end;
  
  hc_gui['btn_close'] = guiCreateButton( 0.88, 0.915, 0.09, 0.05, 'X', true, hc_gui['main'] );
  hc_gui['btn_reset'] = guiCreateButton( 0.88-0.21, 0.915, 0.2, 0.05, 'مسح', true, hc_gui['main'] );
  hc_gui['btn_create'] = guiCreateButton( 0.0, 0.915, 0.3, 0.05, 'موافق', true, hc_gui['main'] );
  
  hc_gui['main_add'] = guiCreateWindow( scX-310-200, (scY/2-250/2)-450/4.5, 200, 250, 'معلومات', false );
  
  hc_gui['edit_intID'] = guiCreateEdit( 0.09, 0.1, 0.35, 0.1, '', true, hc_gui['main_add'] );
  hc_gui['label_intID'] = guiCreateLabel( 0.57, 0.09, 0.3, 0.1, 'ID-Interior', true, hc_gui['main_add'] );
  guiLabelSetVerticalAlign( hc_gui['label_intID'], 'center' );
  
  hc_gui['edit_dim'] = guiCreateEdit( 0.09, 0.25, 0.35, 0.1, '', true, hc_gui['main_add'] );
  hc_gui['label_dim'] = guiCreateLabel( 0.57, 0.249, 0.3, 0.1, 'Dimensionه', true, hc_gui['main_add'] );
  guiLabelSetVerticalAlign( hc_gui['label_dim'], 'center' );
  
  hc_gui['edit_cost'] = guiCreateEdit( 0.09, 0.4, 0.45, 0.1, '', true, hc_gui['main_add'] );
  hc_gui['label_cost'] = guiCreateLabel( 0.57, 0.399, 0.3, 0.1, 'السعر $$$', true, hc_gui['main_add'] );
  guiLabelSetVerticalAlign( hc_gui['label_cost'], 'center' );
  
  for i, v in pairs( hc_gui ) do
    guiSetFont( v, 'default-bold-small' );
    if getElementType( v ) == 'gui-button' then
      guiButtonSetColor( v, '0099FFFF' );
    end;
    if getElementType( v ) == 'gui-window' then
      guiWindowSetMovable( v, false );
      guiWindowSetSizable( v, false );
    end;
  end;
  
  guiSetVisible( hc_gui['main'], false );
  guiSetVisible( hc_gui['main_add'], false );
  
  addEventHandler( 'onClientGUIClick', hc_gui['btn_close'], function( btn )
    if btn ~= 'left' then return false; end;
    triggerEvent( 'HP_SetVisible', me, false );
  end, false );
    
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hc_gui['btn_ecPick'] then
      local x, y, z = getElementPosition( me );
      guiSetText( hc_edit['edit_ec_X'], x );
      guiSetText( hc_edit['edit_ec_Y'], y );
      guiSetText( hc_edit['edit_ec_Z'], z );
    elseif source == hc_gui['btn_etcPick'] then
      local x, y, z = getElementPosition( me );
      guiSetText( hc_edit['edit_etc_X'], x );
      guiSetText( hc_edit['edit_etc_Y'], y );
      guiSetText( hc_edit['edit_etc_Z'], z );
    elseif source == hc_gui['btn_excPick'] then
      local x, y, z = getElementPosition( me );
      guiSetText( hc_edit['edit_exc_X'], x );
      guiSetText( hc_edit['edit_exc_Y'], y );
      guiSetText( hc_edit['edit_exc_Z'], z );
    elseif source == hc_gui['btn_extcPick'] then
      local x, y, z = getElementPosition( me );
      guiSetText( hc_edit['edit_extc_X'], x );
      guiSetText( hc_edit['edit_extc_Y'], y );
      guiSetText( hc_edit['edit_extc_Z'], z );
    end;
  end );
  
  addEventHandler( 'onClientGUIClick', hc_gui['btn_reset'], function( btn )
    if btn ~= 'left' then return false; end;
    for i, v in pairs( hc_edit ) do
      guiSetText( v, '' );
    end;
    for i, v in pairs( hc_gui ) do
      if getElementType( v ) == 'gui-edit' then
        guiSetText( v, '' );
      end;
    end;
  end, false );
  
  addEventHandler( 'onClientGUIChanged', root, function()
    if source == hc_gui['edit_intID'] or source == hc_gui['edit_dim'] or source == hc_gui['edit_cost'] then
      local currText = guiGetText( source );
      local newText = string.gsub( currText, '[^0-9]', '' );
      if newText ~= currText then
        guiSetText( source, newText );
      end;
    end;
  end );
  
  addEventHandler( 'onClientGUIClick', hc_gui['btn_create'], function( btn )
    if btn ~= 'left' then return false; end;
    for i, v in pairs( hc_edit ) do
      if guiGetText( v ) == '' then
        outputChatBox( '* All edit fields must be filled in!', 255, 51, 36 );
        return false;
      end;
    end;
    for i, v in pairs( hc_gui ) do
      if getElementType( v ) == 'gui-edit' and guiGetText( v ) == '' then
        outputChatBox( '* All edit fields must be filled in!', 255, 51, 36 );
        return false;
      end;
    end;
    
    local tableToSend = {
      [1] = guiGetText( hc_edit['edit_ec_X'] ), [4] = guiGetText( hc_edit['edit_etc_X'] ),
      [2] = guiGetText( hc_edit['edit_ec_Y'] ), [5] = guiGetText( hc_edit['edit_etc_Y'] ),
      [3] = guiGetText( hc_edit['edit_ec_Z'] ), [6] = guiGetText( hc_edit['edit_etc_Z'] ),
      
      [7] = guiGetText( hc_edit['edit_exc_X'] ), [10] = guiGetText( hc_edit['edit_extc_X'] ),
      [8] = guiGetText( hc_edit['edit_exc_Y'] ), [11] = guiGetText( hc_edit['edit_extc_Y'] ),
      [9] = guiGetText( hc_edit['edit_exc_Z'] ), [12] = guiGetText( hc_edit['edit_extc_Z'] ),
      
      [13] = guiGetText( hc_gui['edit_intID'] ),
      [14] = guiGetText( hc_gui['edit_dim'] ),
      [15] = guiGetText( hc_gui['edit_cost'] )
    };
    
    for i, v in ipairs( tableToSend ) do tableToSend[ i ] = tonumber( tableToSend[ i ] ); end;
    
    triggerServerEvent( 'onPlayerAttemptCreateHouse', me, tableToSend );
    triggerEvent( 'HP_SetVisible', me, false );
    
  end, false );
  
  hm_gui['main'] = guiCreateWindow( scX-360, scY-360, 350, 350, 'قائمة البيت', false );
  guiSetAlpha( hm_gui['main'], 1.0 );
  
  hm_gui['label_buy'] = guiCreateLabel( 0.03, 0.08, 0.255, 0.1, 'شراء هذا البيت', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_buy'], 'center', true );
  guiLabelSetColor( hm_gui['label_buy'], 0, 153, 255 );
  hm_gui['bck_buy'] = guiCreateGridList( 0.03, 0.15, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_buy'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_buy.png', true, hm_gui['bck_buy'] );
  
  hm_gui['label_sale'] = guiCreateLabel( 0.365, 0.08, 0.255, 0.1, 'بيع هذا البيت', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_sale'], 'center', true );
  guiLabelSetColor( hm_gui['label_sale'], 0, 153, 255 );
  hm_gui['bck_sale'] = guiCreateGridList( 0.365, 0.15, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_sale'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_sale.png', true, hm_gui['bck_sale'] );
  
  hm_gui['label_key'] = guiCreateLabel( 0.7, 0.08, 0.255, 0.1, 'وضع رقم سري', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_key'], 'center', true );
  guiLabelSetColor( hm_gui['label_key'], 0, 153, 255 );
  hm_gui['bck_key'] = guiCreateGridList( 0.7, 0.15, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_key'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_key.png', true, hm_gui['bck_key'] );
  
  hm_gui['label_enter'] = guiCreateLabel( 0.03, 0.45, 0.265, 0.1, 'فتح البيت', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_enter'], 'center', true );
  guiLabelSetColor( hm_gui['label_enter'], 0, 153, 255 );
  hm_gui['bck_enter'] = guiCreateGridList( 0.03, 0.53, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_enter'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_enter.png', true, hm_gui['bck_enter'] );
  
  hm_gui['label_newowner'] = guiCreateLabel( 0.365, 0.45, 0.255, 0.1, 'مالك جديد', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_newowner'], 'center', true );
  guiLabelSetColor( hm_gui['label_newowner'], 0, 153, 255 );
  hm_gui['bck_newowner'] = guiCreateGridList( 0.365, 0.53, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_newowner'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_newowner.png', true, hm_gui['bck_newowner'] );
  
  hm_gui['label_destroy'] = guiCreateLabel( 0.68, 0.45, 0.295, 0.1, 'حذف هذا البيت', true, hm_gui['main'] );
  guiLabelSetHorizontalAlign( hm_gui['label_destroy'], 'center', true );
  guiLabelSetColor( hm_gui['label_destroy'], 0, 153, 255 );
  hm_gui['bck_destroy'] = guiCreateGridList( 0.7, 0.53, 0.255, 0.255, true, hm_gui['main'] );
  hm_gui['icon_destroy'] = guiCreateStaticImage( 0.005, 0.05, 1.0, 1.0, 'images/script/icon_destroy.png', true, hm_gui['bck_destroy'] );
  
  addEventHandler( 'onClientMouseEnter', root, function()
    for i, v in ipairs( { 'buy', 'sale', 'key', 'enter', 'newowner', 'destroy' } ) do
      if source == hm_gui['bck_'..v] or source == hm_gui['icon_'..v] then
        guiSetAlpha( hm_gui['icon_'..v], 0.5 );
        break;
      end;
    end;
  end );
  
  addEventHandler( 'onClientMouseLeave', root, function()
    for i, v in ipairs( { 'buy', 'sale', 'key', 'enter', 'newowner', 'destroy' } ) do
      if source == hm_gui['bck_'..v] or source == hm_gui['icon_'..v] then
        guiSetAlpha( hm_gui['icon_'..v], 1.0 );
        break;
      end;
    end;
  end );
  
  hm_gui['label_ID'] = guiCreateLabel( 0.05, 0.82, 0.25, 0.1, 'رقم البيت: ', true, hm_gui['main'] );
  hm_gui['label_owner'] = guiCreateLabel( 0.05, 0.88, 0.25, 0.1, 'اسم المالك: ', true, hm_gui['main'] );
  hm_gui['label_price'] = guiCreateLabel( 0.4, 0.82, 0.25, 0.1, 'سعر البيت $: ', true, hm_gui['main'] );
  
  hm_gui['label_ID_dyn'] = guiCreateLabel( 0.22, 0.82, 0.25, 0.1, '0', true, hm_gui['main'] );
  hm_gui['label_owner_dyn'] = guiCreateLabel( 0.29, 0.88, 0.49, 0.1, 'none', true, hm_gui['main'] );
  hm_gui['label_price_dyn'] = guiCreateLabel( 0.64, 0.82, 0.35, 0.1, '0', true, hm_gui['main'] );
  
  hm_gui['btn_close'] = guiCreateButton( 0.89, 0.89, 0.07, 0.07, 'X', true, hm_gui['main'] );
  
  guiSetVisible( hm_gui['main'], false );
  
  addEventHandler( 'onClientGUIClick', hm_gui['btn_close'], function( btn )
    if btn ~= 'left' then return false; end;
    guiSetVisible( hm_gui['main'], false );
    triggerServerEvent( 'setFrozen', me, false );
    showCursor( false );
  end, false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['icon_buy'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onBuy'], true );
      guiSetText( hm_gui['onBuy_edit'], 'Key' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['icon_sale'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onSale'], true );
      guiSetText( hm_gui['onSale_edit'], 'Key' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['icon_key'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onChange'], true );
      guiSetText( hm_gui['onChange_edit_Old'], 'رقمك القديم' );
      guiSetText( hm_gui['onChange_edit_New'], 'رقمك الجديد' );
      guiSetText( hm_gui['onChange_edit_RepeatNew'], 'اعادة الرقم الجديد' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['icon_newowner'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onNewOwner'], true );
      guiSetText( hm_gui['onNewOwner_keyEdit'], 'رقم بيتك السري' );
      guiSetText( hm_gui['onNewOwner_nameEdit'], 'اسم حسابه' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['icon_destroy'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_onDestroy'], true );
      playSound( 'sounds/click_icon.wav' );
    end;
  end );
  
  --Buy
  hm_gui['wnd_key_onBuy'] = guiCreateWindow( scX/2-250/2, scY/2-150/2, 250, 150, 'الرقم | السري', false );
  guiSetAlpha( hm_gui['wnd_key_onBuy'], 1.0 );
  hm_gui['onBuy_label'] = guiCreateLabel( 0.05, 0.15, 0.9, 0.4, "انت الان سوف تشتري البيت اكتب الرقم السري الرجاء عدم نسيانه!", true, hm_gui['wnd_key_onBuy'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onBuy_label'], 'center', true );
  guiLabelSetColor( hm_gui['onBuy_label'], 0, 153, 255 );
  hm_gui['onBuy_edit'] = guiCreateEdit( 0.14, 0.5, 0.7, 0.15, '', true, hm_gui['wnd_key_onBuy'] );
  hm_gui['onBuy_confirm'] = guiCreateButton( 0.2, 0.75, 0.2, 0.15, 'موافق', true, hm_gui['wnd_key_onBuy'] );
  hm_gui['onBuy_cancel'] = guiCreateButton( 0.57, 0.75, 0.2, 0.15, 'اغلاق', true, hm_gui['wnd_key_onBuy'] );
  guiSetVisible( hm_gui['wnd_key_onBuy'], false );
  
  --Sale
  hm_gui['wnd_key_onSale'] = guiCreateWindow( scX/2-250/2, scY/2-150/2, 250, 150, 'الرقم | السري', false );
  guiSetAlpha( hm_gui['wnd_key_onSale'], 1.0 );
  hm_gui['onSale_label'] = guiCreateLabel( 0.05, 0.15, 0.9, 0.4, "انت الان تقوم ببيع البيت بنصف السعر اكتب الرقم السري للتأكد بأنك المالك الحقيقي.", true, hm_gui['wnd_key_onSale'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onSale_label'], 'center', true );
  guiLabelSetColor( hm_gui['onSale_label'], 0, 153, 255 );
  hm_gui['onSale_edit'] = guiCreateEdit( 0.14, 0.5, 0.7, 0.15, '', true, hm_gui['wnd_key_onSale'] );
  hm_gui['onSale_confirm'] = guiCreateButton( 0.2, 0.75, 0.2, 0.15, 'موافق', true, hm_gui['wnd_key_onSale'] );
  hm_gui['onSale_cancel'] = guiCreateButton( 0.57, 0.75, 0.2, 0.15, 'اغلاق', true, hm_gui['wnd_key_onSale'] );
  guiSetVisible( hm_gui['wnd_key_onSale'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onBuy_edit'] then guiSetText( hm_gui['onBuy_edit'], '' ); end;
    if source == hm_gui['onBuy_confirm'] then
      local passTxt = guiGetText( hm_gui['onBuy_edit'] );
      if #passTxt >= getElementData( me, 'k_len' ) then
        if not passTxt:find( ' ' ) then
          triggerServerEvent( 'HOUSE_Buy', me, guiGetText( hm_gui['label_price_dyn'] ), guiGetText( hm_gui['onBuy_edit'] ) );
          guiSetText( hm_gui['onBuy_edit'], '' );
          guiSetVisible( hm_gui['wnd_key_onBuy'], false );
          showCursor( false );
          playSound( 'sounds/click_confirm.wav' );
          guiSetInputEnabled( false );
        else
          outputChatBox( '* يجب الرقم السري لايحتوي على مسافات!', 255, 51, 36 );
        end;
      else
        outputChatBox( '* يجب ان يكون من اربع حروف واكثر '..tostring( getElementData( me, 'k_len' ) )..' characters long!', 255, 51, 36 );
      end;
    elseif source == hm_gui['onBuy_cancel'] then
      guiSetText( hm_gui['onBuy_edit'], '' );
      guiSetVisible( hm_gui['wnd_key_onBuy'], false );
      guiSetVisible( hm_gui['main'], true );
      guiSetInputEnabled( false );
    end;
  end );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onSale_edit'] then guiSetText( hm_gui['onSale_edit'], '' ); end;
    if source == hm_gui['onSale_confirm'] then
      local mrk = getHouseByID( getElementData( me, 'mrk_in' ) );
      if guiGetText( hm_gui['onSale_edit'] ) == getElementData( mrk, 'HS_INFO' )[8] then
        triggerServerEvent( 'HOUSE_Sell', me );
        outputChatBox( '*تم بيع البيت بنصف السعر !', 255, 255, 0 );
        guiSetText( hm_gui['onSale_edit'], '' );
        guiSetVisible( hm_gui['wnd_key_onSale'], false );
        playSound( 'sounds/click_confirm.wav' );
        guiSetInputEnabled( false );
      else
        outputChatBox( '* Invalid key!', 255, 51, 36 );
      end;
    elseif source == hm_gui['onSale_cancel'] then
      guiSetText( hm_gui['onSale_edit'], '' );
      guiSetVisible( hm_gui['wnd_key_onSale'], false );
      guiSetVisible( hm_gui['main'], true );
      guiSetInputEnabled( false );
    end;
  end );
  
  hm_gui['wnd_key_onChange'] = guiCreateWindow( scX/2-250/2, scY/2-250/2, 250, 250, 'الرقم | السري', false );
  guiSetAlpha( hm_gui['wnd_key_onChange'], 1.0 );
  hm_gui['onChange_label'] = guiCreateLabel( 0.05, 0.15, 0.9, 0.4, "لتغير رقمك السري اكتب الرقم القديم وثم الرقم الجديد.", true, hm_gui['wnd_key_onChange'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onChange_label'], 'center', true );
  guiLabelSetColor( hm_gui['onChange_label'], 0, 153, 255 );
  hm_gui['onChange_edit_Old'] = guiCreateEdit( 0.14, 0.3, 0.7, 0.1, 'الرقم القديم', true, hm_gui['wnd_key_onChange'] );
  hm_gui['onChange_edit_New'] = guiCreateEdit( 0.14, 0.45, 0.7, 0.1, 'الرقم الجديد', true, hm_gui['wnd_key_onChange'] );
  hm_gui['onChange_edit_RepeatNew'] = guiCreateEdit( 0.14, 0.6, 0.7, 0.1, 'الرقم الجديد', true, hm_gui['wnd_key_onChange'] );
  hm_gui['onChange_confirm'] = guiCreateButton( 0.2, 0.75, 0.23, 0.11, 'موافق', true, hm_gui['wnd_key_onChange'] );
  hm_gui['onChange_cancel'] = guiCreateButton( 0.525, 0.75, 0.23, 0.11, 'اغلاق', true, hm_gui['wnd_key_onChange'] );
  guiSetVisible( hm_gui['wnd_key_onChange'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onChange_edit_Old'] or source == hm_gui['onChange_edit_New'] or source == hm_gui['onChange_edit_RepeatNew'] then
      guiSetText( source, '' );
    elseif source == hm_gui['onChange_confirm'] then
      local mrk = getHouseByID( getElementData( me, 'mrk_in' ) );
      local currKey = getElementData( mrk, 'HS_INFO' )[8];
      if guiGetText( hm_gui['onChange_edit_Old'] ) == currKey then
        if #guiGetText( hm_gui['onChange_edit_New'] ) >= getElementData( me, 'k_len' ) then
          if guiGetText( hm_gui['onChange_edit_New'] ) == guiGetText( hm_gui['onChange_edit_RepeatNew'] ) then
            triggerServerEvent( 'HOUSE_ChangeKey', me, guiGetText( hm_gui['onChange_edit_RepeatNew'] ) );
            outputChatBox( '* New Key has been set to #00FF00'..guiGetText( hm_gui['onChange_edit_RepeatNew'] ), 255, 51, 36, true );
            guiSetText( hm_gui['onChange_edit_Old'], '' );
            guiSetText( hm_gui['onChange_edit_New'], '' );
            guiSetText( hm_gui['onChange_edit_RepeatNew'], '' );
            guiSetVisible( hm_gui['wnd_key_onChange'], false );
            guiSetVisible( hm_gui['main'], true );
            playSound( 'sounds/click_confirm.wav' );
            guiSetInputEnabled( false );
          else
            outputChatBox( '* الرقم السري الجديد مختلف الرجاء التأكد!', 255, 51, 36 );
          end;
        else
          outputChatBox( '* يجب ان يكون الرقم السري '..tostring( getElementData( me, 'k_len' ) )..' ارقام!', 255, 51, 36 );
        end;
      else
        outputChatBox( '* الرقم القديم خاطيء!', 255, 51, 36 );
      end;
    elseif source == hm_gui['onChange_cancel'] then
      guiSetVisible( hm_gui['wnd_key_onChange'], false );
      guiSetText( hm_gui['onChange_edit_Old'], '' );
      guiSetText( hm_gui['onChange_edit_New'], '' );
      guiSetText( hm_gui['onChange_edit_RepeatNew'], '' );
      guiSetVisible( hm_gui['main'], true );
      guiSetInputEnabled( false );
    end;
  end );
  
  hm_gui['wnd_key_onNewOwner'] = guiCreateWindow( scX/2-250/2, scY/2-250/2, 250, 250, "مشتري جديد", false );
  guiSetAlpha( hm_gui['wnd_key_onNewOwner'], 1.0 );
  hm_gui['onNewOwner_label'] = guiCreateLabel( 0.05, 0.11, 0.9, 0.4, "اكتب حساب المشتري الجديد والرقم السري للبيت!", true, hm_gui['wnd_key_onNewOwner'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onNewOwner_label'], 'center', true );
  guiLabelSetColor( hm_gui['onNewOwner_label'], 0, 153, 255 );
  hm_gui['onNewOwner_keyEdit'] = guiCreateEdit( 0.14, 0.45, 0.7, 0.1, 'الرقم', true, hm_gui['wnd_key_onNewOwner'] );
  hm_gui['onNewOwner_nameEdit'] = guiCreateEdit( 0.14, 0.6, 0.7, 0.1, 'اسم حسابه', true, hm_gui['wnd_key_onNewOwner'] );
  hm_gui['onNewOwner_confirm'] = guiCreateButton( 0.2, 0.75, 0.27, 0.11, 'موافق', true, hm_gui['wnd_key_onNewOwner'] );
  hm_gui['onNewOwner_cancel'] = guiCreateButton( 0.5, 0.75, 0.27, 0.11, 'اغلاق', true, hm_gui['wnd_key_onNewOwner'] );
  guiSetVisible( hm_gui['wnd_key_onNewOwner'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onNewOwner_keyEdit'] or source == hm_gui['onNewOwner_nameEdit'] then
      guiSetText( source, '' );
    end;
  end );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onNewOwner_confirm'] then
      if not guiGetText( hm_gui['onNewOwner_nameEdit'] ):find( ' ' ) then
        if guiGetText( hm_gui['onNewOwner_nameEdit'] ) ~= getPlayerName( me ) then
          if getPlayerByAccountName( guiGetText( hm_gui['onNewOwner_nameEdit'] ) ) then
            if guiGetText( hm_gui['onNewOwner_keyEdit'] ) == getElementData( getHouseByID( getElementData( me, 'mrk_in' ) ), 'HS_INFO' )[8] then
              triggerServerEvent( 'HOUSE_ChangeOwner', me, guiGetText( hm_gui['onNewOwner_nameEdit'] ) );
              outputChatBox( '* [المالك الجديد لهذا البيت] #00FF00'..guiGetText( hm_gui['onNewOwner_nameEdit'] ):gsub( "%x%x%x%x%x%x", "" )..' الأن!', 255, 51, 36, true );
              guiSetText( hm_gui['onNewOwner_nameEdit'], '' );
              guiSetVisible( hm_gui['wnd_key_onNewOwner'], false );
			  showCursor( false );
			  guiSetInputEnabled( false );
              playSound( 'sounds/click_confirm.wav' );
			  triggerServerEvent( 'setFrozen', me, false );
            else
              outputChatBox( '* رقم خاطيء حاول مرة اخرى.', 255, 51, 36 );
              guiSetText( hm_gui['onNewOwner_nameEdit'], '' );
              guiSetText( hm_gui['onNewOwner_keyEdit'], '' );
			  guiSetInputEnabled( false );
            end;
          else
            outputChatBox( '* لم يتم ايجاد اي لاعب!', 255, 51, 36 );
          end;
        end;
      else
        outputChatBox( "* المشتري الجديد يجيب ان لايكون اسمه يحتوي على مسافة", 255, 51, 36 );
      end;
    elseif source == hm_gui['onNewOwner_cancel'] then
      guiSetText( hm_gui['onNewOwner_keyEdit'], '' );
      guiSetText( hm_gui['onNewOwner_nameEdit'], '' );
      guiSetVisible( hm_gui['wnd_key_onNewOwner'], false );
      guiSetVisible( hm_gui['main'], false );
	  triggerServerEvent( 'setFrozen', me, false );
	  showCursor( false );
	  guiSetInputEnabled( false );
    end;
  end );
  
  hm_gui['wnd_onDestroy'] = guiCreateWindow( scX/2-250/2, scY/2-150/2, 250, 150, 'Destroy the House', false );
  guiSetAlpha( hm_gui['wnd_onDestroy'], 1.0 );
  hm_gui['onDestroy_label'] = guiCreateLabel( 0.05, 0.23, 0.9, 0.4, 'هل انت متأكد من حذف هذا البيت?', true, hm_gui['wnd_onDestroy'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onDestroy_label'], 'center', true );
  guiLabelSetColor( hm_gui['onDestroy_label'], 0, 153, 255 );
  hm_gui['onDestroy_confirm'] = guiCreateButton( 0.2, 0.65, 0.2, 0.15, 'موافق', true, hm_gui['wnd_onDestroy'] );
  hm_gui['onDestroy_cancel'] = guiCreateButton( 0.57, 0.65, 0.2, 0.15, 'اغلاق', true, hm_gui['wnd_onDestroy'] );
  guiSetVisible( hm_gui['wnd_onDestroy'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onDestroy_confirm'] then
      triggerServerEvent( 'HOUSE_Destroy', me );
      guiSetVisible( hm_gui['wnd_onDestroy'], false );
      showCursor( false );
      playSound( 'sounds/click_confirm.wav' );
    elseif source == hm_gui['onDestroy_cancel'] then
      guiSetVisible( hm_gui['wnd_onDestroy'], false );
      guiSetVisible( hm_gui['main'], true );
    end;
  end );
  
  hm_gui['wnd_key_onEnter'] = guiCreateWindow( scX/2-250/2, scY/2-150/2, 250, 150, 'الرقم | السري', false );
  guiSetAlpha( hm_gui['wnd_key_onEnter'], 1.0 );
  hm_gui['onEnter_label'] = guiCreateLabel( 0.05, 0.15, 0.9, 0.4, "انت تريد فتح البيت اكتب الرقم السري:", true, hm_gui['wnd_key_onEnter'] ); 
  guiLabelSetHorizontalAlign( hm_gui['onEnter_label'], 'center', true );
  guiLabelSetColor( hm_gui['onEnter_label'], 0, 153, 255 );
  hm_gui['onEnter_edit'] = guiCreateEdit( 0.14, 0.5, 0.7, 0.15, '', true, hm_gui['wnd_key_onEnter'] );
  hm_gui['onEnter_confirm'] = guiCreateButton( 0.2, 0.75, 0.2, 0.15, 'موافق', true, hm_gui['wnd_key_onEnter'] );
  hm_gui['onEnter_cancel'] = guiCreateButton( 0.57, 0.75, 0.2, 0.15, 'اغلاق', true, hm_gui['wnd_key_onEnter'] );
  guiSetVisible( hm_gui['wnd_key_onEnter'], false );
  
  addEventHandler( 'onClientGUIClick', root, function( btn )
    if btn ~= 'left' then return false; end;
    if source == hm_gui['onEnter_edit'] then guiSetText( hm_gui['onEnter_edit'], '' ); end;
    if source == hm_gui['icon_enter'] then
      guiSetVisible( hm_gui['main'], false );
      guiSetVisible( hm_gui['wnd_key_onEnter'], true );
      guiSetText( hm_gui['onEnter_edit'], 'Key' );
      playSound( 'sounds/click_icon.wav' );
      guiSetInputEnabled( true );
    elseif source == hm_gui['onEnter_confirm'] then
      local mrk = getHouseByID( getElementData( me, 'mrk_in' ) );
      if guiGetText( hm_gui['onEnter_edit'] ) == getElementData( mrk, 'HS_INFO' )[8] then
        guiSetVisible( hm_gui['wnd_key_onEnter'], false );
        showCursor( false );
        triggerServerEvent( 'HOUSE_Enter', me );
        playSound( 'sounds/click_confirm.wav' );
        guiSetInputEnabled( false );
      else
        outputChatBox( '* Invalid key!', 255, 51, 36 );
      end;
    elseif source == hm_gui['onEnter_cancel'] then
      guiSetVisible( hm_gui['wnd_key_onEnter'], false );
      guiSetVisible( hm_gui['main'], true );
      guiSetInputEnabled( false );
    end;
  end );
  
  for i, v in pairs( hm_gui ) do
    guiSetFont( v, 'default-bold-small' );
    if getElementType( v ) == 'gui-button' then
      guiButtonSetColor( v, '0099FFFF' );
    end;
    if getElementType( v ) == 'gui-window' then
      guiWindowSetMovable( v, false );
      guiWindowSetSizable( v, false );
    end;
  end;
  
  setElementData( me, 'HP_Opened', false );
  if getElementData( me, 'mrk_in' ) then triggerServerEvent( 'setFrozen', me, false ); end;
end );

addEventHandler( 'onClientResourceStop', resourceRoot, function()
  if getElementData( me, 'mrk_in' ) then triggerServerEvent( 'setFrozen', me, false ); end;
end );

function getPlayerByAccountName( name )
  for i, v in ipairs( getElementsByType( 'player' ) ) do
    if getElementData( v, 'HS_accountName' ) == name then
      return v;
    end;
  end;
  return false;
end;

function guiButtonSetColor( btn, hex )
  guiSetProperty( btn, "HoverTextColour", string.sub( hex, 7, 8 )..string.sub( hex, 1, 6 ) );
end;

addEvent( 'HP_SetVisible', true );
addEventHandler( 'HP_SetVisible', root, function( state )
  guiSetVisible( hc_gui['main'], state );
  guiSetVisible( hc_gui['main_add'], state );
  showCursor( state );
  setElementData( me, 'HP_Opened', state );
  if state then
    bindKey( 'mouse2', 'down', showHide );
  else
    unbindKey( 'mouse2', 'down', showHide );
  end;
end );

function showHide()
  showCursor( not isCursorShowing() );
end;

local cursorOverGUI = false;
addEventHandler( 'onClientMouseEnter', root, function() cursorOverGUI = true; end );
addEventHandler( 'onClientMouseLeave', root, function() cursorOverGUI = false; end );

addEventHandler( 'onClientElementDataChange', me, function( name )
  if name == 'HP_Opened' then
    if getElementData( me, name ) then
      addEventHandler( 'onClientRender', root, drawCrsrInfo );
    else
      removeEventHandler( 'onClientRender', root, drawCrsrInfo );
    end;
  end;
end );

function drawCrsrInfo()
  if isCursorShowing() and not cursorOverGUI then
    local x, y = getCursorPosition();
    if x and y then
      dxDrawText( 'RMB to show/hide cursor', scX * x + 10, scY * y - 10, scX, scY, tocolor( 255, 255, 255, 255 ), 1, 'default', 'left', 'top', false, false, true );
    end;
  end;
end;

addEvent( 'openHouseManagementWnd', true );
addEventHandler('openHouseManagementWnd', root, function( rt, cursor )
  for i, cname in ipairs( { 'buy', 'sale', 'key', 'enter', 'newowner', 'destroy' } ) do
    guiSetEnabled( hm_gui['bck_'..cname], rt[i] );
    guiSetEnabled( hm_gui['icon_'..cname], rt[i] );
    if not rt[i] then
      guiSetAlpha( hm_gui['icon_'..cname], 0.3 );
    else
      guiSetAlpha( hm_gui['icon_'..cname], 1.0 );
    end;
  end;
  guiSetText( hm_gui['label_ID_dyn'], rt[7] );
  guiSetText( hm_gui['label_owner_dyn'], rt[8] );
  guiSetText( hm_gui['label_price_dyn'], rt[9] );
  guiSetVisible( hm_gui['main'], true );
  if cursor then showCursor( true ); end;
end );

addEventHandler( 'onClientPlayerWasted', me, function()
  for i, v in pairs( hc_gui ) do if getElementType( hc_gui[ i ] ) == 'gui-window' then guiSetVisible( hc_gui[ i ], false ); end; end;
  for i, v in pairs( hm_gui ) do if getElementType( hm_gui[ i ] ) == 'gui-window' then guiSetVisible( hm_gui[ i ], false ); end; end;
  if isCursorShowing() then showCursor( false ); end;
  triggerEvent( 'HP_SetVisible', me, false );
  guiSetInputEnabled( false );
end );

local l_w      = 64;
local l_h      = 64;
local l_ratio  = l_w / l_h;
local lscale_w = 1920 / scX;
l_w            = l_w / lscale_w;
l_h            = l_w / l_ratio;

addEventHandler( 'onClientRender', root, function()
  for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement(), true ) ) do
    if getElementData( v, 'HS_INFO' ) then
      local x, y, z = getElementPosition( v );
      local cx, cy, cz = getCameraMatrix();
      if isLineOfSightClear( cx, cy, cz, x, y, z, false, false, false, false, false, false, false, v ) then
        local dist = getDistanceBetweenPoints3D( cx, cy, cz, x, y, z );
        if dist >= 5 and dist <= 15 then
          local px, py = getScreenFromWorldPosition( x, y, z + 1.8, 0.06 );
          if px then
            local owner = getElementData( v, 'HS_INFO' )[7];
            local price = getElementData( v, 'HS_INFO' )[6];
            local r, g, b = getMarkerColor( v );
            if r == 0 and g == 153 and b == 255 then
              r, g, b = 255, 255, 255;
            end;
            if owner then
              if owner == '' then owner = 'none'; end;
              dxDrawText( 'المالك: '..owner, px + 1, py + scY/38, px + 1, py + 1, tocolor( 0, 0, 0, 255 ), 1, 'default-bold', 'center', 'center', false, false );
              dxDrawText( 'المالك: '..owner, px, py + scY/38, px, py, tocolor( 255, 255, 255, 255 ), 1, 'default-bold', 'center', 'center', false, false );
              dxDrawText( 'السعر: $ '..tostring( price ), px + 1, py + scY/15, px + 1, py + 1, tocolor( 0, 0, 0, 255 ), 1, 'default-bold', 'center', 'center', false, false );
              dxDrawText( 'السعر: $ '..tostring( price ), px, py + scY/15, px, py, tocolor( 255, 255, 255, 255 ), 1, 'default-bold', 'center', 'center', false, false );
              dxDrawImage( px-l_w/2, py - scY/17, l_w, l_h, 'images/script/house_.png', 0, 0, 0, tocolor( r, g, b, 255 ) );
            end;
          end;
        end;
      end;
    end;
  end;
end );

function getHouseByID( ID )
  for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
    if getElementData( v, 'HS_INFO' ) then
      if getElementData( v, 'HS_INFO' )[9] == ID then
        return v;
      end;
    end;
  end;
  return false;
end;

bindKey( 'O', 'both', function( key, keyState )
  if keyState == 'down' then
    for k, v in ipairs ( getElementsByType( 'marker', getResourceRootElement() ) ) do
      if getElementData( v, 'HS_INFO' ) and getElementData( v, 'HS_INFO' )[7] then
        if getElementData( v, 'HS_INFO' )[7] ~= '' then
          createBlipAttachedTo( v, 32 );
        else
          createBlipAttachedTo( v, 31 );
        end;
      end;
    end;
  else
    for k, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
      if getElementData( v, 'HS_INFO' ) then
        for k, elem in ipairs( getAttachedElements( v ) ) do
          if getElementType( elem ) == 'blip' then
            destroyElement( elem );
          end;
        end;
      end;
    end;
  end;
end );

---

addEventHandler ( "onClientResourceStart" , resourceRoot , function ( )
        wnd = guiCreateWindow(382, 139, 551, 436, "العقارات", false)
        guiWindowSetSizable(wnd, false)
		guiSetVisible ( wnd , false )
        grid12 = guiCreateGridList(59, 31, 450, 248, false, wnd)
        guiGridListAddColumn(grid12, "ID", 0.2)
      --  guiGridListAddColumn(grid12, "House", 0.2)
        guiGridListAddColumn(grid12, "X,Y,Z", 0.4)
        guiGridListAddColumn(grid12, "Owner", 0.3)
        btn1 = guiCreateButton(36, 323, 192, 72, "انتقل", false, wnd)
        btn2 = guiCreateButton(327, 323, 192, 72, "اغلاق", false, wnd)    
end )
s = tostring
function loaded ( )
guiGridListClear ( grid12 )
for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
if getElementData( v, 'HS_INFO' ) then
local row = guiGridListAddRow ( grid12 )
local x,y,z = getElementPosition ( v )
guiGridListSetItemText ( grid12 , row , 1 , s ( getElementData ( v , "HS_INFO" )[9] ) , false , false )
guiGridListSetItemText ( grid12 , row , 2 , s ( math.floor(x) )..","..s(math.floor(y))..","..s(math.floor(z)) , false , false )
guiGridListSetItemText ( grid12 , row , 3 , s ( getElementData ( v , "HS_INFO" )[7] ) == "" and "none" , false , false )
end
end
end

bindKey ( "f7" , "down" , function ( )
loaded ( )
guiSetVisible ( wnd , not guiGetVisible ( wnd ) )
showCursor ( guiGetVisible ( wnd ) )
end );


addEventHandler ( "onClientGUIClick" , root , function ( )
if ( source == btn2 ) then 
guiSetVisible ( wnd , false )
showCursor ( false )
elseif ( source == btn1 ) then 
local selected = guiGridListGetSelectedItem ( grid12 )
if ( selected ~= -1 ) then 
local ItemPosition = guiGridListGetItemText ( grid12 , selected , 2 )
local Position = split ( ItemPosition , "," )
setElementPosition ( localPlayer , Position[1]+2 , Position[2]+2 , Position[3]+2 )
end
end
end );

 

Link to comment

 

يعطيك العافيه اخوي زبط بس لو بغيت احذف البيت من الجريد لست لما الشخص يشتريه او اي احد يشتري

اللي عطيتني اياه اخوي يجيب كل البيوت بس

#Edit:

انا حاولت اخي شف

بس ما زبط

 

s = tostring
function loaded ( )
guiGridListClear ( grid12 )
for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
if getElementData( v, 'HS_INFO' ) then
local row = guiGridListAddRow ( grid12 )
local x,y,z = getElementPosition ( v )
guiGridListSetItemText ( grid12 , row , 1 , s ( getElementData ( v , "HS_INFO" )[9] ) , false , false )
guiGridListSetItemText ( grid12 , row , 2 , s ( math.floor(x) )..","..s(math.floor(y))..","..s(math.floor(z)) , false , false )
local ms9821 = guiGridListSetItemText ( grid12 , row , 3 , s ( getElementData ( v , "HS_INFO" )[7] ) == "" and "none" , false , false )
local ms98212 = guiGridListGetItemText ( grid12 , row , 3 , s ( getElementData ( v , "HS_INFO" )[7] ) == "" and "none" , false , false )

if ms98212 ~= "none" then
			guiGridListRemoveRow ( myGridList, ms9821 )
end
end
end
end

 

#Edit:

يغلققققققققققق تمت الافاده من قبل الاخ عناد يعطيه ربي الف عافيه ويعطيكم ايضا

Edited by Master_MTA
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...