Jump to content

[HELP]setElementInterior


brocky

Recommended Posts

I have problem with my code "It doesn't let you to go to the specified interior and x, y, z position.

I have made a GUI with edits and for interior it is called "IntEdit" and for X it is intx , for Y it is inty, for Z it is intz.

This code doesn't works.

  
intEdit = guiCreateEdit(111, 147, 166, 22, "", false, window1) 
intx = guiCreateEdit(110, 170, 167, 22, "", false, window1) 
inty = guiCreateEdit(111, 193, 170, 21, "", false, window1) 
intz = guiCreateEdit(109, 214, 178, 19, "", false, window1) 
  
function buttonDo() 
if buttonEnter == source then  
      setElementInterior(localPlayer, intEdit, intx, inty, intz )  
                end 
 end 
addEventHandler("onClientGUIClick", buttonEnter, buttonDo, false) 

Link to comment
    addEventHandler("onClientResourceStart", root, 
    function()  
    intEdit = guiCreateEdit(111, 147, 166, 22, "", false, window1) 
    intx = guiCreateEdit(110, 170, 167, 22, "", false, window1) 
    inty = guiCreateEdit(111, 193, 170, 21, "", false, window1) 
    intz = guiCreateEdit(109, 214, 178, 19, "", false, window1) 
     end) 
      
     addEventHandler("onClientGUIClick", root, 
    function() 
    if source == Button then 
    intEditBox = guiGetText(intEdit) 
    intxBox = guiGetText(intx) 
    intyBox = guiGetText(inty) 
    setElementInterior(localPlayer, tostring(intEditBox), tostring(intxBox), tostring(intyBox), tostring(intzBox) ) 
     end 
     end 
     ) 
  

Link to comment

I have a problem with my code, and its like I made an edit window which is set to variable "intPrice" and now I converted using "guiGetText" to "textPrice".

The problem is that I want to take the exact amount of money that the player entered in "textPrice" and the problem is that "takePlayerMoney" is server sided.How is it possible to call the "textPrice" in server side so I CAN TAKE THE MONEY.

This is how I did it and it doesn't works.

  
  
buttonBuy = guiCreateButton(9, 297, 130, 26, "Buy House", false, window2) 
intPrice = guiCreateEdit(114, 294, 178, 22, "", false, window1) 
textPrice = guiGetText ( intPrice ) 
local theMoney = tonumber ( textPrice ) 
  
function buyApart() 
 if buttonBuy == source then 
  playerMoney = getPlayerMoney(localPlayer) 
 if playerMoney >= theMoney then 
     guiSetEnabled(buttonSell, true) 
       outputChatBox("House Bought", 24, 247, 7, true) 
         triggerServerEvent("takingMoney", localPlayer) 
             else 
 outputChatBox("Insufficient cash.", 249, 10, 4 )  
                          end 
                   end  
          end  
addEventHandler("onClientGUIClick", buttonBuy, buyApart, false) 
  

Server side :-

  
function takeMoney() 
 takePlayerMoney(source, textPrice) 
     end  
 addEvent("takingMoney", true) 
addEventHandler("takingMoney", getRootElement(), takeMoney)  
  
  

Hope you understood my problem.

Link to comment
    buttonBuy = guiCreateButton(9, 297, 130, 26, "Buy House", false, window2) 
    intPrice = guiCreateEdit(114, 294, 178, 22, "", false, window1) 
     local theMoney = tonumber ( textPrice ) 
  
    function buyApart() 
     if buttonBuy == source then 
      playerMoney = getPlayerMoney(localPlayer) 
     if playerMoney >= theMoney then 
         guiSetEnabled(buttonSell, true) 
           outputChatBox("House Bought", 24, 247, 7, true) 
           textPrice = guiGetText ( intPrice ) 
           if textPrice ~= "" then 
             triggerServerEvent("takingMoney", localPlayer, textPrice) 
                 else 
     outputChatBox("Insufficient cash.", 249, 10, 4 ) 
                              end 
                       end 
              end 
    addEventHandler("onClientGUIClick", buttonBuy, buyApart, false) 
     

  
     function takeMoney(textPrice) 
      takePlayerMoney(source, textPrice) 
     end 
 addEvent("takingMoney", true) 
addEventHandler("takingMoney", getRootElement(), takeMoney)  

Link to comment

First of all ! takePlayerMoney is server sided! You can't use it on client side script! 2nd is that I made an Edit to input the amount of money that you want and I call it "textPrice" and it is in Client side. Now if a player clicks buyApart then the script will take the amount of money used in "textPrice" edit. but "the server side" doesn't recognize "textPrice" because it is in Client side and thats why "takePlayerMoney" doesn't recognize "textPrice" because I defined it in client side and server side doesn't know what is it.

Understood? Thats my problem and here is the debugscript 3 decision.

WARNING: [script]Test\server.lua:2: Bad argument @ 'takePlayerMoney' [Expected number at argument 2, got nil]

Link to comment

its should works

buttonBuy = guiCreateButton(9, 297, 130, 26, "Buy House", false, window2) 
intPrice = guiCreateEdit(114, 294, 178, 22, "", false, window1) 
  
  
addEventHandler("onClientGUIClick", resourceRoot, function (    ) 
    if ( source == buttonBuy ) then 
        local gTEXT = tonumber ( guiGetText ( intPrice ) ) 
    if ( getPlayerMoney ( localPlayer ) >= gTEXT ) then 
        guiSetEnabled(buttonSell, true) 
    outputChatBox("House Bought", 24, 247, 7, true ) 
        triggerServerEvent("takingMoney", localPlayer, gTEXT ) 
       else 
        outputChatBox("Insufficient cash.", 249, 10, 4, true ) 
        end 
    end 
end ) 

addEvent("takingMoney", true) 
  
addEventHandler("takingMoney", resourceRoot, function ( gTEXT ) 
takePlayerMoney ( source, gTEXT ) 
end ) 
Edited by Guest
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...