DaHoM Posted August 2, 2017 Share Posted August 2, 2017 السلام عليكم ورحمة الله وبركاتة function RGBToHex(red, green, blue) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) ) then return nil end return string.format("#%.2X%.2X%.2X", red,green,blue) end function outputChat(text,who,r,g,b) local color = RGBToHex(r,g,b) --exports["vMZ-TopBar"]:sendClientMessage ("#98AFC7[Market System] "..color..""..text.."",who,r,g,b,true) outputChatBox ("#98AFC7[Market System] "..color..""..text.."",who,r,g,b,true) end addEventHandler( "onResourceStart", resourceRoot, function () ModerMarketDB = dbConnect("sqlite","Market.db") dbExec(ModerMarketDB, "CREATE TABLE IF NOT EXISTS Market_Trading ( ware, amount, price, player, PlayerAccName )" ) end ); function getAllWareInShop( Player ) local Ware = dbPoll( dbQuery(ModerMarketDB, "SELECT * FROM Market_Trading" ), -1) local WeaponsPlayer = dbPoll( dbQuery(ModerMarketDB, "SELECT * FROM Market_Trading WHERE PlayerAccName=? ", getAccountName(getPlayerAccount(source)) ), -1) for i,v in ipairs(Ware) do if tonumber(v.amount) <= 0 then dbExec(ModerMarketDB, "DELETE FROM Market_Trading WHERE ware = ? AND amount = ?",v.ware, v.amount ) end end triggerClientEvent( root, "SetWareInlist", root, Ware ) triggerClientEvent( source, "SetWeaponsPlayerForSale", source, WeaponsPlayer ) end addEvent( "getAllWareInShop", true ) addEventHandler( "getAllWareInShop", root,getAllWareInShop) addEvent( "AddWareToShop", true ) addEventHandler( "AddWareToShop", root, function ( ID, Ammo, price, statr ) local Weapons = dbPoll( dbQuery(ModerMarketDB, "SELECT * FROM Market_Trading WHERE ware=? AND PlayerAccName=? ",ID, getAccountName(getPlayerAccount(source)) ), -1) if ( type (Weapons) == "table" and #Weapons == 0 or not Weapons ) then dbExec(ModerMarketDB, "INSERT INTO Market_Trading (ware,amount,price,player,PlayerAccName) VALUES(?,?,?,?,?) ", ID, Ammo, price , getPlayerName ( source ),getAccountName(getPlayerAccount(source)) ) else local NewAmmo = tonumber ( Weapons[1]["amount"] ) + tonumber ( Ammo ) dbExec(ModerMarketDB, "UPDATE Market_Trading SET amount=? WHERE ware = ? AND PlayerAccName = ?",NewAmmo, ID, getAccountName(getPlayerAccount(source))) end getAllWareInShop( source ) if statr == "Weapon" then takeWeapon(source,ID,Ammo) else setElementData(source,ID,(getElementData(source,ID) or 0 ) - tonumber ( Ammo )) end outputChat("You Have Putted "..ID.." Amount : "..Ammo.." on market By $"..price.."",source,0,255,0) end ); addEvent( "RemoveWareToShop", true ) addEventHandler( "RemoveWareToShop", root, function ( ID, Ammo, statr ) dbExec(ModerMarketDB, "DELETE FROM Market_Trading WHERE ware = ? AND PlayerAccName = ?",ID , getAccountName(getPlayerAccount(source))) if statr == "Weapon" then giveWeapon(source,ID,Ammo) else setElementData(source,ID,(getElementData(source,ID) or 0 ) + tonumber ( Ammo )) end getAllWareInShop( source ) end ); addEvent( "BuyWareInmarket", true ) addEventHandler( "BuyWareInmarket", root, function ( name, ID, Ammo, Money, TotalAmmo, statr ) if getPlayerMoney ( source ) >= tonumber ( Money ) then local Player = getPlayerFromName ( name ) local accName = getAccountName(getPlayerAccount(Player)) givePlayerMoney ( Player, tonumber ( Money ) ) getElementData(localPlayer, "Money")( source, tonumber ( Money ) ) if localPlayer == getPlayerFromName ( name ) then outputChatBox("You can not buy from yourself !",255,0,0) return end if statr == "Weapon" then giveWeapon(source,ID,Ammo) outputChat("You Have Bought a weapon "..getWeaponNameFromID ( ID ).." and "..Ammo.." Ammo By $"..Money.." From "..name,source,0,255,0) outputChat(getPlayerName(source).." Has bought a "..getWeaponNameFromID ( ID ).." and "..Ammo.." Ammo By $"..Money,Player,0,255,0) else setElementData(source,ID,(getElementData(source,ID) or 0 ) + tonumber ( Ammo )) outputChat("You Have Bought ( "..Ammo.." "..ID.." ) By $"..Money.." From"..name,source,0,255,0) outputChat(getPlayerName(source).." Has bought From you a ( "..Ammo.." "..ID.." ) By $"..Money.."",Player,0,255,0) end getAllWareInShop( source ) getAllWareInShop( Player ) local NewAmmo = tonumber ( TotalAmmo ) - tonumber ( Ammo ) dbExec( ModerMarketDB, "UPDATE Market_Trading SET amount=? WHERE ware = ? AND PlayerAccName = ?",NewAmmo, ID, accName ) else outputChat("You Don't Have Enough Money .",source,255,0,0) end end ); addEventHandler("onPlayerLogin", root, function () local accName = getAccountName(getPlayerAccount(source)) local Market = dbPoll( dbQuery(ModerMarketDB, "SELECT * FROM Market_Trading "), -1) givePlayerMoney(source,150) if (type(Market) == "table" and #Market == 0) or not Market then return end for i,v in ipairs(Market) do if v.PlayerAccName == accName then dbExec( ModerMarketDB, "UPDATE Market_Trading SET player=? WHERE PlayerAccName=?", getPlayerName(source), accName ) getAllWareInShop( source ) end end end ); addEventHandler("onPlayerChangeNick", root, function (oldNick, newNick) if not isGuestAccount( getPlayerAccount( source ) ) then local accName = getAccountName(getPlayerAccount(source)) local Market = dbPoll( dbQuery(ModerMarketDB, "SELECT * FROM Market_Trading "), -1) if (type(Market) == "table" and #Market == 0) or not Market then return end for i,v in ipairs(Market) do if v.PlayerAccName == accName then dbExec( ModerMarketDB,"UPDATE Market_Trading SET player=? WHERE PlayerAccName=?", newNick, accName) getAllWareInShop( source ) end end end end ); مساعده في تحويل الكود دا من سيرفر الي سيلنت عشان مشكله الفلوس الوهميه كل اما اشغله مو يحسب انه فيه فلوس ودا لينك المود اذا حد يبي يعدلي او يعدلي في الكومنتات شكرا جدا للي هيردكل دا عشان الفلوس في الجيم مود عندي سلينت مو سيرفر لذلك لازم كل المودات كلينت Link to comment
#BrosS Posted August 2, 2017 Share Posted August 2, 2017 اتوقع الجيم مود حقك حرب عصابات صح . معظمهم يستخدمون الفلوس بالداتا . قول عشان استبدلك الأكواد 1 Link to comment
DaHoM Posted August 2, 2017 Author Share Posted August 2, 2017 10 minutes ago, #BrosS said: اتوقع الجيم مود حقك حرب عصابات صح . معظمهم يستخدمون الفلوس بالداتا . قول عشان استبدلك الأكواد يب اخوي6 Link to comment
#BrosS Posted August 2, 2017 Share Posted August 2, 2017 addEvent( "BuyWareInmarket", true ) addEventHandler( "BuyWareInmarket", root, function ( name, ID, Ammo, Money, TotalAmmo, statr ) if (getElementData(source, "Money") or 0) >= tonumber(Money) then local Player = getPlayerFromName ( name ) local accName = getAccountName(getPlayerAccount(Player)) setElementData(Player, "Money", (getElementData(Player, "Money")or 0 ) + tonumber(Money) if localPlayer == getPlayerFromName ( name ) then outputChatBox("You can not buy from yourself !",255,0,0) return end if statr == "Weapon" then giveWeapon(source,ID,Ammo) outputChat("You Have Bought a weapon "..getWeaponNameFromID ( ID ).." and "..Ammo.." Ammo By $"..Money.." From "..name,source,0,255,0) outputChat(getPlayerName(source).." Has bought a "..getWeaponNameFromID ( ID ).." and "..Ammo.." Ammo By $"..Money,Player,0,255,0) else setElementData(source,ID,(getElementData(source,ID) or 0 ) + tonumber ( Ammo )) outputChat("You Have Bought ( "..Ammo.." "..ID.." ) By $"..Money.." From"..name,source,0,255,0) outputChat(getPlayerName(source).." Has bought From you a ( "..Ammo.." "..ID.." ) By $"..Money.."",Player,0,255,0) end getAllWareInShop( source ) getAllWareInShop( Player ) local NewAmmo = tonumber ( TotalAmmo ) - tonumber ( Ammo ) dbExec( ModerMarketDB, "UPDATE Market_Trading SET amount=? WHERE ware = ? AND PlayerAccName = ?",NewAmmo, ID, accName ) else outputChat("You Don't Have Enough Money .",source,255,0,0) end end ); addEventHandler("onPlayerLogin", root, function () local accName = getAccountName(getPlayerAccount(source)) local Market = dbPoll( dbQuery(ModerMarketDB, "SELECT * FROM Market_Trading "), -1) setElementData(source, "Money", (getElementData(source, "Money")or 0 ) + 150) if (type(Market) == "table" and #Market == 0) or not Market then return end for i,v in ipairs(Market) do if v.PlayerAccName == accName then dbExec( ModerMarketDB, "UPDATE Market_Trading SET player=? WHERE PlayerAccName=?", getPlayerName(source), accName ) getAllWareInShop( source ) end end end ); 1 Link to comment
#BrosS Posted August 2, 2017 Share Posted August 2, 2017 11 minutes ago, Default said: سطر 7 ناقص قوس . ذذ م انتبهت ما اقدر اعدل وكسلان احط من جديد بالجوال ذا Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now