Jump to content

Trade


Tando

Recommended Posts

itens = {
[-1] = "Money",
[0] = "Gas Can",
[1] = "Full Rack",
[2] = "Buster",
[3] = "Double D-Luxe",
[4] = "Sallad Meal",
[5] = "Wrench",
[6] = "Medic Kit",
[7] = "Gas Mask",
[8] = "Tire Repair Kit",
[9] = "2x Nitrous",
[10] = "5x Nitrous",
[11] = "10x Nitrous",
[12] = "Heroine",
[13] = "Weed",
[14] = "LSD",
[15] = "DMT",
[16] = "Armour",
[17] = "Paint",
[18] = "Heroine Seed",
[19] = "Weed Seed",
[20] = "LSD Seed",
[21] = "DMT Seed",
[22] = "Mistery Box",
[23] = "Colt 45",
[24] = "Taser",
[25] = "Deagle",
[26] = "M4",
[27] = "AK-47",
[28] = "Uzi",
[29] = "Tec-9",
[30] = "MP5",
[31] = "Shotgun",
[32] = "Sawn-off",
[33] = "Spas-12",
[34] = "Rifle",
[35] = "Sniper",
[36] = "Minigun",
[37] = "RPG",
[38] = "Heat-Seeking RPG",
[39] = "Flamethrower",
[40] = "Grenade",
[41] = "Satchel",
[42] = "Molotov",
[43] = "Tear Gas",
[44] = "Parachute",
}
bindKey("F7","down","trade")
mymarket = {
}

setTimer(function()
	for i,v in ipairs(mymarket) do
		triggerServerEvent("clientUpdateMyMarket",localPlayer)
	end
end,50,0)
		
		
addEvent("updateMyMarket",true)
addEventHandler("updateMyMarket",root,function(data,arg,row)
	if arg == "add" then
		table.remove(mymarket,row)
		table.insert(mymarket,data)
	elseif arg == "set" then
		table.insert(mymarket,data)
	elseif arg == "new" then
		mymarket = {}
		for i,v in ipairs(data) do
			table.insert(mymarket,data[i])
		end
		if isElement(mymarketgrid) then
			local sel = guiGridListGetSelectedItem(mymarketgrid)
				if sel == -1 then
				destroyElement(mymarketgrid)
				mymarketgrid = guiCreateGridList(9, 182, 190, 146, false, tradewdw)
				guiGridListAddColumn(mymarketgrid, "My Market", 0.5)
				guiGridListAddColumn(mymarketgrid, "Amount", 0.5)
				guiGridListAddColumn(mymarketgrid, "Price", 0.5)
				guiGridListAddColumn(mymarketgrid, "Private", 0.5)
					for i,v in ipairs(mymarket) do
						local row = guiGridListAddRow(mymarketgrid)
						guiGridListSetItemText(mymarketgrid, row, 1, v["item"], false, false)
						guiGridListSetItemText(mymarketgrid, row, 2, v["quant"].." Unit(s)", false, false)
						guiGridListSetItemText(mymarketgrid, row, 3, "$"..v["price"], false, false)
						guiGridListSetItemText(mymarketgrid, row, 4, v["to"], false, false)
					end
				end
		end
	end
end)

function getKeyFromValueInTable(a, b)
    for k,v in pairs(a) do
        if v == b then
           return k
        end
    end
    return false
end

local sx,sy = guiGetScreenSize()

addEvent("onTradeCommand",true)
addEventHandler("onTradeCommand", root,
    function(global)
		if isElement(tradewdw) then destroyElement() else
		local inv = getElementData(localPlayer,"inventory.items")
        tradewdw = guiCreateWindow((sx-500)/2, (sy-480)/2, 500, 480, "SAUG Trade System", false)
        guiWindowSetSizable(tradewdw, false)

        mygridlist = guiCreateGridList(9, 24, 190, 153, false, tradewdw)
        guiGridListAddColumn(mygridlist, "Inventroy", 0.5)
        guiGridListAddColumn(mygridlist, "Amount", 0.5)
			for i,v in ipairs(inv) do
				local row = guiGridListAddRow(mygridlist)
				guiGridListSetItemText(mygridlist, row, 1, v["item"], false, false)
				guiGridListSetItemText(mygridlist, row, 2, v["quant"], false, false)
			end
        maingrid = guiCreateGridList(202, 24, 289, 344, false, tradewdw)
        guiGridListAddColumn(maingrid, "Player", 0.4)
        guiGridListAddColumn(maingrid, "Item", 0.35)
        guiGridListAddColumn(maingrid, "Price", 0.2)
		guiGridListAddColumn(maingrid, "Quantity", 0.3)
		guiGridListAddColumn(maingrid, "Private", 0.3)
			for i,v in ipairs(global) do
				local row = guiGridListAddRow(maingrid)
				local r,g,b = 255,255,255
				if (v[5] ~= "N/A" or v[5] ~= "") and v[5] ~= getPlayerName(localPlayer) then r,g,b = 255,0,0 end
				if v[5] == getPlayerName(localPlayer) then r,g,b = 0,255,0 end
				if v[5] == "N/A" then r,g,b = 255,255,255 end
				guiGridListSetItemText(maingrid, row, 1, v[1], false, false)
				guiGridListSetItemText(maingrid, row, 2, v[2], false, false)
				guiGridListSetItemText(maingrid, row, 3, "$"..v[3], false, false)
				guiGridListSetItemText(maingrid, row, 4, v[4].." Unit(s)", false, false)
				guiGridListSetItemText(maingrid, row, 5, v[5], false, false)
				guiGridListSetItemColor(maingrid, row, 1,r,g,b,255)
				guiGridListSetItemColor(maingrid, row, 2,r,g,b,255)
				guiGridListSetItemColor(maingrid, row, 3,r,g,b,255)
				guiGridListSetItemColor(maingrid, row, 4,r,g,b,255)
				guiGridListSetItemColor(maingrid, row, 5,r,g,b,255)
			end
        setprice = guiCreateEdit(9, 353, 84, 28, "", false, tradewdw)
        pricelabel = guiCreateLabel(10, 334, 83, 19, "Price ($/unit)", false, tradewdw)
        guiSetFont(pricelabel, "default-bold-small")
        guiLabelSetColor(pricelabel, 101, 254, 0)
        guiLabelSetHorizontalAlign(pricelabel, "center", false)
        guiLabelSetVerticalAlign(pricelabel, "center")
        privlabel = guiCreateLabel(10, 381, 190, 23, "Private Trade?", false, tradewdw)
        guiSetFont(privlabel, "default-bold-small")
        guiLabelSetColor(privlabel, 101, 254, 0)
        guiLabelSetHorizontalAlign(privlabel, "center", false)
        guiLabelSetVerticalAlign(privlabel, "center")
        privedit = guiCreateEdit(27, 405, 175, 29, "", false, tradewdw)
        addbtn = guiCreateButton(9, 438, 93, 32, "Add to Market", false, tradewdw)
        guiSetFont(addbtn, "default-bold-small")
        guiSetProperty(addbtn, "NormalTextColour", "FF65FE00")
        removebtn = guiCreateButton(109, 438, 93, 32, "Remove from Market", false, tradewdw)
        guiSetFont(removebtn, "default-bold-small")
        guiSetProperty(removebtn, "NormalTextColour", "FF65FE00")
        privcheck = guiCreateCheckBox(9, 411, 15, 17, "", false, false, tradewdw)
        setquant = guiCreateEdit(116, 353, 84, 28, "", false, tradewdw)
        quantlabel = guiCreateLabel(116, 334, 83, 19, "Quantity", false, tradewdw)
        guiSetFont(quantlabel, "default-bold-small")
        guiLabelSetColor(quantlabel, 101, 254, 0)
        guiLabelSetHorizontalAlign(quantlabel, "center", false)
        guiLabelSetVerticalAlign(quantlabel, "center")
        mymarketgrid = guiCreateGridList(9, 182, 190, 146, false, tradewdw)
        guiGridListAddColumn(mymarketgrid, "My Market", 0.5)
        guiGridListAddColumn(mymarketgrid, "Amount", 0.5)
		guiGridListAddColumn(mymarketgrid, "Price", 0.5)
		guiGridListAddColumn(mymarketgrid, "Private", 0.5)
			for i,v in ipairs(mymarket) do
				local row = guiGridListAddRow(mymarketgrid)
				guiGridListSetItemText(mymarketgrid, row, 1, v["item"], false, false)
				guiGridListSetItemText(mymarketgrid, row, 2, v["quant"].." Unit(s)", false, false)
				guiGridListSetItemText(mymarketgrid, row, 3, "$"..v["price"], false, false)
				guiGridListSetItemText(mymarketgrid, row, 4, v["to"], false, false)
			end
        quantbuy = guiCreateLabel(209, 376, 94, 20, "Quantity to Buy:", false, tradewdw)
        guiSetFont(quantbuy, "default-bold-small")
        guiLabelSetColor(quantbuy, 246, 148, 7)
        guiLabelSetVerticalAlign(quantbuy, "center")
        buyqedit = guiCreateEdit(304, 371, 187, 29, "", false, tradewdw)
        buybtn = guiCreateButton(211, 403, 93, 32, "Buy", false, tradewdw)
        guiSetFont(buybtn, "default-bold-small")
        guiSetProperty(buybtn, "NormalTextColour", "FFF69407")
        logo = guiCreateStaticImage(309, 404, 182, 65, ":SAUGLogin/logo.png", false, tradewdw)
		end
    end
)

addEventHandler("onClientGUIClick",root,function()
	if isElement(tradewdw) then
		if source == addbtn then
			local sel = guiGridListGetSelectedItem(mygridlist)
			local checks = guiCheckBoxGetSelected(privcheck)
				if sel ~= -1 and checks == false then
					local amount = guiGetText(setquant)
					local price = guiGetText(setprice)
					local item = guiGridListGetItemText(mygridlist,sel,1)
						if tonumber(amount) and tonumber(amount) >= 1 and tonumber(price) and tonumber(price) >= 1 then
							triggerServerEvent("onAddMarketButtonPress",localPlayer,math.floor(amount),price,item,false)
						end
				elseif sel ~= -1 and checks == true then
					local player = guiGetText(privedit)
					local amount = guiGetText(setquant)
					local price = guiGetText(setprice)
					local item = guiGridListGetItemText(mygridlist,sel,1)
						if tonumber(amount) and tonumber(amount) >= 1 and tonumber(price) and tonumber(price) >= 1 then
							triggerServerEvent("onAddMarketButtonPress",localPlayer,math.floor(amount),price,item,true,player)
						end
				end
		end
		if source == removebtn then
			local sel = guiGridListGetSelectedItem(mymarketgrid)
				if sel ~= -1 then
					local amount = guiGetText(setquant)
					local item = guiGridListGetItemText(mymarketgrid,sel,1)
					local quant = guiGridListGetItemText(mymarketgrid,sel,2)
					local quant = string.gsub(quant," Unit(%()s(%))","")
					local price = guiGridListGetItemText(mymarketgrid,sel,3)
					local price = string.gsub(price,"($)","")
					local player = guiGridListGetItemText(mymarketgrid,sel,4)
						if tonumber(amount) and tonumber(amount) >= 1 then
							for i,v in ipairs(mymarket) do
								if v["item"] == item and tonumber(quant) == tonumber(amount) then
									table.remove(mymarket,i)
								elseif v["item"] == item and tonumber(quant) > tonumber(amount) then
									table.remove(mymarket,i)
									table.insert(mymarket,{["item"]=item,["quant"]=tonumber(math.floor(quant)) - tonumber(math.floor(amount)),["price"]=tonumber(price),["to"]=player})
								end
							end
							triggerServerEvent("onRemoveMarketButtonPress",localPlayer,math.floor(amount),math.floor(quant),item,player)
						end
				end
		end
		if source == buybtn then
			local sel = guiGridListGetSelectedItem(maingrid)
				if sel ~= -1 then
					local amount = guiGetText(buyqedit)
					local name = guiGridListGetItemText(maingrid,sel,1)
					local item = guiGridListGetItemText(maingrid,sel,2)
					local price = guiGridListGetItemText(maingrid,sel,3)
					local price = string.gsub(price,"($)","")
					local quant = guiGridListGetItemText(maingrid,sel,4)
					local quant = string.gsub(quant," Unit(%()s(%))","")
					local player = guiGridListGetItemText(maingrid,sel,5)
						if tonumber(amount) and tonumber(amount) >= 1 then
							if tonumber(amount) <= tonumber(quant) then
							     if getPlayerMoney(localPlayer) >= tonumber(price)*tonumber(amount) then
								          triggerServerEvent("onBuyMarketButtonPress",localPlayer,name,math.floor(amount),item,tonumber(price),tonumber(math.floor(quant)),player)
					             end
                           end
						end
				end
	
	end	end	
end)

addEvent("updateAllMarket",true)
addEventHandler("updateAllMarket",root,function(global,arg)
	if isElement(tradewdw) then
		if arg == "onlyglobal" then
			guiGridListClear(maingrid)
				for i,v in ipairs(global) do
					local row = guiGridListAddRow(maingrid)
					local r,g,b = 255,255,255
					if (v[5] ~= "N/A" or v[5] ~= "") and v[5] ~= getPlayerName(localPlayer) then r,g,b = 255,0,0 end
					if v[5] == getPlayerName(localPlayer) then r,g,b = 0,255,0 end
					if v[5] == "N/A" then r,g,b = 255,255,255 end
					guiGridListSetItemText(maingrid, row, 1, v[1], false, false)
					guiGridListSetItemText(maingrid, row, 2, v[2], false, false)
					guiGridListSetItemText(maingrid, row, 3, "$"..v[3], false, false)
					guiGridListSetItemText(maingrid, row, 4, v[4].." Unit(s)", false, false)
					guiGridListSetItemText(maingrid, row, 5, v[5], false, false)
					guiGridListSetItemColor(maingrid, row, 1,r,g,b,255)
					guiGridListSetItemColor(maingrid, row, 2,r,g,b,255)
					guiGridListSetItemColor(maingrid, row, 3,r,g,b,255)
					guiGridListSetItemColor(maingrid, row, 4,r,g,b,255)
					guiGridListSetItemColor(maingrid, row, 5,r,g,b,255)
				end
		else
			local inv = getElementData(localPlayer,"inventory.items")
				guiGridListClear(mygridlist)
				for i,v in ipairs(inv) do
					local row = guiGridListAddRow(mygridlist)
					guiGridListSetItemText(mygridlist, row, 1, v["item"], false, false)
					guiGridListSetItemText(mygridlist, row, 2, v["quant"], false, false)
				end
					guiGridListClear(maingrid)
					for i,v in ipairs(global) do
						local row = guiGridListAddRow(maingrid)
						local r,g,b = 255,255,255
						if (v[5] ~= "N/A" or v[5] ~= "") and v[5] ~= getPlayerName(localPlayer) then r,g,b = 255,0,0 end
						if v[5] == getPlayerName(localPlayer) then r,g,b = 0,255,0 end
						if v[5] == "N/A" then r,g,b = 255,255,255 end
						guiGridListSetItemText(maingrid, row, 1, v[1], false, false)
						guiGridListSetItemText(maingrid, row, 2, v[2], false, false)
						guiGridListSetItemText(maingrid, row, 3, "$"..v[3], false, false)
						guiGridListSetItemText(maingrid, row, 4, v[4].." Unit(s)", false, false)
						guiGridListSetItemText(maingrid, row, 5, v[5], false, false)
						guiGridListSetItemColor(maingrid, row, 1,r,g,b,255)
						guiGridListSetItemColor(maingrid, row, 2,r,g,b,255)
						guiGridListSetItemColor(maingrid, row, 3,r,g,b,255)
						guiGridListSetItemColor(maingrid, row, 4,r,g,b,255)
						guiGridListSetItemColor(maingrid, row, 5,r,g,b,255)
					end
				guiGridListClear(mymarketgrid)
				for i,v in ipairs(mymarket) do
					local row = guiGridListAddRow(mymarketgrid)
					guiGridListSetItemText(mymarketgrid, row, 1, v["item"], false, false)
					guiGridListSetItemText(mymarketgrid, row, 2, v["quant"].." Unit(s)", false, false)
					guiGridListSetItemText(mymarketgrid, row, 3, "$"..v["price"], false, false)
					guiGridListSetItemText(mymarketgrid, row, 4, v["to"], false, false)
				end
		end
	end
end)












when i click f7 or t/trade not shown

Link to comment
18 hours ago, Dimos7 said:

i don't see where is the addCommandHandler here 



itens = {
[-1] = "Money",
[0] = "Gas Can",
[1] = "Full Rack",
[2] = "Buster",
[3] = "Double D-Luxe",
[4] = "Sallad Meal",
[5] = "Wrench",
[6] = "Medic Kit",
[7] = "Gas Mask",
[8] = "Tire Repair Kit",
[9] = "2x Nitrous",
[10] = "5x Nitrous",
[11] = "10x Nitrous",
[12] = "Heroine",
[13] = "Weed",
[14] = "LSD",
[15] = "DMT",
[16] = "Armour",
[17] = "Paint",
[18] = "Heroine Seed",
[19] = "Weed Seed",
[20] = "LSD Seed",
[21] = "DMT Seed",
[22] = "Mistery Box",
[23] = "Colt 45",
[24] = "Taser",
[25] = "Deagle",
[26] = "M4",
[27] = "AK-47",
[28] = "Uzi",
[29] = "Tec-9",
[30] = "MP5",
[31] = "Shotgun",
[32] = "Sawn-off",
[33] = "Spas-12",
[34] = "Rifle",
[35] = "Sniper",
[36] = "Minigun",
[37] = "RPG",
[38] = "Heat-Seeking RPG",
[39] = "Flamethrower",
[40] = "Grenade",
[41] = "Satchel",
[42] = "Molotov",
[43] = "Tear Gas",
[44] = "Parachute",
}

function getKeyFromValueInTable(a, b)
    for k,v in pairs(a) do
        if v == b then
           return k
        end
    end
    return false
end

function table.removeValue(tab, val)
    for index, value in ipairs(tab) do
        if value == val then
            table.remove(tab, index)
            return index
        end
    end
    return false
end

globalitems = {

}

function getGlobalItems()
    return globalitems
end

function removeFromGlobalItems(acc)
    for i,v in ipairs(globalitems) do
        if v[1] == acc then
            table.remove(globalitems,i)
            removeFromGlobalItems(acc)
            break 
        end
    end
end

function getPlayerItemCount(player,item)
    local rquant = exports["SAUGInventory"]:getPlayerItemCount(player,getKeyFromValueInTable(itens,item))
        return rquant
end

function takePlayerItem(player,item,qt)
    exports["SAUGInventory"]:takePlayerItem(player,getKeyFromValueInTable(itens,item),tonumber(qt))
end

function addPlayerItem(player,item,qt)
    exports["SAUGInventory"]:addPlayerItem(player,getKeyFromValueInTable(itens,item),(qt))
end

addCommandHandler("trade",function(player,cmd)
    if getElementData(player,"inventory.items") and not isGuestAccount(getPlayerAccount(player)) then
        triggerClientEvent(player,"onTradeCommand",player,globalitems)
    end
end)


addEvent("onAddMarketButtonPress",true)
addEventHandler("onAddMarketButtonPress",root,function(amount,price,item,priv,player)
    local rquant = getPlayerItemCount(source,item)
    local itemInMarket = false
    if not player then player = "N/A" end
        if rquant >= tonumber(amount) then
                    for i,v in ipairs(globalitems) do
                        if itemInMarket == false and v[1] == getAccountName(getPlayerAccount(source)) and v[2] == item and v[5] == player then
                            itemInMarket = true
                            local oldq = v[4]
                            if priv == false then
                                takePlayerItem(source,item,amount)
                                table.remove(globalitems,i)
                                table.insert(globalitems,{getAccountName(getPlayerAccount(source)),item,price,tonumber(amount + oldq),"N/A"})
                            elseif priv == true and getPlayerFromName(player) then
                                takePlayerItem(source,item,amount)
                                table.remove(globalitems,i)
                                table.insert(globalitems,{getAccountName(getPlayerAccount(source)),item,price,tonumber(amount + oldq),player})
                            elseif priv == true and not getPlayerFromName(player) then
                                exports["SAUGMessages"]:sendClientMessage("No such player with that name!",source,255,255,0)
                            end
                            triggerClientEvent(source,"updateMyMarket",source,{["item"]=item,["quant"]=tonumber(amount + oldq),["price"]=price,["to"]=player},"add",i)
                            triggerClientEvent(source,"updateAllMarket",source,globalitems)
                            break
                        end
                    end
                if itemInMarket == false then
                    if priv == false then
                        takePlayerItem(source,item,amount)
                        table.insert(globalitems,{getAccountName(getPlayerAccount(source)),item,price,tonumber(amount),"N/A"})
                    elseif priv == true and getPlayerFromName(player) then
                        takePlayerItem(source,item,amount)
                        table.insert(globalitems,{getAccountName(getPlayerAccount(source)),item,price,tonumber(amount),player})
                    elseif priv == true and not getPlayerFromName(player) then
                        exports["SAUGMessages"]:sendClientMessage("No such player with that name!",source,255,255,0)
                    end
                    triggerClientEvent(source,"updateMyMarket",source,{["item"]=item,["quant"]=tonumber(amount),["price"]=price,["to"]=player},"set")
                    triggerClientEvent(source,"updateAllMarket",source,globalitems)
                end
        end
end)

addEvent("onRemoveMarketButtonPress",true)
addEventHandler("onRemoveMarketButtonPress",root,function(amount,quant,item,player)
    if tonumber(amount) <= tonumber(quant) then
        for i,v in ipairs(globalitems) do
            local name = v[1]
            local itemn = v[2]
            local price = v[3]
            local quant = v[4]
            local to = v[5]
            if name == getAccountName(getPlayerAccount(source)) and itemn == item and to == player and tonumber(quant) == tonumber(amount) then
                table.remove(globalitems,i)
                addPlayerItem(source,item,amount)
                triggerClientEvent(source,"updateAllMarket",source,globalitems)
            elseif name == getAccountName(getPlayerAccount(source)) and itemn == item and tonumber(quant) > tonumber(amount) then
                table.remove(globalitems,i)
                table.insert(globalitems,{getAccountName(getPlayerAccount(source)),item,price,tonumber(quant - amount),to})
                addPlayerItem(source,item,amount)
                triggerClientEvent(source,"updateAllMarket",source,globalitems)
            end
        end
    end
end)

addEvent("onBuyMarketButtonPress",true)
addEventHandler("onBuyMarketButtonPress",root,function(name,amount,item,price,quant,player)
    local money = getPlayerMoney(source)
        if money >= tonumber(amount)*tonumber(price) then
            for i,v in ipairs(globalitems) do
                if v[1] == name and v[2] == item and (player == "N/A" or getPlayerName(source) == player) then
                    if v[4] == tonumber(amount) then
                        table.remove(globalitems,i)
                        takePlayerMoney(source,tonumber(amount)*tonumber(price))
                        addPlayerItem(source,item,amount)
                        exports["SAUGMessages"]:sendClientMessage("You bought "..amount.."x "..item..".",source,0,255,0)
                        triggerClientEvent(source,"updateAllMarket",source,globalitems)
                        for i,v in ipairs(getElementsByType("player")) do
                        if getAccountName(getPlayerAccount(v)) == name then
                            givePlayerMoney(v,tonumber(amount)*tonumber(price))
                            exports["SAUGMessages"]:sendClientMessage("You recieved $"..(tonumber(amount)*tonumber(price)).." from "..getPlayerName(source).." (TRADE)",v,0,255,0)
                        end
            end
                    elseif v[4] > tonumber(amount) then
                        table.insert(globalitems,{name,item,price,tonumber(quant-amount),v[5]})
                        table.remove(globalitems,i)
                        takePlayerMoney(source,tonumber(amount)*tonumber(price))
                        addPlayerItem(source,item,amount)
                        exports["SAUGMessages"]:sendClientMessage("You bought "..amount.."x "..item..".",source,0,255,0)
                        triggerClientEvent(source,"updateAllMarket",source,globalitems)
                        for i,v in ipairs(getElementsByType("player")) do
                            if getAccountName(getPlayerAccount(v)) == name then
                                givePlayerMoney(v,tonumber(amount)*tonumber(price))
                                exports["SAUGMessages"]:sendClientMessage("You recieved $"..(tonumber(amount)*tonumber(price)).." from "..getPlayerName(source).." (TRADE)",v,0,255,0)
                            end
                        end
                    end
                end
            end
        end
end)


addEventHandler("onResourceStop",resourceRoot,function()
    for i,v in ipairs(globalitems) do
        for k,player in ipairs(getElementsByType("player")) do
            local account = getAccountName(getPlayerAccount(player))
                if v[1] == account then
                    addPlayerItem(player,v[2],v[4])
                end
        end
    end
end)

addEvent("clientUpdateMyMarket",true)
addEventHandler("clientUpdateMyMarket",root,function()
    local acc = getAccountName(getPlayerAccount(source))
    local mymarket = {}
        for i,v in ipairs(globalitems) do
            if v[1] == acc then
                table.insert(mymarket,{["item"]=v[2],["quant"]=v[4],["price"]=v[3],["to"]=v[5]})
            end
        end
        triggerClientEvent(source,"updateMyMarket",source,mymarket,"new")
end)

setTimer(function()
    for i,v in ipairs(getElementsByType("player")) do
        triggerClientEvent(v,"updateAllMarket",v,globalitems,"onlyglobal")
    end
end,5000,0)










 

Link to comment
  • MTA Anti-Cheat Team
23 hours ago, Knuck said:

@Dutchman101 this is stolen script.

from SAEG RPG

https://forum.multitheftauto.com/topic/46410-stolen-resource-accusations/

Please stick with that and stay on-topic, unless you're ready to show evidence that leaked/stolen code is being posted here. In that case, use the 'report post' function.. please don't post here again (or respond to me), we're back on-topic now.

Link to comment

 

On 04/10/2018 at 00:41, sanyisasha said:

Still not see addCommandHandler or bindKey :D

bind in client + command in server.lua

Edited by Dutchman101
Edited out offensive part, please do not argue in here again or start a flamewar
Link to comment
  • 3 years later...

You've done a great job! The code looks good, but I didn't find a block that would be responsible for the client card. I'm not sure that your customer will like the unfinished work. I also advise you to review a few commands from the first part of the code.  Sometimes writing a practical program without trading experience or participation in transactions is difficult. When I had such a problem, I filled in the knowledge on https://www.youngandthrifty.ca/how-to-buy-stocks-in-canada/.  Some of my clients have sent me links to educational material or videos on YouTube that would help me better understand a particular area of financial trading.

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