Jump to content

3NAD

Members
  • Posts

    1,992
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by 3NAD

  1. On 25/11/2019 at 16:05, 3NAD said:

    Client:

    
    triggerServerEvent ( "onRequestCurrentGamemode", localPlayer )
    

     

    Server:

    
    addEvent ( "onRequestCurrentGamemode", true )
    addEventHandler ( "onRequestCurrentGamemode", root,
    	function ( )
    		if CWMode then
    			triggerClientEvent ( source, "EnableCW", resourceRoot )
    		elseif WFFMode then
    			triggerClientEvent ( source, "EnableWFF", resourceRoot )
    		end
    	end
    )
    

     

    هذا الحل

  2. local arena = { };
    
    function arena.create ( )
    	arena.marker = { };
    	arena.marker[1] = createMarker ( -224, 125, 4, "cylinder", 1, 255, 255, 255, 255 )
    	arena.marker[2] = createMarker ( -200, 125, 4, "cylinder", 1, 255, 0, 0, 255 )
    	arena.marker[3] = createMarker ( -200, 157, 6, "cylinder", 1, 0, 255, 0, 255 )
    	arena.marker[4] = createMarker ( -224, 157, 6, "cylinder", 1, 0, 0, 255, 255 )
    	arena.attachMarker ( )
    end
    addCommandHandler ( "work", arena.create )
    
    function arena.leave ( player )
    	if player == localPlayer then
    		outputChatBox ( "You have left the area" )
    	end
    end
    
    function arena.borders ( )
    	if not arena.run then return end
    	for i, v in ipairs ( arena.attach ) do
    		local x1, y1, z1 = getElementPosition ( v.fromMarker )
    		local x2, y2, z2 = getElementPosition ( v.toMarker )
    		dxDrawLine3D ( x1, y1, z1, x2, y2, z2, tocolor ( 0, 255, 0, 230 ), 2 )
    	end
    end
    addEventHandler ( "onClientRender", root, arena.borders )
    
    function arena.attachMarker ( )
    	arena.attach = { };
    	local fromID = 1
    	while fromID <= 4 do
    		local toID = ( ( fromID < 4 and fromID +1 ) or 1 )
    		table.insert ( arena.attach, { fromMarker=arena.marker[fromID], toMarker=arena.marker[toID], distance=0 } )
    		fromID = fromID +1
    	end
    	
    	arena.positions ( )	
    end
    
    function arena.positions ( )
    	arena.position = { };
    	arena.position.marker = { };
    	arena.position.center = { x = 0, y = 0, z = 0 };
    	
    	for i, v in ipairs ( arena.marker ) do
    		arena.position.marker[i] = { };
    		arena.position.marker[i].x, arena.position.marker[i].y, arena.position.marker[i].z = getElementPosition ( v )
    	end
    	
    	local markerID = 1
    	while markerID <= 4 do
    		arena.position.center.x = arena.position.center.x + arena.position.marker[markerID].x
    		arena.position.center.y = arena.position.center.y + arena.position.marker[markerID].y
    		arena.position.center.z = arena.position.center.z + arena.position.marker[markerID].z
    		markerID = markerID +1
    	end
    	arena.position.center.x = arena.position.center.x/4
    	arena.position.center.y = arena.position.center.y/4
    	arena.position.center.z = arena.position.center.z/4
    	
    	arena.createBorders ( )
    end
    
    function arena.createBorders ( )
    	local x, y = { }, { }
    	for i, v in ipairs ( arena.position.marker ) do
    		table.insert ( x, v.x )
    		table.insert ( y, v.y )
    	end
    	
    	arena.borders = createColPolygon ( arena.position.center.x, arena.position.center.y, x[1], y[1], x[2], y[2], x[3], y[3], x[4], y[4] )
    	addEventHandler ( "onClientColShapeLeave", arena.borders, arena.leave, false )
    	
    	arena.run = true
    end

     

    جرب ذا

    ما انسى اللي ساعدني فيه 

     

    بالتوفيق

  3. 5 minutes ago, Mr.Mostafa said:

    الحين انا معي جدول فيه 1 2 3 مثلا

    ابي لو كتبت

    /startMission 1

    لو الكلمة التانية الي هي 1 = شي من الجدول 

    يطلع رسالة يس بالشات

    لكن لو القيمة مب بالجدول  , يطلع رسالة نو فهمتني؟

    addCommandHandler ( "startMission" , 
    	function ( player,cmd,mission ) 
    		local playerAccount = getPlayerAccount ( player ) 
    		if ( not isGuestAccount ( playerAccount ) ) then 
    			if ( isObjectInACLGroup ( "user."..getAccountName(playerAccount),aclGetGroup("Console") ) ) then 
    				for k,v in pairs ( positionTable ) do
    					if mission == v[1] then
    						setElementData(resourceRoot,"TheMissions",mission)
    						outputChatBox("yes",root,255,0,0,true)
    						return
    					end
    				end
    				outputChatBox("no",root,255,0,0,true)
    			end
    		end
    	end 
    )

     

  4. 6 minutes ago, Mr.Mostafa said:

    صارت تجيب كل النتايج no

    المفروض ان هادا التحقق

    
    for k,v in pairs ( positionTable ) do
    if mission == v[1] then
    

    يشوف اذا الكلمة بتساوي شي في الجدول ولا لا

    انت اللي تحدد تبي نو تظهر ولا لا !

     

    مثلاً كان كودك انك تبحث عن قيمة في التيبل , ف مافي حاجة انك تستخدم

    else

     

     

  5. On 17/09/2018 at 20:43, Mr.Mostafa said:

    آبي توضيح لحقت آلترتيب مآ عرفت آسويهآ آلصرآحة 

    ــ

    آنآ فكرتي آبي لو كتب كومآند dor

    يسجله مثلا انه رقم 1 , لو احد تاني كتب يسجله رقم اتنين , الخ الخ الخ

    ولما اكتب كوماند مثلا getdor

    يسحب الشخص الي عليه الدور

    ــ

    
    local taple = {}
      
    addCommandHandler("dor",-- يحط نفسه بالدور
    	function(source)
    		local dor = -- ما عرفت كودها ..
    		outputChatBox("تم وضعك في الدور , انتظر حتي ياتي دورك لسحبك",source,255,0,0,true)
    			outputChatBox(""..dor.." انت الدور رقم",source,255,0,0,true)
    				table.insert(taple,{player=source})
    	end
    )
    
    addCommandHandler("getDor",-- يسحب الاعب الي عليه الدور
    	function(source)
    	  local x,y,z = getElementPosition(source)
    		if #ta~=0 then
    			setElementPosition(player,x,y,z)
    			table.remove(ta,1)
    		end
    	end
    )
    

     

    local taple = {}
      
    getPlayerDor = function ( source )
    	for i, v in ipairs ( taple ) do
    		if v.player == source then
    			return i
    		end
    	end
    end
    
    addCommandHandler("dor",-- يحط نفسه بالدور
    	function(source)
    		local dor = getPlayerDor ( source )
    		if not dor then
    			outputChatBox("تم وضعك في الدور , انتظر حتي ياتي دورك لسحبك",source,255,255,0,true)
    			table.insert(taple,{player=source})
    			outputChatBox(""..#taple.." انت الدور رقم",source,255,255,0,true)
    		else
    			outputChatBox(""..dor.." قمت بأخذ دور مسبقاً, الرقم",source,255,0,0,true)
    		end
    	end
    )
    
    addCommandHandler("getDor",
    	function(source)
    		local dorNow = taple[1]
    		if dorNow then
    			local player = dorNow.player
    			local x,y,z = getElementPosition(source)
    			setElementPosition(player,x,y,z+2)
    			table.remove(taple,1)
    		else
    			outputChatBox("لايوجد دور",source,255,0,0,true)
    		end
    	end
    )

     

  6. 30 minutes ago, Mr.Mostafa said:

    عادي استخدمه وموجود else ?

    احط بريك بعد else يعني؟

    لما احط بريك تصير تيجي كلمة نو فقط , 

    
    addCommandHandler ( "startMission" , function ( player,cmd,mission ) 
    local playerAccount = getPlayerAccount ( player ) 
    if ( not isGuestAccount ( playerAccount ) ) then 
    if ( isObjectInACLGroup ( "user."..getAccountName(playerAccount),aclGetGroup("Console") ) ) then 
    for k,v in pairs ( positionTable ) do
    if mission == v[1] then
    setElementData(resourceRoot,"TheMissions",mission)
    outputChatBox("yes",root,255,0,0,true)
    break
    else
    outputChatBox("no",root,255,0,0,true)
    end
    end
    end
    end
    end )
    

    كدا يطلع اكتر من 5 كلمات نو , بعدين بالاخر كلمة واحدة yes

     

    نعم , راح يوقف اللوب بعد اول نو

  7. 2 hours ago, Mr.Mostafa said:

    مب فاهم شي من كودك , ولا ادري وش فكرة كودك الصراحة

    انا قلت لك جرب الكوماندات (اكتب الكلمة بأف8) ء

    إضافة كلمة للجدول

    addValue text

     

    حذف كلمة من الجدول

    removeValue text

     

    عرض الكلمات اللي بالجدول

    getValues

     

     

  8. 2 hours ago, Mr.Mostafa said:

    وش هادا ؟

    + ابدل tableToBeUsed , 

    باسم الجدول؟؟

    انت اللي تحتاجه هو 

    fromJSON

    toJSON

    اقرا الكود وافهم طريقة استخدام الوظيفتين اللي فوق

    اذا فيه شيء مافهمته, حدد عليه واسأل هنا

  9. 12 hours ago, Mr.Mostafa said:

    للاسف طريقة الدروب تيبل ما بتظبط , لان في اشياء بالقاعدة تكون مغلقة , لو سويت دروب , بترجع مفتوحة ,, ياريت لو احد معه فكرة تانية

    الحين الجدول كدا

    {"1",

    "2",

    "3"}

    ابي كل القيم الي بضيفها جديد للجدول , تنضاف بالقاعدة , بس القيم القديمة تضل مثل ما هي

    يعني مثلا لو ابي ازود رقم 4 , ينسسوي INSERT للقاعدة تلقائي

     

     

    executeSQLQuery ( "CREATE TABLE IF NOT EXISTS `Sql` (`test` TEXT)")	
    
    addCommandHandler ( "addValue",
    	function ( player, _, value )
    		local SQL = executeSQLQuery ( "SELECT `test` FROM `Sql`" )
    		if #SQL == 0 then
    			local testingTable = { value };
    			local tableToBeStored = toJSON ( testingTable )
    			executeSQLQuery ( "INSERT INTO `Sql` (`test`) VALUES(?)", tableToBeStored )
    			outputChatBox ( "* The value has been added.", player )
    		else
    			local tableToBeUsed = fromJSON ( SQL[1].test )
    			table.insert ( tableToBeUsed, value )
    			local tableToBeStored = toJSON ( tableToBeUsed )
    			executeSQLQuery ( "UPDATE `Sql` SET test=?", tableToBeStored )
    			outputChatBox ( "* The value has been added.", player )
    		end
    	end
    )
    
    addCommandHandler ( "removeValue",
    	function ( player, _, value )
    		local SQL = executeSQLQuery ( "SELECT `test` FROM `Sql`" )
    		if #SQL == 0 then
    			outputChatBox ( "* No results.", player )
    		else
    			local tableToBeUsed = fromJSON ( SQL[1].test ) 
    			for i, v in ipairs ( tableToBeUsed ) do
    				if v == value then
    					table.remove ( tableToBeUsed, i )
    					local tableToBeStored = toJSON ( tableToBeUsed )
    					executeSQLQuery ( "UPDATE `Sql` SET test=?", tableToBeStored )
    					outputChatBox ( "* The value has been removed.", player )
    					return
    				end
    			end
    			outputChatBox ( "* The value isn't exist.", player )
    		end
    	end
    )
    
    addCommandHandler ( "getValues",
    	function ( player )
    		local SQL = executeSQLQuery ( "SELECT `test` FROM `Sql`" )
    		if #SQL == 0 then
    			outputChatBox ( "* No results.", player )
    		else
    			local tableToBeUsed = fromJSON ( SQL[1].test ) 
    			for i, v in ipairs ( tableToBeUsed ) do
    				outputChatBox ( v, player )
    			end
    		end
    	end
    )

    جرب الكوماندات

  10. On 15/09/2018 at 01:43, KillerX said:
    
    addEventHandler( 'onClientRender' , root , 
    	function( )
    		if ( isPedInVehicle( localPlayer ) ) then
    			local v = getPedOccupiedVehicle(localPlayer)
    			for _ , vehicle in ipairs(getElementsByType( 'vehicle' ) ) do
    				setElementCollidableWith ( vehicle , v , false )
    			end
    		end
    	end
    )
    

     

    هذا الكود راح يعمل ثقل كبير على الكلاينت ( يسبب لاق ) ء

     

    • Like 1
×
×
  • Create New...