WTF_ Posted December 2, 2017 Share Posted December 2, 2017 executeSQLQuery( ' CREATE TABLE IF NOT EXISTS `weaponAmmo` (account, weapon, ammo) ' ) addEventHandler ( "onPlayerQuit", root , function ( ) local checkData = executeSQLQuery( ' SELECT * FROM `weaponAmmo` WHERE account = ? ', getPlayerAccount(source) ) local ammoo = getPedTotalAmmo ( source ) local weaponn = getPedWeapon ( source ) if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData ) and not isGuestAccount ( source ) then executeSQLQuery( ' INSERT INTO `weaponAmmo` (account, weapon, ammo) VALUES(?, ?, ?) ', getPlayerAccount(source), ammoo, weaponn ) else executeSQLQuery( ' UPDATE`weaponAmmo` SET weapon = ? , ammo = ? WHERE account = ? ', getPlayerAccount(source), ammoo, weaponn ) end end ) addEventHandler("onPlayerLogin", root, function() local weaponn1 = executeSQLQuery( ' SELECT * FROM `weaponAmmo` WHERE account = ? ', getPlayerAccount(source) ) if ( type ( weaponn1 ) == 'table' and #weaponn1 == 0 or not weaponn1 ) then else local wp = weaponn1[1]['weapon'] local am = weaponn1[1]['ammo'] local wpp = getWeaponIDFromName ( wp ) giveWeapon ( source , wpp , am ) end end ) Link to comment
Abu-Solo Posted December 2, 2017 Share Posted December 2, 2017 طيب ويش المشكله؟ debugscript 3 ? Link to comment
WTF_ Posted December 2, 2017 Author Share Posted December 2, 2017 ولا شي ولا يعطيني الأسلح لما اخش 32 minutes ago, Abu-Solo said: طيب ويش المشكله؟ debugscript 3 ? وفي اللوق بيقول مشكلة في فاكشن giveweaponX Link to comment
Adham Posted December 3, 2017 Share Posted December 3, 2017 if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData and not isGuestAccount ( source ) ) then Link to comment
WTF_ Posted December 3, 2017 Author Share Posted December 3, 2017 14 minutes ago, -Le[3]bA. said: if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData and not isGuestAccount ( source ) ) then خخخخخخخخخخخخ بالله يا أخوي قول شي تفهمه مشان ما رح يفرق شي والمشكلة مو من التحقق :// على كل حال شكرا لمحاولت المساعدة Link to comment
Adham Posted December 3, 2017 Share Posted December 3, 2017 (edited) 14 minutes ago, WTF_ said: خخخخخخخخخخخخ بالله يا أخوي قول شي تفهمه مشان ما رح يفرق شي والمشكلة مو من التحقق :// على كل حال شكرا لمحاولت المساعدة ي حبيبي شوف كودك if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData ) and not isGuestAccount ( source ) then كيف قافل التحقق ؟ واطرح الدي بق عشان نعرف المشكله م راح نعرفها تلقائي وعدل السطر ذا إلي giveWeapon ( source , wpp , am ) -- to giveWeapon ( source , wpp , am, true ) Edited December 3, 2017 by -Le[3]bA. Link to comment
Master_MTA Posted December 3, 2017 Share Posted December 3, 2017 2 hours ago, -Le[3]bA. said: شوف كودك التحقق حقه سليم مافيه مشكله لكن التحقق الخاص بك يا غالي راح يسبب مشاكل ليش لانه لما يجي يتحقق ينفذ اول شي بالترتيب العمليات ما بين الاقواس فهمت علي؟ Link to comment
Bssol Posted December 4, 2017 Share Posted December 4, 2017 (edited) executeSQLQuery( 'CREATE TABLE IF NOT EXISTS `weaponAmmo` (account TEXT, weapon NUMERIC, ammo NUMERIC)' ) function onPlayerQuit( ) local playerAccount = getPlayerAccount(source) if ( playerAccount ) and ( not isGuestAccount(playerAccount) ) then local accountName = getAccountName(playerAccount) local checkData = executeSQLQuery( 'SELECT * FROM `weaponAmmo` WHERE account=?', accountName ) local ammoo = getPedTotalAmmo ( source ) local weaponn = getPedWeapon ( source ) if ( #checkData == 0 ) then executeSQLQuery( 'INSERT INTO `weaponAmmo` (account,weapon,ammo) VALUES(?,?,?)', accountName, weaponn, ammoo ) else executeSQLQuery( 'UPDATE `weaponAmmo` SET weapon=?,ammo=? WHERE account=?', weaponn, ammoo, accountName ) end end end addEventHandler ( "onPlayerQuit", root , onPlayerQuit ) function onPlayerLogin() local playerAccount = getPlayerAccount(source) local accountName = getAccountName(playerAccount) local weaponn1 = executeSQLQuery( 'SELECT * FROM `weaponAmmo` WHERE account=?', accountName ) if ( #weaponn1 ~= 0 ) then local wp = weaponn1[1]['weapon'] local am = weaponn1[1]['ammo'] giveWeapon ( source, wp, am ) end end addEventHandler("onPlayerLogin", root, onPlayerLogin ) الكود غير مجرب، جربه ورد لنا خبر Edited December 4, 2017 by Bssol Link to comment
WTF_ Posted December 4, 2017 Author Share Posted December 4, 2017 9 hours ago, Bssol said: executeSQLQuery( 'CREATE TABLE IF NOT EXISTS `weaponAmmo` (account TEXT, weapon NUMERIC, ammo NUMERIC)' ) function onPlayerQuit( ) local playerAccount = getPlayerAccount(source) if ( playerAccount ) and ( not isGuestAccount(playerAccount) ) then local accountName = getAccountName(playerAccount) local checkData = executeSQLQuery( 'SELECT * FROM `weaponAmmo` WHERE account=?', accountName ) local ammoo = getPedTotalAmmo ( source ) local weaponn = getPedWeapon ( source ) if ( #checkData == 0 ) then executeSQLQuery( 'INSERT INTO `weaponAmmo` (account,weapon,ammo) VALUES(?,?,?)', accountName, weaponn, ammoo ) else executeSQLQuery( 'UPDATE `weaponAmmo` SET weapon=?,ammo=? WHERE account=?', weaponn, ammoo, accountName ) end end end addEventHandler ( "onPlayerQuit", root , onPlayerQuit ) function onPlayerLogin() local playerAccount = getPlayerAccount(source) local accountName = getAccountName(playerAccount) local weaponn1 = executeSQLQuery( 'SELECT * FROM `weaponAmmo` WHERE account=?', accountName ) if ( #weaponn1 ~= 0 ) then local wp = weaponn1[1]['weapon'] local am = weaponn1[1]['ammo'] giveWeapon ( source, wp, am ) end end addEventHandler("onPlayerLogin", root, onPlayerLogin ) الكود غير مجرب، جربه ورد لنا خبر أخوي جربته وضبط معي بس مو 100/100 يعني انا معي 10 أسلح بيعطيني سلاح واحد Link to comment
Rockyz Posted December 4, 2017 Share Posted December 4, 2017 (edited) addEventHandler('onResourceStart', root, function() local createdTable = executeSQLQuery('CREATE TABLE IF NOT EXISTS `restoreWeapons` (playerAccount, weaponsTable)'); end) function onPlayerQuit() local playerAccount = getPlayerAccount(source) if playerAccount and not isGuestAccount(playerAccount) then local accountName = getAccountName(playerAccount) local checkData = executeSQLQuery('SELECT * FROM `restoreWeapons` WHERE playerAccount = ?', accountName) local weps = getPedWeapons(source); if weps and type(weps) == 'table' then local weapons = toJSON(weps) if type(checkData) == 'table' then if #checkData == 0 then executeSQLQuery('INSERT INTO `restoreWeapons` (playerAccount, weaponsTable) VALUES(?, ?)', accountName, weapons) else executeSQLQuery('UPDATE `restoreWeapons` SET weaponsTable = ? WHERE playerAccount = ?', weapons, accountName) end end end end end addEventHandler('onPlayerQuit', root, onPlayerQuit) function onPlayerLogin(_, acc) local accountName = getAccountName(acc) local checkData = executeSQLQuery('SELECT * FROM `restoreWeapons` WHERE playerAccount = ?', accountName) if type(checkData) == 'table' and #checkData > 0 then local weapons = fromJSON(checkData[1].weaponsTable) if weapons and type(weapons) == 'table' then for _, weaponz in ipairs(weapons) do if weaponz.weapon and weaponz.ammo then giveWeapon(source, weaponz.weapon, weaponz.ammo); end end end end end addEventHandler('onPlayerLogin', root, onPlayerLogin) function getPedWeapons(ped) local playerWeapons = {} if ped and isElement(ped) and getElementType(ped) == 'ped' or getElementType(ped) == 'player' then for i=2,9 do local wep = getPedWeapon(ped,i) if wep and wep ~= 0 then table.insert(playerWeapons, {weapon = wep, ammo = getPedTotalAmmo(ped, i)}) end end else return false end return playerWeapons end Edited December 4, 2017 by #,+( _xiRoc[K]; > 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