Jump to content

مساعدة في executeSQLQuery


WTF_

Recommended Posts

local check1 = executeSQLQuery( ' SELECT * FROM `bank` WHERE accname = ? ', getPlayerAccount(source) )
local x = check1[1]['bank']
outputChatBox('You Have Add '..x , source , 255,0,0)

انا ابي أسحب قيمة من داخل الجدول 

سويت هيك 

local x = checkData1[1]['bank']

فقال لي في الدي بيق لما سويت 

outputChatBox("You Have Add"..x, source , 255,0,0)

attempt to concatenate local x ( a nil value )

ساعدوني من فضلكم وشكرا لكم 

هدفي انو يجيب القيمة الي داخل الجدول الي هو عدد موجود في البنك وبيطلعه في الشات وشكراااا

Link to comment
3 hours ago, XML said:

عندك اول شي


local x = check1[1]['bank']

 

مختلفه عن ذي


local x = checkData1[1]['bank']

 

حط اكوادك المخصصه لهذي النقطه كامله

أخوي انا في الكود تبعي مسويها check1

وانت تشوفها وذي هي الأكواد تبع النقطة وما إشتغل 

كل ذول وسويت لما الشخص يسوي كومند

Link to comment

Server 



executeSQLQuery( ' CREATE TABLE IF NOT EXISTS `bank` (accname, money) ' )


addEventHandler( "onMarkerHit" , bankmarker , function ( hitElement ) 
local checkData = executeSQLQuery( ' SELECT * FROM `bank` WHERE accname = ? ', getPlayerAccount(hitElement) )
local moneyPlaye =  getPlayerMoney ( hitElement  ) 
local nameplaye = getPlayerName ( hitElement )
if not ( type ( checkData ) == 'table' and #checkData == 0 or not checkData ) then
if moneyPlaye and nameplaye then 
triggerClientEvent (hitElement, "hit" , hitElement , moneyPlaye ,nameplaye , checkData[1].bank) 
end 
else 
triggerClientEvent (hitElement, "hit2" , hitElement ,moneyPlaye,nameplaye)
 end 
end 

 )
 addEvent ( "depoinbank" , true ) 
 addEventHandler ( "depoinbank" , root , function ( e1 ) 
 local checkData1 = executeSQLQuery( ' SELECT * FROM `bank` WHERE accname = ? ', getPlayerAccount(source) )
if getPlayerMoney ( source )  >= e1*1 then 
 if  ( type ( checkData1 ) == 'table' and #checkData1 == 0 or not checkData1 ) then
executeSQLQuery( ' INSERT INTO `bank` (accname, money) VALUES(?, ?) ', getPlayerAccount(source), e1 )
outputChatBox('You Have Add '..e1.." To bank" , source , 0,255,0)
takePlayerMoney ( source , e1 )
else 
 local checkData = executeSQLQuery( ' SELECT * FROM `bank` WHERE accname = ? ', getPlayerAccount(source) )
 local x = checkData[1]['bank']
executeSQLQuery( ' UPDATE`bank` SET money = money + '..e1..' WHERE accname = ? ', getPlayerAccount(source))
takePlayerMoney ( source , e1 )
outputChatBox('Your money is now '..x , source , 0,255,0)
end 
end 
end )

Client 

addEvent ( 'hit' , true ) 
addEventHandler ( "hit" , root , function ( moneyPlaye ,nameplaye , checkData ) 
if moneyPlaye and nameplaye  then 
guiSetVisible ( windowbank , true ) 
showCursor ( true ) 
guiSetText ( bankplayername , "Player Name : "..nameplaye ) 
guiSetText ( moneyinbank , "Money in Bank : "..checkData.."$" ) 
guiSetText ( moneyout , "Your Money : "..moneyPlaye.."$" ) 
end 
end 
)
addEvent ( 'hit2' , true ) 
addEventHandler ( "hit2" , root , function (moneyPlaye ,nameplaye) 
if moneyPlaye and nameplaye then 
guiSetVisible ( windowbank , true ) 
showCursor ( true ) 
guiSetText ( moneyout , "Your Money : "..moneyPlaye.."$" ) 
guiSetText ( bankplayername , "Player Name : "..nameplaye )
guiSetText ( moneyinbank , "Money in Bank : 0$" ) 
end 
end 
)

المشكلة بطريقة كاملة في الكلينت 

guiSetText ( moneyinbank , "Money in Bank : "..checkData.."$" ) 

ما يشتغل 

On 15/12/2017 at 08:26, XML said:

@WTF_

ورنا الكود كامل .. مافيه طريقه نساعدك غير كذا

 

On 15/12/2017 at 04:07, #Soking said:

تأكد ان في الكولمن في شي اسمه 

bank

 

Link to comment
executeSQLQuery("CREATE TABLE IF NOT EXISTS `bank` (accname, money)")

addEventHandler("onMarkerHit", bankmarker,
	function(player)
		local result = executeSQLQuery("SELECT * FROM bank WHERE accname = ?", getPlayerAccount(player))
		local Money =  getPlayerMoney(player) 
		local Name = getPlayerName(player)
		if not type ( result ) == "table" and #result == 0 or not result then
			if Money and Name then 
				triggerClientEvent(player, "hit" , player, Money, Name, result[1].money) 
			end 
		else 
			triggerClientEvent (player, "hit2", player, Money, Name)
		end 
	end  
)

addEvent("depoinbank", true) 
addEventHandler("depoinbank", root, 
	function ( e1 )
		local result1 = executeSQLQuery("SELECT * FROM bank WHERE accname = ?", getPlayerAccount(source))
		if getPlayerMoney(source) >= e1 then
			if type ( result1 ) == "table" and #result1 == 0 or not result1 then
				executeSQLQuery( "INSERT INTO bank (accname, money) VALUES(?, ?)", getPlayerAccount(source), e1)
				outputChatBox("You Have Add "..e1.." To bank" , source , 0,255,0)
				takePlayerMoney(source , e1)
			else 
				local result = executeSQLQuery("SELECT * FROM `bank` WHERE accname = ?", getPlayerAccount(source))
				local x = result[1]["money"]
				executeSQLQuery( " UPDATE bank SET money = money + "..e1.." WHERE accname = ? ", getPlayerAccount(source))
				takePlayerMoney(source , e1)
				outputChatBox("Your money is now "..x , source , 0,255,0)
			end 
		end 
	end 
)

 

Edited by #x1AhMeD,-09
ما نظرت كويس
Link to comment

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