Jump to content

executeSQLQuery [ مشكلة ]


Recommended Posts

--client
addEventHandler("onClientGUIClick", root, 
function ()
	if source == create then
		local Text = guiGetText(editwarp)
			local x,y,z = getElementPosition(localPlayer)
					if Text == "" or Text == " " then return end
					table.insert ( tele, { Text, x, y, z } )
					            triggerServerEvent ( 'event2' , localPlayer , Text )
					loob () 
end
end)

addEventHandler("onClientResourceStart",resourceRoot,function ()
triggerServerEvent('event1',localPlayer)
end)

addEvent('events' , true )
addEventHandler('events' , getRootElement ( ),
function ( Value )
    for Value1 , Value2 in ipairs ( Value ) do
        guiGridListSetItemText ( GridList , guiGridListAddRow ( GridList ) , 1 , Value2.aRows , false , false )
    end
end )


--server
executeSQLQuery ( ' CREATE TABLE IF NOT EXISTS aTalis ( aRows ) ' )

addEvent('event1',true)
addEventHandler('event1',getRootElement(),
function (aText)
executeSQLQuery ( ' INSERT INTO aTalis VALUES ( ? )' , aText )
end)

addEvent('event2',true)
addEventHandler('event2',getRootElement(),
function ()
Value = executeSQLQuery ('SELECT * FROM aTalis')
if ( #Value ~= 0 ) then
triggerClientEvent ( source , 'events', source , Value )
	end
end)

السلام عليكم , سويت مود الانتقال عشان اتعلم السكل

المهم واجهتني مشكلة اني اذا سويت مكان جديد وذا طلعت ودخلت ماينحفظ

وش المشكلة

@#BrosS

@Abdul KariM

@Master_MTA

@iMr.WiFi..!

@iMr.Omar

Edited by Talis
Link to comment
--- Client Side 

addEventHandler ( "onClientGUIClick" , resourceRoot , function ( ) 
if ( source == create ) then
local aName = guiGetText ( editwarp ) ; 
if ( aName ~= "" or aName ~= " " ) then 
triggerServerEvent ( "addNewPlace" , localPlayer , aName ) ;
end
end
end );

addEventHandler("onClientResourceStart",resourceRoot,function()
setTimer ( function ( ) 
triggerServerEvent ( "getPlaces" , localPlayer );
end,1500,1)
end);

addEvent ( "setPlaces" , true )
addEventHandler ( "setPlaces" , root , function ( Table )
guiGridListClear ( GridList );
for index,values in ipairs ( Table ) do 
local row = guiGridListAddRow ( GridList ) ;
guiGridListSetItemText ( GridList , row , 1 , values [ 'name' ] , false , false )
guiGridListSetItemData ( GridList , row , 1 , values['position'] );
end
end ) ;

--- Server Side 

executeSQLQuery ( "CREATE TABLE IF NOT EXISTS aTails_Places ( name , position )" );

addEvent ( "addNewPlace" , true )
addEventHandler ( "addNewPlace" , root , function ( aName )
local aResult = executeSQLQuery ( "SELECT * FROM aTails_Places" )
if ( aResult and type ( aResult ) == "table" and #aResult ~= 0 ) then 
for i,v in ipairs ( aResult ) do 
if ( v [ "name" ] == aName ) then 
return
end
end
end
local x , y , z = getElementPosition ( source ) ;
executeSQLQuery ( "INSERT INTO aTails_Places ( name , position ) VALUES ( ? , ? )" , aName , tostring(x)..","..tostring(y)..","..tostring(z) );
outputChatBox("تم إضافة المكان",source,255,255,0,true)
end ) ;


addEvent ( "getPlaces" , true )
addEventHandler ( "getPlaces" , root , function ( )
local aResult = executeSQLQuery ( "SELECT * FROM aTails_Places" )
if ( aResult and type ( aResult ) == "table" and #aResult ~= 0 ) then 
triggerClientEvent ( source , "setPlaces" , source , aResult ) ;
end
end );

لو تبي تخليه لو ظغط زر وينتقل للامكان إستخدم 

guiGridListGetItemData
split
setElementPosition

 

  • Like 1
Link to comment
1 minute ago, Abdul KariM said:

@iMr.Omar ماينفع تخزن الاحداثيات في التيبل وانت مسوي كولمنين فقط

راح يخزن الاسم واحداثي اكس 

@Talis انت تبيه فقط لك تضيف اماكن والزوار يشوفها ولا اي زائر يضيف اماكن ؟

يب ابي اذا ضفت اماكن يشوفونها الزوار

Link to comment

كلينت

addEvent ( "setPlaces" , true )
addEventHandler ( "setPlaces" , root ,

	function ( Table )
	
	guiGridListClear ( GridList );
	
	for index,values in ipairs ( Table ) do 
	
	local row = guiGridListAddRow ( GridList ) ;
	
	guiGridListSetItemText ( GridList , row , 1 , values [ 'name' ] , false , false )

	guiGridListSetItemData ( GridList , row , 1 , fromJSON ( values [ 'position' ] ) )
		end
	end 
	)
	

سيرفر


executeSQLQuery ( "CREATE TABLE IF NOT EXISTS aTails_Places ( name , position )" );

addEvent ( "addNewPlace" , true )
addEventHandler ( "addNewPlace" , root ,

	function ( aName )

	local aResult = executeSQLQuery ( "SELECT * FROM aTails_Places WHERE name=?" , aName )
	
	if ( aResult and #aResult == 0 ) then 

	local aPos = { getElementPosition ( source ) } ;

	executeSQLQuery ( "INSERT INTO aTails_Places ( name , position ) VALUES ( ? , ? )" , aName , toJSON ( aPos ) );

	outputChatBox("تم إضافة المكان",source,255,255,0,true)

	else
	
	outputChatBox ( "هذا المكان موجود سابقا" , source )
		end
	end
	) ;


addEvent ( "getPlaces" , true )
addEventHandler ( "getPlaces" , root , function ( )
local aResult = executeSQLQuery ( "SELECT * FROM aTails_Places" )
if ( aResult and type ( aResult ) == "table" and #aResult ~= 0 ) then 
triggerClientEvent ( source , "setPlaces" , source , aResult ) ;
end
end );

 

  • Like 2
Link to comment
tele = {
	{"=[ القفزه الخونفشاريه ]=",1541.0673828125, -1357.576171875, 329.46615600586},
	{"=[ مقر الجيش ]=",146.66674804688, 1720, 17.640625},
	{"=[ موقف الباصات ]=",1790.2674560547,-1912.0159912109 , 13.396838188171},
	{"=[ الفنادق ]=",-1739.0821533203, 940.56231689453, 24.7421875},
	{"=[ الشارع الطويل ]=",-3072.5554199219,-3000.345703125,5},
	{"=[ بيت سي جي ]=",2491.12109375, -1667.4482421875, 13.34375}
}

function loob ( )
guiGridListClear ( GridList )
for i,mk in ipairs(tele) do
	local row = guiGridListAddRow(GridList)
	guiGridListSetItemText(GridList,row,1,mk[1],false,false)
	guiGridListSetItemData(GridList,row,1,{mk[2],mk[3],mk[4]})
	guiGridListSetItemColor(GridList,row,1,0,255,0)
end
end

 

Link to comment
2 hours ago, Talis said:

tele = {
	{"=[ القفزه الخونفشاريه ]=",1541.0673828125, -1357.576171875, 329.46615600586},
	{"=[ مقر الجيش ]=",146.66674804688, 1720, 17.640625},
	{"=[ موقف الباصات ]=",1790.2674560547,-1912.0159912109 , 13.396838188171},
	{"=[ الفنادق ]=",-1739.0821533203, 940.56231689453, 24.7421875},
	{"=[ الشارع الطويل ]=",-3072.5554199219,-3000.345703125,5},
	{"=[ بيت سي جي ]=",2491.12109375, -1667.4482421875, 13.34375}
}

function loob ( )
guiGridListClear ( GridList )
for i,mk in ipairs(tele) do
	local row = guiGridListAddRow(GridList)
	guiGridListSetItemText(GridList,row,1,mk[1],false,false)
	guiGridListSetItemData(GridList,row,1,{mk[2],mk[3],mk[4]})
	guiGridListSetItemColor(GridList,row,1,0,255,0)
end
end

 

ليه حاطه بتيبل ليه ما تخزنه بالسيرفر سايد بالداتا بيز؟

يعني كمثال

سيرفر سايد طبعا

executeSQLQuery ( "CREATE TABLE IF NOT EXISTS aTails_Places ( name , position )" );

tele = {
	{"=[ القفزه الخونفشاريه ]=",1541.0673828125, -1357.576171875, 329.46615600586},
	{"=[ مقر الجيش ]=",146.66674804688, 1720, 17.640625},
	{"=[ موقف الباصات ]=",1790.2674560547,-1912.0159912109 , 13.396838188171},
	{"=[ الفنادق ]=",-1739.0821533203, 940.56231689453, 24.7421875},
	{"=[ الشارع الطويل ]=",-3072.5554199219,-3000.345703125,5},
	{"=[ بيت سي جي ]=",2491.12109375, -1667.4482421875, 13.34375}
}
addEventHandler('onResourceStart',root,function()
local aResult = executeSQLQuery ( "SELECT * FROM aTails_Places"  )
	if ( aResult and #aResult == 0 ) then 
			 for k,v in ipairs(tele)do
				local xyz=v[2]..','..v[3]..','..v[4]
				executeSQLQuery ( "INSERT INTO aTails_Places ( name , position ) VALUES ( ? , ? )" , v[1] , xyz );
			end
		end
    end)


addEvent ( "addNewPlace" , true )
addEventHandler ( "addNewPlace" , root ,

	function ( aName )

	local aResult = executeSQLQuery ( "SELECT * FROM aTails_Places WHERE name=?" , aName )
	
	if ( aResult and #aResult == 0 ) then 

	local x,y,z = getElementPosition ( source ) 
      local aPos=x..','..y..','..z

	executeSQLQuery ( "INSERT INTO aTails_Places ( name , position ) VALUES ( ? , ? )" , aName ,  aPos  );

	outputChatBox("تم إضافة المكان",source,255,255,0,true)

	else
	
	outputChatBox ( "هذا المكان موجود سابقا" , source )
		end
	end
	) ;


addEvent ( "getPlaces" , true )
addEventHandler ( "getPlaces" , root , function ( )
local aResult = executeSQLQuery ( "SELECT * FROM aTails_Places" )
if ( aResult and type ( aResult ) == "table" and #aResult ~= 0 ) then 
triggerClientEvent ( source , "setPlaces" , source , aResult ) ;
end
end );

client side

 

triggerServerEvent('getPlaces',localPlayer)
function loob (table )
guiGridListClear ( GridList )
for index,value in ipairs(table) do
	local row = guiGridListAddRow(GridList)
    local allpos=split(value.position,',')
	guiGridListSetItemText(GridList,row,1,value.name,false,false)
	guiGridListSetItemData(GridList,row,1,{allpos[1],allpos[2],allpos[3]})
	guiGridListSetItemColor(GridList,row,1,0,255,0)
end
end
addEventHandler('setPlaces',root,loob)
addEvent('setPlaces',true)

 

جرب اي خدمه

طبعا لو بتسوي كودي في نفس السيرفر لا تنسى تسوي دروب للتيبل الاول عشان يزبط

Edited by Master_MTA
  • Like 1
Link to comment

@Master_MTA كودك ماينفع زي كود عمر مايصير تحط الاحداثيات كلها وعندك كولمنين فقط

جرب هذا مع كودي بس بدل الكلينت

addEvent ( "setPlaces" , true )
addEventHandler ( "setPlaces" , root ,

	function ( Table )
	
	loob ( )
	
	for index,values in ipairs ( Table ) do 
	
	local row = guiGridListAddRow ( GridList ) ;
	
	guiGridListSetItemText ( GridList , row , 1 , values [ 'name' ] , false , false )

	guiGridListSetItemData ( GridList , row , 1 , fromJSON ( values [ 'position' ] ) )
	
		end
	end 
	)
	
	

 

  • Like 2
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...