Jump to content

كود اوبيكت


Recommended Posts

سلام عليكم كيفك

ان شاء الله بخير

ممكن مساعده في كود اوبجيكت يتحرك في حركه انا حدده والابجيكت يبقا يتحرك على طول يعني ما يوقف 

و يعطيكم العافيه

Link to comment

ما عليك من الشرح اللي فوق ما راح تفهم شي 

التايمر بسيط وظيفته بالكود اللي تحتاجه هو الاستمرارية .. يعني يحرك الاوبجكت باستمرار

timer setTimer ( function theFunction, int timeInterval, int timesToExecute, [ var arguments... ] )

function theFunction = الوظيفة اللي بطبق عليها التايمر 

timeInterval = الوقت الميلي سكند

timesToExecute = عدد تكرار التايمر

( ملاحظة : ( 0 = غير منتهي يعني يضل يتكرر 

 

اول شي نجي نصنع الوظيفة اللي نحتاجها عشان نحرك الاوبجكت

function movingObject (  )
    local px, py, pz = getElementPosition ( object )
    moveObject ( object, 1000, px + 1, py, pz )
end

 

الان نحتاج التايمر عشان يكررها باستمرار

setTimer ( movingObject, 1000, 0 )

1000 = ثانية واحدة بالملي سكند

0 = لا منتهي

وهذا الكود النهائي :

 

function movingObject (  )
    local px, py, pz = getElementPosition ( object )
    moveObject ( object, 1000, px + 1, py, pz )
end
setTimer ( movingObject, 1000, 0 )



 

Edited by #ZA7F //=
Link to comment
12 minutes ago, #ZA7F //= said:

ما عليك من الشرح اللي فوق ما راح تفهم شي 

التايمر بسيط وظيفته بالكود اللي تحتاجه هو الاستمرارية .. يعني يحرك الاوبجكت باستمرار

timer setTimer ( function theFunction, int timeInterval, int timesToExecute, [ var arguments... ] )

function theFunction = الوظيفة اللي بطبق عليها التايمر 

timeInterval = الوقت الميلي سكند

timesToExecute = عدد تكرار التايمر

( ملاحظة : ( 0 = غير منتهي يعني يضل يتكرر 

 

اول شي نجي نصنع الوظيفة اللي نحتاجها عشان نحرك الاوبجكت


function movingObject (  )
    local px, py, pz = getElementPosition ( object )
    moveObject ( object, 1000, px + 1, py, pz )
end

 

الان نحتاج التايمر عشان يكررها باستمرار


setTimer ( movingObject, 1000, 0 )

1000 = ثانية واحدة بالملي سكند

0 = لا منتهي

وهذا الكود النهائي :

 


function movingObject (  )
    local px, py, pz = getElementPosition ( object )
    moveObject ( object, 1000, px + 1, py, pz )
end
setTimer ( movingObject, 1000, 0 )



 

function movingObject (  )
    local -719.74915 ,966.17249, 12.13281 + 4 = getElementPosition ( 980 )
    moveObject ( 980, 1000,-719.74915 + 2 ,966.17249, 12.13281 + 4 )
end
setTimer ( movingObject, 1000, 0 )

يعطيك العافيه ولله ما تقصر بس في غلط في السطر الثاني مو رادي يشتغل المود بسببه

Link to comment
13 minutes ago, #ZA7F //= said:

كان قلت من اول ..

استبدل اسم الاوبجكت بس .

 


addEventHandler ( "onClientRender", root, function (  )
   local rx, ry, rz = getElementRotation ( object )
   setElementRotation ( object, rx, ry, rz+0.5 )
end )

 

addEventHandler ( "onClientRender", root, function (  )
   local 2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 = getElementRotation ( 8131 )
   setElementRotation ( 8131, 2496.1000976563,-1665.30004882,22.799999237061,0,0,90 )
end )
setTimer ( movingObject, 1000, 0 )

[11:56:12] SCRIPT ERROR: t1\Ts.lua:2: '<name>' expected near '2496.1000976563'

 

ذا الغلط يطلعلي كل شويه

Link to comment

ياخي انت اكوادك خبيصةة :@

addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
   setElementRotation ( object,0,0,rz+1 )
end )

بدل object

بأسم الاوبجكت حقك ؛

اذا انت مسويهه عالايدي

كذا بيصير

object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )

addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
   setElementRotation ( object,0,0,rz+1 )
end )

 

Link to comment
17 minutes ago, iMr.WiFi..! said:

ياخي انت اكوادك خبيصةة :@


addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
   setElementRotation ( object,0,0,rz+1 )
end )

بدل object

بأسم الاوبجكت حقك ؛

اذا انت مسويهه عالايدي

كذا بيصير


object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )

addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
   setElementRotation ( object,0,0,rz+1 )
end )

 

object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )

addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
   setElementRotation ( object,2496.1000976563,-1665.30004882,22.799999237061 +1 )
end )

setTimer ( movingObject, 1000, 1 )

الابجكت ينزل بس ابيه يدورحولين نفسه

 

Edited by r2x
Link to comment

لا تعدل ولا تخبص اي شي !!

 

object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )

addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
    setElementRotation ( object, rx,ry,rz+1 )
end )

 

Link to comment
20 minutes ago, #ZA7F //= said:

لا تعدل ولا تخبص اي شي !!

 


object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )

addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
    setElementRotation ( object, rx,ry,rz+1 )
end )

 

اخوي انا ازعجتك استحملني 

بس الابجيكت ينزل وما يتحرك انا ابيه يتحرك حولين نفسه يعني يلف في نفس المكان

Link to comment
10 minutes ago, iMr.WiFi..! said:

object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )

addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
    setElementRotation ( object, rx+1,ry,rz )
end )

 

الابجيكت ما يتحرك

Link to comment
object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )

addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
    local x,y,z = getElementPosition ( object )
    setElementRotation ( object, rx+1,ry,rz )
    setElementPosition ( object, x +5,y,z )
end )

 

Edited by iMr.WiFi..!
Link to comment
13 minutes ago, iMr.WiFi..! said:

object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )

addEventHandler ( "onClientRender", root, function (  )  
    local rx,ry,rz = getElementRotation ( object )
    local x,y,z = getElementPosition ( object )
    setElementRotation ( object, rx+1,ry,rz )
    setElementPosition ( object, x +5,y,z )
end )

 

ولله مني داري ليش كذا ما يتحرك ابد بس ينزل لي الابجكت بس

ما يتحرك ولا يعمل شي 

انا ابيه يدول في نفس المكان  يبقا يدور تلقائي

 

Link to comment

@iMr.WiFi..!  : كودك فيه زيادات مالها داعي وما راح يطلع تمام

 

  1. object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )
    
    addEventHandler ( "onClientRender", root, function (  )  
        local rx,ry,rz = getElementRotation ( object )
        setElementRotation ( object, rx,ry,rz+1 )
    end )

@r2x :الكود شغال % 100 .. الخطا من عندك 

Edited by #ZA7F //=
Link to comment
7 minutes ago, #ZA7F //= said:

@iMr.WiFi..!  : كودك فيه زيادات مالها داعي وما راح يطلع تمام

 

  1. 
    object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )
    
    addEventHandler ( "onClientRender", root, function (  )  
        local rx,ry,rz = getElementRotation ( object )
        setElementRotation ( object, rx,ry,rz+1 )
    end )
    

@r2x :الكود شغال % 100 .. الخطا من عندك 

الابجكت يتحرك؟ لحاله؟

Link to comment
5 minutes ago, #ZA7F //= said:

@iMr.WiFi..!  : كودك فيه زيادات مالها داعي وما راح يطلع تمام

 

  1. 
    object = createObject(8131,2496.1000976563,-1665.30004882,22.799999237061 , 0 ,0 , 0 )
    
    addEventHandler ( "onClientRender", root, function (  )  
        local rx,ry,rz = getElementRotation ( object )
        setElementRotation ( object, rx,ry,rz+1 )
    end )
    

@r2x :الكود شغال % 100 .. الخطا من عندك 

هو يبي الاوبجكت يتحرك ي أبني :(

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