Jump to content

House System Problem


shoBy

Recommended Posts

Posted

see.png

I don't know what I have to do here :|

core_client.lua

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, 'Coordinates of the entrance', 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, 'Pick up coordinates', true, hc_gui['main'] ); --1
 
  --Entrance teleport--
  hc_gui['label_etc'] = guiCreateLabel( 0.009, 0.45, 0.5, 0.1, 'Coordinates of teleport inside the house', 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, 'Pick up coordinates', true, hc_gui['main'] ); --2
 
  --Exit--
  hc_gui['label_exc'] = guiCreateLabel( 0.55, 0.05, 0.4, 0.1, 'Coordinates of the Exit', 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, 'Pick up coordinates', true, hc_gui['main'] ); --3
 
  --Exit teleport--
  hc_gui['label_extc'] = guiCreateLabel( 0.51, 0.45, 0.47, 0.1, 'Coordinates of teleport outside the house', 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, 'Pick up coordinates', 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, 'Reset', true, hc_gui['main'] );
  hc_gui['btn_create'] = guiCreateButton( 0.0, 0.915, 0.3, 0.05, 'Create House', true, hc_gui['main'] );
 
  hc_gui['main_add'] = guiCreateWindow( scX-310-200, (scY/2-250/2)-450/4.5, 200, 250, 'Additional info', 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, 'Interior ID', 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, 'Cost $$$', 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, 'House Management', false );
  guiSetAlpha( hm_gui['main'], 1.0 );
 
  hm_gui['label_buy'] = guiCreateLabel( 0.03, 0.08, 0.255, 0.1, 'Buy this House', 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, 'Sell this House', 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, 'Set Key', 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, 'Enter this House', 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, 'Set new Owner', 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, 'Destroy this House', 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, 'House ID: ', true, hm_gui['main'] );
  hm_gui['label_owner'] = guiCreateLabel( 0.05, 0.88, 0.25, 0.1, 'House owner: ', true, hm_gui['main'] );
  hm_gui['label_price'] = guiCreateLabel( 0.4, 0.82, 0.25, 0.1, 'House Price $: ', 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' );
Posted

Sever.lua

          setPedFrozen( player, true ); 

Edit server.lua

          setElementFrozen( player, true ); 

is good ?

Posted

Now says line 123 setPedFrozen replace with setElementFrozen but the problem is that at line 123 isn't any setPedFrozen...WTF!?

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...