Mmohab Posted April 10, 2020 Share Posted April 10, 2020 executeSQLQuery("CREATE TABLE IF NOT EXISTS `player_stats` (`username` TEXT, `Thirst` INT, `Hunger` INT)") addEventHandler("onPlayerQuit", function (Player) local atsh = getElementData(source, "Thirst") local hungry = getElementData(source, "Hunger") local username = getAccountName(getPlayerAccount(thePlayer)) local result = executeSQLQuery("SELECT * FROM player_stats WHERE `username` = ?", username) if (#result > 1) then executeSQLQuery("UPDATE `player_stats` SET `Hunger` = ?, `Thirst` = ? WHERE `username` = ?", hungry, atsh, username) else executeSQLQuery("INSERT INTO health (username, Thirst, Hunger) VALUES (?, ?, ?)", username, atsh, hungry) end end) addEventHandler("onPlayerLogin", root, function(_, account) local accountName = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE username = ?", accountName) if (#result > 1) then setElementData(source, "Thirst", result[1].Thirst) setElementData(source, "Hunger", result[1].Hunger) end end) هذا عشان مود الجوع والعطش بحيث ان لو اللاعب سجل خروج وجوعه 50 لما يرجع يصير جوعه 50 ما يصير 100 من فضلكم ساعدوني ليش هذا السكريبت ما يشتغل ؟ Link to comment
Infinity-War Posted April 10, 2020 Share Posted April 10, 2020 executeSQLQuery("CREATE TABLE IF NOT EXISTS `player_stats` (`username` TEXT, `Thirst` INT, `Hunger` INT)") addEventHandler("onPlayerQuit", root , function (Player) local atsh = getElementData(source, "Thirst") local hungry = getElementData(source, "Hunger") local account = getPlayerAccount(thePlayer) if ( isGuestAccount ( account ) ) then return end local username = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE `username` = ?", username) if (#result > 1) then executeSQLQuery("UPDATE `player_stats` SET `Hunger` = ?, `Thirst` = ? WHERE `username` = ?", hungry, atsh, username) else executeSQLQuery("INSERT INTO health (username, Thirst, Hunger) VALUES (?, ?, ?)", username, atsh, hungry) end end) addEventHandler("onPlayerLogin", root, function(_, account) local accountName = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE username = ?", accountName) if (#result > 1) then setElementData(source, "Thirst", result[1].Thirst) setElementData(source, "Hunger", result[1].Hunger) end end) Link to comment
Mmohab Posted April 10, 2020 Author Share Posted April 10, 2020 10 hours ago, Infinity-War said: executeSQLQuery("CREATE TABLE IF NOT EXISTS `player_stats` (`username` TEXT, `Thirst` INT, `Hunger` INT)") addEventHandler("onPlayerQuit", root , function (Player) local atsh = getElementData(source, "Thirst") local hungry = getElementData(source, "Hunger") local account = getPlayerAccount(thePlayer) if ( isGuestAccount ( account ) ) then return end local username = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE `username` = ?", username) if (#result > 1) then executeSQLQuery("UPDATE `player_stats` SET `Hunger` = ?, `Thirst` = ? WHERE `username` = ?", hungry, atsh, username) else executeSQLQuery("INSERT INTO health (username, Thirst, Hunger) VALUES (?, ?, ?)", username, atsh, hungry) end end) addEventHandler("onPlayerLogin", root, function(_, account) local accountName = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE username = ?", accountName) if (#result > 1) then setElementData(source, "Thirst", result[1].Thirst) setElementData(source, "Hunger", result[1].Hunger) end end) Iam using OwlGaming Backup so .. i think this is the problem bcuse it doesn't work Link to comment
Infinity-War Posted April 10, 2020 Share Posted April 10, 2020 @Mohab - كان في خطا بسيط جرب هسا : executeSQLQuery("CREATE TABLE IF NOT EXISTS `player_stats` (`username` TEXT, `Thirst` INT, `Hunger` INT)") addEventHandler("onPlayerQuit", root , function () local atsh = getElementData(source, "Thirst") local hungry = getElementData(source, "Hunger") local account = getPlayerAccount(source) if ( isGuestAccount ( account ) ) then return end local username = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE `username` = ?", username) if (#result > 1) then executeSQLQuery("UPDATE `player_stats` SET `Hunger` = ?, `Thirst` = ? WHERE `username` = ?", hungry, atsh, username) else executeSQLQuery("INSERT INTO health (username, Thirst, Hunger) VALUES (?, ?, ?)", username, atsh, hungry) end end) addEventHandler("onPlayerLogin", root, function(_, account) local accountName = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE username = ?", accountName) if (#result > 1) then setElementData(source, "Thirst", result[1].Thirst) setElementData(source, "Hunger", result[1].Hunger) end end) Link to comment
Mmohab Posted April 10, 2020 Author Share Posted April 10, 2020 انا خليته يقول في الديبق success عشان اتأكد انه نجح test = executeSQLQuery("CREATE TABLE IF NOT EXISTS `player_stats` (`username` TEXT, `Thirst` INT, `Hunger` INT)") if test then print ("success") else print ("failed") end addEventHandler("onPlayerQuit", root , function () local atsh = getElementData(source, "Thirst") local hungry = getElementData(source, "Hunger") local account = getPlayerAccount(source) if ( isGuestAccount ( account ) ) then return end local username = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE `username` = ?", username) if (#result > 1) then executeSQLQuery("UPDATE `player_stats` SET `Hunger` = ?, `Thirst` = ? WHERE `username` = ?", hungry, atsh, username) else executeSQLQuery("INSERT INTO health (username, Thirst, Hunger) VALUES (?, ?, ?)", username, atsh, hungry) end end) addEventHandler("onPlayerLogin", root, function(_, account) local accountName = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE username = ?", accountName) if (#result > 1) then setElementData(source, "Thirst", result[1].Thirst) setElementData(source, "Hunger", result[1].Hunger) end end) بس ايش الخطوة اللي بعدها ؟ يعني انا اشكرك جدا انك ساعدتني المشكلة اتحلت بس مافي شئ اتغير بالنسبة للكلاينت حق المود يعني المفروض اني لما اسوي local atsh = getElementData(getLocalPlayer(), "Thirst") local hungry = getElementData(getLocalPlayer(), "Hunger") المفروض انه يسوي تلقائي الجوع والعطش اللي كان متسجل بس يقولي نفس المشكله ان الجوع والعطش متغير ولازم اخليه كدا local atsh = getElementData(getLocalPlayer(), "Thirst") or 100 local hungry = getElementData(getLocalPlayer(), "Hunger") or 100 عشان كدا حسيت انه ما في تقدم ساعدني من فضلك @Infinity-War Link to comment
Infinity-War Posted April 10, 2020 Share Posted April 10, 2020 executeSQLQuery("CREATE TABLE IF NOT EXISTS `player_stats` (`username` TEXT, `Thirst` INT, `Hunger` INT)") addEventHandler("onPlayerQuit", root , function () local atsh = getElementData(source, "Thirst") local hungry = getElementData(source, "Hunger") local account = getPlayerAccount(source) if ( isGuestAccount ( account ) ) then return end local username = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE `username` = ?", username) if (#result > 1) then executeSQLQuery("UPDATE `player_stats` SET `Hunger` = ?, `Thirst` = ? WHERE `username` = ?", hungry, atsh, username) else executeSQLQuery("INSERT INTO health (username, Thirst, Hunger) VALUES (?, ?, ?)", username, atsh, hungry) end end) addEventHandler("onPlayerLogin", root, function(_, account) local accountName = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE username = ?", accountName) if (#result > 1) then outputChatBox ( 'done' ) setElementData(source, "Thirst", result[1].Thirst) setElementData(source, "Hunger", result[1].Hunger) end end) شوف اذا قال لك Done بالشات او لا . Link to comment
Mmohab Posted April 10, 2020 Author Share Posted April 10, 2020 للأسف ما حصل شئ طب ممكن تكون المشكلة في الكلاينت سايد ؟ @Infinity-War طب هل استخدامي لباك اب owlgaming ممكن يكون السبب في المشكلة ؟ Link to comment
Infinity-War Posted April 10, 2020 Share Posted April 10, 2020 34 minutes ago, Mohab said: للأسف ما حصل شئ طب ممكن تكون المشكلة في الكلاينت سايد ؟ @Infinity-War طب هل استخدامي لباك اب owlgaming ممكن يكون السبب في المشكلة ؟ لا , طلع لك شيء في الشات ولا لا ؟ Link to comment
Mmohab Posted April 10, 2020 Author Share Posted April 10, 2020 11 hours ago, Infinity-War said: لا , طلع لك شيء في الشات ولا لا ؟ شكرا لمساعدتك حليت المشكلة 11 hours ago, Infinity-War said: لا , طلع لك شيء في الشات ولا لا ؟ شكرا لمساعدتك حليت المشكلة Link to comment
iwalidza Posted April 11, 2020 Share Posted April 11, 2020 8 hours ago, Infinity-War said: لا , طلع لك شيء في الشات ولا لا ؟ من الافضل ان تشرح له المشكلة و اين هي و طريقة حلها مش تعطيه اياها جاهزة عشان يتعلم يحل مشاكله بنفسه Link to comment
N3xT Posted April 15, 2020 Share Posted April 15, 2020 executeSQLQuery("CREATE TABLE IF NOT EXISTS `player_stats` (`username` TEXT, `Thirst` INT, `Hunger` INT)") addEventHandler("onPlayerQuit", root, function () local account = getPlayerAccount(source) if ( isGuestAccount ( account ) ) then return end local atsh = getElementData(source, "Thirst") local hungry = getElementData(source, "Hunger") local username = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE `username` = ?", username) if (result and #result > 0) then executeSQLQuery("UPDATE `player_stats` SET `Hunger` = ?, `Thirst` = ? WHERE `username` = ?", hungry, atsh, username) else executeSQLQuery("INSERT INTO health (username, Thirst, Hunger) VALUES (?, ?, ?)", username, atsh, hungry) end end ) addEventHandler("onPlayerLogin", root, function (_, account) local accountName = getAccountName(account) local result = executeSQLQuery("SELECT * FROM player_stats WHERE username = ?", accountName) if (result and #result > 0) then setElementData(source, "Thirst", result[1].Thirst) setElementData(source, "Hunger", result[1].Hunger) end end ) 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