السلام عليكم انا اليوم لقيت مود تبع f7 حق بيع الاسلحه و الانشر
بس في مشكله لما اجي اضيف سلاح للبيع ما ينضاف الاكواد اهي
Clinet
GUIEditor = {
edit = {},
button = {},
window = {},
label = {},
gridlist = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
function()
GUIEditor.window[3] = guiCreateWindow(165, 45, 861, 603, "F7 - CSF Trading/Market Interface", false)
guiWindowSetSizable(GUIEditor.window[3], false)
guiSetVisible(GUIEditor.window[3], false)
remove_item_list = guiCreateGridList(22, 457, 308, 133, false, GUIEditor.window[3])
remove_item_col1 = guiGridListAddColumn(remove_item_list, "Item", 0.5)
remove_item_col2 = guiGridListAddColumn(remove_item_list, "Amount", 0.5)
GUIEditor.button[7] = guiCreateButton(205, 410, 125, 37, "Remove selected item from sale", false, GUIEditor.window[3])
guiSetFont(GUIEditor.button[7], "default-bold-small")
guiSetProperty(GUIEditor.button[7], "NormalTextColour", "FFFF0000")
addEventHandler ( "onClientGUIClick", GUIEditor.button[7], outputEditBox2, false )
GUIEditor.label[5] = guiCreateLabel(30, 433, 290, 28, "My item for sale", false, GUIEditor.window[3])
guiSetFont(GUIEditor.label[5], "default-bold-small")
add_item_list = guiCreateGridList(12, 65, 328, 153, false, GUIEditor.window[3])
add_item_col1 = guiGridListAddColumn(add_item_list, "Item", 0.5)
add_item_col2 = guiGridListAddColumn(add_item_list, "Amount", 0.5)
GUIEditor.label[6] = guiCreateLabel(15, 33, 315, 22, "Put an item up for sale...", false, GUIEditor.window[3])
guiSetFont(GUIEditor.label[6], "default-bold-small")
add_item_price = guiCreateEdit(97, 281, 62, 27, "", false, GUIEditor.window[3])
guiEditSetMaxLength(add_item_price, -- s8) -->
guiSetProperty(add_item_price, "ValidationString", "^[0-9]*$")
GUIEditor.button[8] = guiCreateButton(169, 234, 126, 37, "Put the selected item up for sale", false, GUIEditor.window[3])
guiSetFont(GUIEditor.button[8], "default-bold-small")
addEventHandler ( "onClientGUIClick", GUIEditor.button[8], outputEditBox, false )
items_list = guiCreateGridList(376, 36, 462, 495, false, GUIEditor.window[3])
items_col1 = guiGridListAddColumn(items_list, "Item", 0.2)
items_col2 = guiGridListAddColumn(items_list, "Amount", 0.2)
items_col3 = guiGridListAddColumn(items_list, "Price", 0.2)
items_col4 = guiGridListAddColumn(items_list, "Seller", 0.3)
GUIEditor.button[9] = guiCreateButton(728, 539, 100, 30, "Buy Selected amount of item", false, GUIEditor.window[3])
guiSetFont(GUIEditor.button[9], "default-bold-small")
addEventHandler ( "onClientGUIClick", GUIEditor.button[9], outputEditBox3, false )
buy_select_edit = guiCreateEdit(650, 545, 68, 24, "", false, GUIEditor.window[3])
guiSetProperty(buy_select_edit, "ValidationString", "^[0-9]*$")
GUIEditor.label[7] = guiCreateLabel(8, 287, 89, 16, "Price For Each:", false, GUIEditor.window[3])
GUIEditor.label[8] = guiCreateLabel(18, 250, 53, 15, "Amount:", false, GUIEditor.window[3])
GUIEditor.label[5] = guiCreateLabel(171, 286, 124, 22, "Total: $0", false, GUIEditor.window[3])
add_item_amount = guiCreateEdit(76, 244, 81, 27, "", false, GUIEditor.window[3])
addEventHandler("onClientGUIChanged", add_item_price, totalthing)
addEventHandler("onClientGUIChanged", add_item_amount, totalthing)
addEventHandler("onClientGUIChanged", buy_select_edit, totalthing2)
guiEditSetMaxLength(add_item_amount, -- s8) -->
guiSetProperty(add_item_amount, "ValidationString", "^[0-9]*$")
GUIEditor.label[9] = guiCreateLabel(354, 21, 22, 582, "|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n", false, GUIEditor.window[3])
guiSetFont(GUIEditor.label[9], "default-bold-small")
GUIEditor.label[10] = guiCreateLabel(592, 548, 48, 20, "Amount:", false, GUIEditor.window[3])
GUIEditor.label[11] = guiCreateLabel(0, 373, 354, 15, "____________________________________________________________________________________________________", false, GUIEditor.window[3])
guiSetFont(GUIEditor.label[11], "default-bold-small")
GUIEditor.label[12] = guiCreateLabel(645, 571, 124, 22, "Total: $0", false, GUIEditor.window[3])
refreshbut = guiCreateButton(385, 546, 113, 17, "Refresh..", false, GUIEditor.window[3])
addEventHandler ( "onClientGUIClick", refreshbut, refresh, false )
end
)
function guishow (key,keyst)
--if getElementInterior(localPlayer) ~= 0 then exports.CSFtexts:output("You can't open store menu in other interior",255,0,0) return end
local bool = not guiGetVisible(GUIEditor.window[3])
guiSetVisible(GUIEditor.window[3],bool)
setElementData(localPlayer,"shopOpen",bool)
showCursor(bool)
refresh()
end
bindKey ( "F7", "down", guishow )
addCommandHandler("csfshop",guishow)
function getamo(weapon,amo)
if weapon == "Rocket Launcher" then return end
local weapon = tostring(weapon)
local amo = tostring(amo)
local row = guiGridListAddRow ( add_item_list )
guiGridListSetItemText ( add_item_list, row, add_item_col1, weapon, false, false )
guiGridListSetItemText ( add_item_list, row, add_item_col2, amo, false, true )
end
addEvent("CSFselling.Clientammo", true)
addEventHandler("CSFselling.Clientammo", root, getamo)
function totalthing()
if tonumber(guiGetText(add_item_price)) > 0 and tonumber(guiGetText(add_item_amount)) > 0 then
guiSetText(GUIEditor.label[5], "Total: $"..tostring(tonumber(guiGetText(add_item_price))* tonumber(guiGetText(add_item_amount))) )
end
end
function totalthing2()
if tonumber(guiGetText(buy_select_edit)) > 0 and tonumber(guiGridListGetSelectedItemText( items_list, 3 )) > 0 then
guiSetText(GUIEditor.label[12], "Total: $"..tostring(tonumber(guiGetText(buy_select_edit))* tonumber(guiGridListGetSelectedItemText( items_list, 3 ))) )
end
end
function getitems(weapon,amo,owner,price)
if weapon == "Rocket Launcher" then return end
if not owner then return end
local weapon = tostring(weapon)
local amo = tostring(amo)
local owner = tostring(owner)
local row = guiGridListAddRow ( items_list )
guiGridListSetItemText ( items_list, row, items_col1, weapon, false, false )
guiGridListSetItemText ( items_list, row, items_col2, amo, false, true )
guiGridListSetItemText ( items_list, row, items_col3, price, false, true )
guiGridListSetItemText ( items_list, row, items_col4, owner, false, false )
end
addEvent("CSFselling.Getitems", true)
addEventHandler("CSFselling.Getitems", root, getitems)
function remoitems(weapon,amo)
local weapon = tostring(weapon)
local amo = tostring(amo)
local row = guiGridListAddRow ( remove_item_list )
guiGridListSetItemText ( remove_item_list, row, remove_item_col1, weapon, false, false )
guiGridListSetItemText ( remove_item_list, row, remove_item_col2, amo, false, true )
end
addEvent("CSFselling.removeable", true)
addEventHandler("CSFselling.removeable", root, remoitems)
function guiGridListGetSelectedItemText ( gridList, column )
local item = guiGridListGetSelectedItem ( gridList )
if item then
return guiGridListGetItemText ( gridList, item, column or 1 )
end
return false
end
function outputEditBox ( button )
if button == "left" then
local amount = tonumber(guiGetText ( add_item_amount ))
local price = tonumber(guiGetText ( add_item_price ))
local item = tostring(guiGridListGetSelectedItemText( add_item_list ))
local ammo = tonumber(guiGridListGetSelectedItemText( add_item_list, 2 ))
if amount and amount ~= "" and tonumber(amount) then
if price and price ~= "" and tonumber(price) then
if item and item ~= "" then
if amount <= ammo then
if price > 1 then
if amount > 0 then
triggerServerEvent ( "CSFselling.SellThing", localPlayer, item, amount, price )
refresh()
end
end
end
end
end
end
end
end
function outputEditBox2 ( button )
if button == "left" then
local item = tostring(guiGridListGetSelectedItemText( remove_item_list ))
local ammo = tonumber(guiGridListGetSelectedItemText( remove_item_list, 2 ))
if ammo and ammo ~= "" and tonumber(ammo) then
if item and item ~= "" then
triggerServerEvent ( "CSFselling.RemoveThing", localPlayer, item, ammo )
refresh()
end
end
end
end
function outputEditBox3 ( button )
if button == "left" then
local amount = tonumber(guiGetText ( buy_select_edit ))
local item = tostring(guiGridListGetSelectedItemText( items_list, 1 ))
local ammo = tonumber(guiGridListGetSelectedItemText( items_list, 2 ))
local price = tonumber(guiGridListGetSelectedItemText( items_list, 3 )) * amount
local seller = tostring(guiGridListGetSelectedItemText( items_list, 4 ))
local bool
if amount and amount ~= "" and tonumber(amount) then
if price and price ~= "" and tonumber(price) then
if item and item ~= "" then
if amount <= ammo then
if price > 1 then
if amount > 0 then
if amount == ammo then bool = false end
if amount < ammo then bool = ammo-amount end
triggerServerEvent ( "CSFselling.BuyThing", localPlayer, item, amount, seller, bool, price, ammo )
--refresh()
end
end
end
end
end
end
end
end
function refresh()
if guiGetVisible(GUIEditor.window[3]) then
guiGridListClear(remove_item_list)
guiGridListClear(add_item_list)
guiGridListClear(items_list)
triggerServerEvent ( "CSFselling.ServerShow", localPlayer )
end
end
addEvent("CSFselling.refreshShow",true)
addEventHandler("CSFselling.refreshShow", root, refresh)
--setTimer(refresh,10000,0)
function disableFlares ( creator )
if (getElementInterior(localPlayer) ~= 0) or (getElementDimension(localPlayer) ~= 0) then
if (creator == localPlayer) then
exports.CSFtexts:output("You can't make this in other interior/dimension!", 255, 0, 0)
setElementPosition(source, 9000, 9000, 0)
end
end
end
addEventHandler( "onClientProjectileCreation", getRootElement(), disableFlares ) -- when a projectile gets created call disableFlares.
Server
function showsgui () p = client t = {} local weaponSlots = {0,1,2,3,4,5,6,7,8,9,10,11,12} for i, slot in ipairs(weaponSlots) do local ammo = getPlayerTotalAmmo ( p, slot ) if ( getPlayerWeapon ( p, slot ) ~= 0 ) then local weapon = getPlayerWeapon ( p, slot ) local ammo = getPlayerTotalAmmo ( p, slot ) table.insert(t, {weapon, ammo}) end end for k,v in pairs(t) do if v[1] > 0 and v[2] > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, getWeaponNameFromID(v[1]), v[2] ) end end local god = getPlayerData(p,"god") local heroin = getPlayerData(p,"heroin") local speed = getPlayerData(p,"speed") local weed = getPlayerData(p,"weed") local steroids = getPlayerData(p,"steroids") local lsd = getPlayerData(p,"lsd") local iron = getPlayerData(p,"iron") local oil = getPlayerData(p,"oil") local plastic = getPlayerData(p,"plastic") local silver = getPlayerData(p,"silver") local gold = getPlayerData(p,"gold") local explosives = getPlayerData(p,"explosives") local electronics = getPlayerData(p,"electronics") local hemp = getPlayerData(p,"hemp") local temp = getPlayerData(p,"temp") local pln = tonumber(getAccountNoumberOfPlant ( p )) or 0 local seeds = tonumber(getAccountSeeds ( p )) or 0 --local cars = exports.CSFvehsys:getPlayerVehicles(p) if god > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "God", god ) end if heroin > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "Heroin", heroin ) end if speed > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "Speed", speed ) end if weed > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "Weed", weed ) end if steroids > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "Steroids", steroids ) end if lsd > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "LSD", lsd ) end if iron > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "iron", iron ) end if pln > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "Plant", pln ) end if seeds > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "Seed", seeds ) end if oil > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "oil", oil ) end if plastic > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "plastic", plastic ) end if silver > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "silver", silver ) end if gold > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "gold", gold ) end if explosives > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "explosives", explosives ) end if electronics > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "electronics", electronics ) end if hemp > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "hemp", hemp ) end if temp > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "temp", temp ) end --if cars and #cars > 0 then for ind,data in ipairs(cars) do triggerClientEvent ( p, "CSFselling.Clientammo", p, getVehicleNameFromModel(data["Model"]), 1 ) end end local medkits = getElementData(p, "mK") if medkits and medkits > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "Med-Kit", medkits ) end local medkits = getElementData(p, "vipTime") if medkits and medkits > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "VIP Hours", medkits ) end local armor = math.floor(getPedArmor(client)) if armor and armor > 0 then triggerClientEvent ( p, "CSFselling.Clientammo", p, "Armor", armor ) end local tblasd = exports.DENmysql:query( "SELECT * FROM selling" ) if tblasd and #tblasd > 0 then for i,val in ipairs(tblasd) do local itemname = val.item if itemname == "god" then itemname = "God" end if itemname == "weed" then itemname = "Weed" end if itemname == "heroin" then itemname = "Heroin" end if itemname == "steroids" then itemname = "Steroids" end if itemname == "speed" then itemname = "Speed" end if itemname == "lsd" then itemname = "LSD" end if itemname == "iron" then itemname = "iron" end if itemname == "oil" then itemname = "oil" end if itemname == "plastic" then itemname = "plastic" end if itemname == "silver" then itemname = "silver" end if itemname == "explosives" then itemname = "explosives" end if itemname == "electronics" then itemname = "electronics" end if itemname == "hemp" then itemname = "hemp" end if itemname == "gold" then itemname = "gold" end if itemname == "temp" then itemname = "temp" end if getAccount(val.userid) and getAccountPlayer(getAccount(val.userid)) then useiname = getPlayerName(getAccountPlayer(getAccount(val.userid))) else useiname = false end triggerClientEvent ( p, "CSFselling.Getitems", p, itemname, val.amount, useiname, val.price ) end end local userid = getAccountName(getPlayerAccount(p)) local tblasd2 = exports.DENmysql:query( "SELECT * FROM selling WHERE userid=?", tostring(userid) ) if tblasd2 and #tblasd2 > 0 then for i,val2 in ipairs(tblasd2) do local itemname = val2.item if itemname == "god" then itemname = "God" end if itemname == "weed" then itemname = "Weed" end if itemname == "heroin" then itemname = "Heroin" end if itemname == "steroids" then itemname = "Steroids" end if itemname == "speed" then itemname = "Speed" end if itemname == "lsd" then itemname = "LSD" end if itemname == "iron" then itemname = "iron" end if itemname == "oil" then itemname = "oil" end if itemname == "plastic" then itemname = "plastic" end if itemname == "silver" then itemname = "silver" end if itemname == "explosives" then itemname = "explosives" end if itemname == "electronics" then itemname = "electronics" end if itemname == "hemp" then itemname = "hemp" end if itemname == "gold" then itemname = "gold" end if itemname == "temp" then itemname = "temp" end triggerClientEvent ( p, "CSFselling.removeable", p, itemname, val2.amount ) end end end addEvent("CSFselling.ServerShow",true) addEventHandler("CSFselling.ServerShow", root, showsgui) function getAccountNoumberOfPlant ( player ) local acc = getPlayerAccount(player) local accountName = getAccountName(acc) local result = executeSQLQuery ( "SELECT * FROM Playerplant WHERE accountName = ?", tostring ( accountName ) ) if ( type ( result ) == "table" and #result == 0 or not result ) then return "None" else return tonumber(result[ 1 ][ "noumberOfPlant" ]) end end function getAccountSeeds ( player ) local acc = getPlayerAccount(player) local accountName = getAccountName(acc) local result = executeSQLQuery ( "SELECT * FROM Playerplant WHERE accountName = ?", tostring ( accountName ) ) if ( type ( result ) == "table" and #result == 0 or not result ) then return "None" else return tonumber(result[ 1 ][ "seeds" ]) end end function setAccountNoumberOfPlant ( accountName,noumberOfPlant ) executeSQLQuery( "UPDATE `Playerplant` SET `noumberOfPlant` = '".. noumberOfPlant .."' WHERE accountName = '".. accountName .."'" ) end function setAccountSeeds ( accountName,seeds ) executeSQLQuery( "UPDATE `Playerplant` SET `seeds` = '".. seeds .."' WHERE accountName = '".. accountName .."'" ) end function getPlayerData(p,name) local ru = tonumber(getAccountData(getPlayerAccount(p),name)) or 0 return ru end function decPlayerData(p,name,num) local ru = tonumber(getAccountData(getPlayerAccount(p),name)) or 0 setAccountData(getPlayerAccount(p),name,ru-num) end function incPlayerData(p,name,num) local ru = tonumber(getAccountData(getPlayerAccount(p),name)) or 0 setAccountData(getPlayerAccount(p),name,ru+num) end function sellgui(item,amo,price) local userid = getAccountName(getPlayerAccount(client)) local tbl123123 = exports.DENmysql:query( "SELECT * FROM selling WHERE userid=?", tostring(userid) ) if tbl123123 and #tbl123123 > 0 then for i,val3 in ipairs(tbl123123) do local itemnames = val3.item if itemnames == item then exports.CSFtexts:output("You can't add an item you are already selling!",client,255,0,0) return end end end if item == "God" then local item = "god" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "Weed" then local item = "weed" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "Speed" then local item = "speed" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "Steroids" then local item = "steroids" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "Heroin" then local item = "heroin" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "LSD" then local item = "lsd" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "iron" then local item = "iron" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "oil" then local item = "oil" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "plastic" then local item = "plastic" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "silver" then local item = "silver" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",client,0,255,0) return end if item == "gold" then local item = "gold" decPlayerData(client,item,amo) exports.DENmysql:exec("INSERT INTO selling (userid,item,amount,price) VALUES (?,?,?,?)",tostring(userid), tostring(item), tonumber(amo), tonumber(price)) exports.CSFtexts:output("Item Added to Store successfully!",