Jump to content

مساعدة في executeSQLQuery


WTF_

Recommended Posts

Posted
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 
  )
  

 

Posted

طيب ويش المشكله؟

debugscript 3 ?

 

721195519.png

595770773.png

 

76561198277320954.pngAddFriend.png

خلك احسن من غيرك,

لا تقول عندهم اشياء ماهي عندي

انت عندك اشياء ماهي عند غيرك #

Posted

ولا شي ولا يعطيني الأسلح لما اخش 

32 minutes ago, Abu-Solo said:

طيب ويش المشكله؟

debugscript 3 ?

وفي اللوق بيقول مشكلة في فاكشن giveweaponX

Posted
if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData and not isGuestAccount ( source ) ) then

 

 

قد تكونآمنيآتنآ حزينه !وآحلآمُنآ ملت طآبور آلإنتِظآر لكنهآ ،تتشبث بآلأمل فنفوسُنآ خُلقت لتقول غداً آجمل B-18.png 

Posted
14 minutes ago, -Le[3]bA. said:

if ( type ( checkData ) == 'table' and #checkData == 0 or not checkData and not isGuestAccount ( source ) ) then

 

خخخخخخخخخخخخ بالله يا أخوي قول شي تفهمه مشان ما رح يفرق شي والمشكلة مو من التحقق ://

على كل حال شكرا لمحاولت المساعدة :)

Posted (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 by -Le[3]bA.

 

قد تكونآمنيآتنآ حزينه !وآحلآمُنآ ملت طآبور آلإنتِظآر لكنهآ ،تتشبث بآلأمل فنفوسُنآ خُلقت لتقول غداً آجمل B-18.png 

Posted
2 hours ago, -Le[3]bA. said:

شوف كودك

التحقق حقه سليم مافيه مشكله

لكن التحقق الخاص بك يا غالي راح يسبب مشاكل ليش

لانه لما يجي يتحقق ينفذ اول شي بالترتيب العمليات ما بين الاقواس فهمت علي؟

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted (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 by Bssol
Posted
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 أسلح بيعطيني سلاح واحد :'(

Posted (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 by #,+( _xiRoc[K]; >

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