Jump to content

exports


orcun99

Recommended Posts

Hi,

 

How can export gui in another script?

 

example

scriptname: deatchmach/resources/atm/atmc.lua

function createBanking(marker, money)
	if not isElement(atmWindow) then
		atmWindow = guiCreateWindow(561, 274, 267, 208, "BD:RPG BANKA", false)
		guiWindowSetSizable(atmWindow, false)

		gayLabel = guiCreateLabel(0.05, 0.13, 0.90, 0.08, "Bakiyen:", true, atmWindow)
		guiLabelSetHorizontalAlign(gayLabel, "center", false)

		balanceLabel = guiCreateLabel(0.05, 0.21, 0.90, 0.08,tostring(money) .. "$", true, atmWindow)
		guiSetFont(balanceLabel, "default-bold-small")
		guiLabelSetHorizontalAlign(balanceLabel, "center", false)

		closeButton = guiCreateButton(9, 167, 249, 32, "Menüyü Kapat", false, atmWindow)
		guiSetProperty(closeButton, "NormalTextColour", "FFAAAAAA")
		addEventHandler("onClientGUIClick", closeButton, function()
			destroyElement(atmWindow)
			atmWindow = nil
			showCursor(false)
			guiSetInputEnabled(false)
		end, false)
		
		tabPanel = guiCreateTabPanel(9, 71, 249, 91, false, atmWindow)

		-- Withdraw Tab
		withdrawTab = guiCreateTab("Çek", tabPanel)
		withdrawEdit = guiCreateEdit(9, 17, 174, 25, "Bakiye Gir.", false, withdrawTab)
		addEventHandler ( "onClientGUIClick", withdrawEdit,
			function ()
				if ( guiGetText ( withdrawEdit ) == "Bakiye Gir." or guiGetText ( withdrawEdit ) == "Geçerli Bir Bakiye Gir" ) then
					guiSetText ( withdrawEdit, "" )
				end
			end, false )

		withdrawButton = guiCreateButton(188, 17, 49, 25, "Tamam", false, withdrawTab)
		guiSetProperty(withdrawButton, "NormalTextColour", "FFAAAAAA")
		addEventHandler("onClientGUIClick", withdrawButton, function()
			local atmAmount = guiGetText(withdrawEdit)
			if tonumber(atmAmount) and tonumber(atmAmount) > 0 then
				triggerServerEvent("banking",getLocalPlayer(),"withdrawal",atmAmount)
			else
				guiSetText(withdrawEdit,"Geçerli Bir Bakiye Gir!")
			end
		end, false)
		
		-- Deposit Tab
		depositTab = guiCreateTab("Yatır", tabPanel)
		depositEdit = guiCreateEdit(9, 17, 174, 25, "Bakiye Gir..", false, depositTab)
		addEventHandler ( "onClientGUIClick", depositEdit,
			function ()
				if ( guiGetText ( depositEdit ) == "Bakiye Gir.." or guiGetText ( depositEdit ) == "Geçerli Bir Bakiye Gir" ) then
					guiSetText ( depositEdit, "" )
				end
			end, false )

		depositButton = guiCreateButton(188, 17, 49, 25, "Tamam", false, depositTab)
		guiSetProperty(depositButton, "NormalTextColour", "FFAAAAAA")
		addEventHandler("onClientGUIClick", depositButton, function()
			local atmAmount = guiGetText(depositEdit)
			if tonumber(atmAmount) and tonumber(atmAmount) > 0 then
				triggerServerEvent("banking",getLocalPlayer(),"deposit",atmAmount)
			else
				guiSetText(depositEdit,"Geçerli Bir Sayı Gir!")
			end
		end, false)
		
		-- Enable / Disable Deposit Tab
		if getElementData(marker, "banking.type") == "ATM" then guiSetEnabled(depositTab, false) end
		guiSetInputEnabled(true)
	end
end
addEvent("showBank", true) 
addEventHandler ( "showBank", getRootElement(), createBanking)

I want to open this gui in another script

 

scriptname = deatchmach/resources/vippanel/vippanels.lua ( another folder )

function atm(element)
exports.atmc:createBanking()
end
 addEvent( "atm", true )
addEventHandler( "atm", getRootElement(), atm )

---

 

Edited by orcun99
Link to comment

deatchmach/resources/atm/meta.xml yi aç

    <export function="createBanking" type="client"/>


bu kodu ekleyerek çalıştır bakalım

ve alttaki kod 

function atm(element)
exports["atm"]:createBanking()
end
addEvent( "atm", true )
addEventHandler( "atm", getRootElement(), atm )

 

Edited by djharbi2
  • Thanks 1
Link to comment
38 minutes ago, djharbi2 said:

deatchmach/resources/atm/meta.xml yi aç


    <export function="createBanking" type="client"/>


bu kodu ekleyerek çalıştır bakalım

ve alttaki kod 


function atm(element)
exports["atm"]:createBanking()
end
addEvent( "atm", true )
addEventHandler( "atm", getRootElement(), atm )

 

added meta  changed exports but debug erorr:

 

ERROR: vippanel/server.lua:154 call: failed to call 'atm:createBanking' [string "?"]

Link to comment
8 minutes ago, orcun99 said:

added meta  changed exports but debug erorr:

 

ERROR: vippanel/server.lua:154 call: failed to call 'atm:createBanking' [string "?"]

 

function createBanking(marker, money)

burada marker ve money istemişsin fakat export yaparken birşey yollamadık oradan sıkıntı çıkarmış olabilir.

Link to comment
1 minute ago, djharbi2 said:

bunu başka biryerde kullanıyormusun yani marker olarak kullanıyormusun atm yi 

normalde mapin heryerinde atm var markere girince gui açılıyor ben vippanel diye bi script yaptım f3 e basınca ayrı bi gui açılıyor atm markerına gitmeden atmyi kullanmak amaç  vippanelde atm butonuna basınca atm guisi açılsın istiyorum

Edited by orcun99
Link to comment
2 minutes ago, orcun99 said:

normalde mapin heryerinde atm var markere girince gui açılıyor ben vippanel diye bi script yaptım f3 e basınca ayrı bi gui açılıyor atm markerına gitmeden atmyi kullanmak amaç

anladım scripti görmem lazım özel mesaj olarak görüşelim

Link to comment

https://prnt.sc/j8v6oq

http://prntscr.com/j8v7bg

 

atm full code:

client.lua 

function createBanking(marker, money)
	if not isElement(atmWindow) then
		atmWindow = guiCreateWindow(561, 274, 267, 208, "BD:RPG BANKA", false)
		guiWindowSetSizable(atmWindow, false)

		gayLabel = guiCreateLabel(0.05, 0.13, 0.90, 0.08, "Bakiyen:", true, atmWindow)
		guiLabelSetHorizontalAlign(gayLabel, "center", false)

		balanceLabel = guiCreateLabel(0.05, 0.21, 0.90, 0.08,tostring(money) .. "$", true, atmWindow)
		guiSetFont(balanceLabel, "default-bold-small")
		guiLabelSetHorizontalAlign(balanceLabel, "center", false)

		closeButton = guiCreateButton(9, 167, 249, 32, "Menüyü Kapat", false, atmWindow)
		guiSetProperty(closeButton, "NormalTextColour", "FFAAAAAA")
		addEventHandler("onClientGUIClick", closeButton, function()
			destroyElement(atmWindow)
			atmWindow = nil
			showCursor(false)
			guiSetInputEnabled(false)
		end, false)
		
		tabPanel = guiCreateTabPanel(9, 71, 249, 91, false, atmWindow)

		-- Withdraw Tab
		withdrawTab = guiCreateTab("Çek", tabPanel)
		withdrawEdit = guiCreateEdit(9, 17, 174, 25, "Bakiye Gir.", false, withdrawTab)
		addEventHandler ( "onClientGUIClick", withdrawEdit,
			function ()
				if ( guiGetText ( withdrawEdit ) == "Bakiye Gir." or guiGetText ( withdrawEdit ) == "Geçerli Bir Bakiye Gir" ) then
					guiSetText ( withdrawEdit, "" )
				end
			end, false )

		withdrawButton = guiCreateButton(188, 17, 49, 25, "Tamam", false, withdrawTab)
		guiSetProperty(withdrawButton, "NormalTextColour", "FFAAAAAA")
		addEventHandler("onClientGUIClick", withdrawButton, function()
			local atmAmount = guiGetText(withdrawEdit)
			if tonumber(atmAmount) and tonumber(atmAmount) > 0 then
				triggerServerEvent("banking",getLocalPlayer(),"withdrawal",atmAmount)
			else
				guiSetText(withdrawEdit,"Geçerli Bir Bakiye Gir!")
			end
		end, false)
		
		-- Deposit Tab
		depositTab = guiCreateTab("Yatır", tabPanel)
		depositEdit = guiCreateEdit(9, 17, 174, 25, "Bakiye Gir..", false, depositTab)
		addEventHandler ( "onClientGUIClick", depositEdit,
			function ()
				if ( guiGetText ( depositEdit ) == "Bakiye Gir.." or guiGetText ( depositEdit ) == "Geçerli Bir Bakiye Gir" ) then
					guiSetText ( depositEdit, "" )
				end
			end, false )

		depositButton = guiCreateButton(188, 17, 49, 25, "Tamam", false, depositTab)
		guiSetProperty(depositButton, "NormalTextColour", "FFAAAAAA")
		addEventHandler("onClientGUIClick", depositButton, function()
			local atmAmount = guiGetText(depositEdit)
			if tonumber(atmAmount) and tonumber(atmAmount) > 0 then
				triggerServerEvent("banking",getLocalPlayer(),"deposit",atmAmount)
			else
				guiSetText(depositEdit,"Geçerli Bir Sayı Gir!")
			end
		end, false)
		
		-- Enable / Disable Deposit Tab
		if getElementData(marker, "banking.type") == "ATM" then guiSetEnabled(depositTab, false) end
		guiSetInputEnabled(true)
	end
end
addEvent("showBank", true) 
addEventHandler ( "showBank", getRootElement(), createBanking)

function updateTotalEdit(money) --Called from server, updates total to the value 'money'.
	if isElement(balanceLabel) then
		guiSetText(balanceLabel,exports.acommands:formatNumber(money).. "$")
	end
end

addEvent("updateTotal", true) 
addEventHandler ( "updateTotal", getRootElement(), updateTotalEdit)

 

server.lua




local db = exports.adatabase

local bankData = -- {x,y,z,int,dim}
{ 
	-- LV BANK
	{358.69396972656,168.33,1007.2,3,2},
	{358.69396972656,165.60,1007.2,3,2},
	{358.69396972656,179.76811218262,1007.2,3,2},
	{411.56384277344,411.97106933594,980.61560058594,3,1},
	-- LS BANK
	{411.56384277344,411.97106933594,980.61560058594,3,0},
	-- SF BANK
	{412.35479736328,411.85781860352,980.61560058594,3,2},
	{2537.5,-1604.5821533203,714,3,1},
	{2542.5,-1604.5821533203,714,3,1},
	{2547.4,-1604.5821533203,714,3,1}
}

local atmData = -- {x,y,z,rot,int,dim}
{
	{2573.783447,-2432.050049,13.275315,-3.926991,0,0},
	{1950.369995,-2176.166748,13.197108,-3.141592,0,0},
	{1070.823975,-1865.652466,13.189775,-1.570795,0,0},
	{387.745361,-1868.947632,7.478837,-1.570795,0,0},
	{488.096100,-1269.109985,15.372196,0.695398,0,0},
	{1011.868042,-928.996338,41.971024,0.166350,0,0},
	{1617.280151,-1170.462891,23.721024,-3.171593,0,0},
	{2134.264893,-1206.344971,23.526657,-5.482788,0,0},
	{2435.497070,-1219.473145,25.037033,-6.268187,0,0},
	{2714.669922,-1452.110962,30.1082,-10.980572,0,0},
	{2308.478516,-1638.88623,14.444342,-14.122160,0,0},
	{2107.753174,-1790.69519,13.203745,-15.692955,0,0},
	{1272.961548,-1785.919067,13.19684,-18.834551,0,0},
	{664.028992,-577.972839,15.978837,0,0,0},
	{1381.084595,259.592773,19.191923,-3.534292,0,0},
	{2273.72583,-76.358864,26.167656,-6.283186,0,0},
	{193.713776,-181.493698,1.178124,-9.424776,0,0},
	{2779.04834,-1821.866577,9.918186,0.589049,0,0},
	{-44.305725,-2495.498779,36.157078,-0.981748,0,0},
	{-1557.005127,-2735.659668,48.386356,-0.589049,0,0},
	{-2168.949951,-2409.553711,30.267899,2.477543,0,0},
	{-2683.941895,-283.600403,6.795951,3.973341,0,0},
	{-2718.826172,167.332672,4.260992,0.04635,0,0},
	{-1978.749878,144.813354,27.269041,-4.696039,0,0},
	{-1677.094971,435.290466,6.754690,-3.910640,0,0},
	{-2658.843262,1354.059082,6.588484,-4.726038,0,0},
	{-1546.152222,-444.761444,5.624444,-0.799047,0,0},
	{-2258.562744,2379.001953,4.646098,-0.785398,0,0},
	{-1262.308472,2719.562012,49.909180,0.514049,0,0},
	{-859.652161,1515.417480,22.162035,0.016350,0,0},
	{-133.250870,1232.401978,19.467176,1.587146,0,0},
	{-252.458679,2595.852051,62.433189,1.587146,0,0},
	{1437.758423,2647.946045,10.992603,-1.554446,0,0},
	{2873.047852,2442.524414,10.643948,0.801748,0,0},
	{1582.180908,2218.005615,10.705400,0,0,0},
	{1680.629639,1437.314453,10.405745,2.234845,0,0},
	{2198.292725,1434.394653,10.629679,4.772389,0,0},
	{1877.375488,2073.969727,10.662491,1.630798,0,0},
	{2107.847656,896.778076,10.779678,3.171595,0,0},
	{239.1975402832,1880.4007568359,11.05,0,0,0},
	{432.48355102539,2539.2858886719,15.8,0,0,0},
	{-551.82763671875,2579.3337402344,53.57767868042,1.59365158,0,0},
	{-1895.692,-1657.640,22.65852355957,1.56608466,0,0},
	{2019.3,1015.153,10.475,1.59365158,0,0},
	{3042.8151855469,-770.16998291016,10.926562309265,0,0,0},
{-1524.7185058594,494.28372192383,6.8796875,0,0,0},
	
}

local bankBlips = -- {x,y,z}
{ 
	{1571.1135,-1336.7331,17.3}, -- LS
	{-1749.3680419922,867.71264648438,25.0859375}, -- SF
	{2446.2106,2376.2634,12.164} -- LV
}

moneyUpdater = {}
bankID = 0
atmMarkers = {}
atmID = 0

function getPlayerBankBalance(player)
	if not player or not isElement(player) or getElementType(player) ~= "player" then return 0 end
	local account = getPlayerAccount(player)
	if not account then return 0 end
	return tonumber(getAccountData(account, "money")) or 0
end

function getAccountBankBalance(player)
	if not player then return 0 end
	local account = getAccount(player)
	if not account then return 0 end
	return tonumber(getAccountData(account, "money")) or 0
end

addEvent("getPlayerBankBalance",true)
addEventHandler("getPlayerBankBalance",root,getPlayerBankBalance)

function setPlayerBankBalance (player,balance)
	if not player or not isElement(player) or getElementType(player) ~= "player" or not tonumber(balance) then return false end
	local account = getPlayerAccount(player)
	if not account then return false end
	setAccountData(account, "money", tonumber(balance))
	return true
end

function setAccountBankBalance (player,balance)
	if not player or not tonumber(balance) then return false end
	local account = getAccount(player)
	if not account then return false end
	setAccountData(account, "money", tonumber(balance))
	return true
end

addEvent ( "setPlayerBankBalance", true )
addEventHandler ( "setPlayerBankBalance", getRootElement(), setPlayerBankBalance )

function startBank()
	for k, v in ipairs(bankBlips) do
		createBlip(v[1],v[2],v[3],52,2,0,0,0,150,0,2000)
	end
	
	bankBlips = {}
	for k, v in ipairs(bankData) do
		local theMarker = createMarker(v[1],v[2],v[3],"cylinder",1.5,204,0,0,200)
		setElementData(theMarker,"banking.type","bank")
		setElementInterior(theMarker,v[4])
		setElementDimension(theMarker,v[5])
	end
	bankData = {}

	for k, v in ipairs(atmData) do
		local atm = createObject(2754,v[1],v[2],v[3],0,0,math.deg(v[4]))
		local rotX,rotY,rotZ = getElementRotation(atm)
		setElementRotation(atm, rotX, rotY, rotZ + 90)
		local theMarker = createMarker(v[1]+math.sin(math.rad(rotZ))*1.2,v[2]-math.cos(math.rad(rotZ))*1.2,v[3]-0.55,"cylinder",1,204,0,0,200)
		setElementData(theMarker,"banking.type","ATM")
		setElementInterior(atm,v[5])
		setElementInterior(theMarker,v[5])
		setElementDimension(atm,v[6])
		setElementDimension(theMarker,v[6])
	end
	atmData = {}
end

function bankPlayerJoined()
	local Username = getElementData(source,"username")
	local name = getPlayerName(source)
	time = getRealTime()
	days = time.yearday 
end

function bankPlayerQuit(quitType,reason,responsible)
	local account = getPlayerAccount(source)
	if not account then return end
	local moneyBank = tonumber(getAccountData(account, "money")) or 0
	local moneyDelta = tonumber(getElementData(source, "money")) or 0
	moneyDelta = math.floor(moneyDelta)
	local playerMoney = moneyBank+moneyDelta
	local playerMoney = tonumber(playerMoney)
	setAccountData(account, "money", playerMoney)
end

function serverBanking(dorw,money) --This is the banking handler, it takes any values from the gui namely dorw (deposit or withdrawal) and money and uses it to set bank and user money.
	-- both arguements are strings from the gui
	local moneyBank = getPlayerBankBalance(source)
	local moneyHeld = tonumber(getElementData(source, "money"))
	local moneyDelta = math.floor(tonumber(money))	--moneyDelta is the change in ammount of moneys, floor makes it an integer
	if dorw == "withdrawal" then
		if moneyDelta <= moneyBank and moneyDelta > 0 then --check they have the available moneys in their account
			local playermoney = moneyBank-moneyDelta
			local playermoney = tonumber(playermoney)
			exports.acommands:giveMoney(source,moneyDelta)
			setPlayerBankBalance (source,playermoney)
			exports.acommands:sendMessage("*BD Banka* İşlem Gerçekleşti.",0,255,0,source)
			triggerClientEvent(source,"updateTotal",source,playermoney) -- this updates the total on the bankers GUI
		else
			exports.acommands:sendMessage("*BD BANKA* Bilinmeyen miktar.",255,0,0,source)
		end
	elseif dorw == "deposit" then
		if moneyDelta <= moneyHeld and moneyDelta > 0 then --check they have the available moneys on hand
			local playermoney = moneyBank+moneyDelta --Put the money into their account
			local playermoney = tonumber(playermoney)
			exports.acommands:takeMoney(source,moneyDelta)
			setPlayerBankBalance(source,playermoney)
			exports.acommands:sendMessage("*BD BANKA* İşlem Gerçekleşti.",0,255,0,source)
			triggerClientEvent(source,"updateTotal",source,playermoney) -- this updates the total on the bankers GUI
		else
			exports.acommands:sendMessage("*BD BANKA* Bilinmeyen miktar.",255,0,0,source)
		end
	else
		exports.acommands:sendMessage(source, "*BD BANKA* Bilinmeyen Transfer Tipi.",255,0,0,source)
	end
end

function bankMarkerHit(hitPlayer,matchingDim)
	if not matchingDim or getElementType(hitPlayer) ~= "player" or isPedInVehicle(hitPlayer) then return end
	triggerClientEvent(hitPlayer,"showBank",hitPlayer,source,getPlayerBankBalance(hitPlayer))
end

addEvent("banking",true) 
addEventHandler("banking",root,serverBanking)
addEventHandler("onMarkerHit",resourceRoot,bankMarkerHit)
addEventHandler("onPlayerLogIn",root,bankPlayerJoined)
addEventHandler("onPlayerQuit",root,bankPlayerQuit)
addEventHandler("onResourceStart",resourceRoot,startBank)

 

atm  meta:

<meta>
	<info author="BlackDragon:rpg scripterları" description="Banka Scripti"/>
	<script src="bankClient.lua" type="client" />
	<script src="bankSQL.lua"  type="server" />
	<export function="getPlayerBankBalance" type="server"/>
	<export function="setPlayerBankBalance" type="server"/>
	<export function="getAccountBankBalance" type="server"/>
	<export function="setAccountBankBalance" type="server"/>
	 <export function="createBanking" type="client"/>
</meta>

 

 

 

vippanel. client.lua


 GUIEditor.button[6] = guiCreateButton(171, 144, 135, 68, "ATM Menüsü Aç", false, GUIEditor.window[1])
---			 
addEventHandler("onClientGUIClick", GUIEditor.button[6], atm, false)

--

function atm()
triggerServerEvent("atm", getRootElement(), getLocalPlayer())
end

 

vippanel server.lua

--atm


function atm(element)
exports["WSSbanking"]:createBanking()
end
 addEvent( "atm", true )
addEventHandler( "atm", getRootElement(), atm )

---

 

Edited by orcun99
Link to comment
On 23.04.2018 at 17:13, Juuve said:

you can also give acl rights for resource where you paste exports. function. Everything have to work

didn't work  same erorr

acl rights is done still same error

On 23.04.2018 at 10:21, orcun99 said:

added meta  changed exports but debug erorr:

 

ERROR: vippanel/server.lua:154 call: failed to call 'atm:createBanking' [string "?"]

 

Edited by orcun99
Link to comment

check your functions and exports again. I've recently used exports too:

resource: house_sys

file: server.lua

function calculateLimit (player)
  -- actions
end

resource: house_sys

file: meta.xml

<export function="calculateLimit" type="server"/>

resource: vehshop

file: serv.lua

exports["house_sys"]:calculateLimit(source)

Check exported function for mistakes.

Also i exported server-side function with type="server" and used only in server-side scripts

server-side scripts have to look in both resources (in meta.xml) like this:

<script src="your_name.lua" type="server" />

 

  • Thanks 1
Link to comment
14 hours ago, Juuve said:

check your functions and exports again. I've recently used exports too:

resource: house_sys

file: server.lua


function calculateLimit (player)  -- actionsend

resource: house_sys

file: meta.xml


<export function="calculateLimit" type="server"/>

resource: vehshop

file: serv.lua


exports["house_sys"]:calculateLimit(source)

Check exported function for mistakes.

Also i exported server-side function with type="server" and used only in server-side scripts

server-side scripts have to look in both resources (in meta.xml) like this:

<script src="your_name.lua" type="server" />

 

 

I solved the problem on your behalf THANK U 

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