Jump to content

تصحيح كود


Bo7meeeD

Recommended Posts

السلام عليكم ورححمة الله

شباب صلحولي الأخطاء ابغاه اذا ضرب الاعب يلحق الاعب اللي ضربه

هذا الكود

addEventHandler ( "onPlayerDamage", getRootElement (), 
function (attacker, wep) 
 if attacker and getElementType(attacker) == "player" then 
 theTeam = getPlayerTeam ( attacker ) 
 wep = getPedWeapon ( attacker ) 
 theWL = getPlayerWantedLevel ( source ) 
  if  getTeamName( theTeam ) == "police" and wep and theWL then 
  attachElements ( source, attacker ) 
  showCursor ( source, true )   
  end 
     end 
        end ) 
   

وشكككرا

Link to comment
-- لم يتم التجربة 
addEventHandler ( "onPlayerDamage", root, 
    function ( attacker, wep ) 
        if getElementType ( attacker ) == "player" then 
            theTeam = getPlayerTeam ( attacker ) 
            theWL = getPlayerWantedLevel ( source ) 
            if theTeam == getTeamFromName ( "police" ) then 
                if wep == 3 and theWL >= 1 then 
                    if isTimer ( theTimer ) then killTimer ( theTimer ) end 
                    theTimer = setTimer (  
                        function ( ) 
                            x, y, z = getElementRotation ( attacker ) 
                            setElementRotation ( source, x, y, z ) 
                        end 
                    , 500, 0 ) 
                    showCursor ( source, true )   
                    setPedControlState ( source, "sprint", true )                    
                end 
            end 
        end 
    end 
) 

Link to comment
-- لم يتم التجربة 
addEventHandler ( "onPlayerDamage", root, 
    function ( attacker, wep ) 
        if getElementType ( attacker ) == "player" then 
            theTeam = getPlayerTeam ( attacker ) 
            theWL = getPlayerWantedLevel ( source ) 
            if theTeam == getTeamFromName ( "police" ) then 
                if wep == 3 and theWL >= 1 then 
                    if isTimer ( theTimer ) then killTimer ( theTimer ) end 
                    theTimer = setTimer (  
                        function ( ) 
                            x, y, z = getElementRotation ( attacker ) 
                            setElementRotation ( source, x, y, z ) 
                        end 
                    , 500, 0 ) 
                    showCursor ( source, true )   
                    setPedControlState ( source, "sprint", true )                    
                end 
            end 
        end 
    end 
) 

1- جربته ولا ضبط

2- وش فايدة ذا الكود

setElementRotation 

Link to comment
1- جربته ولا ضبط

2- وش فايدة ذا الكود

setElementRotation 

1- تأكد انك حققت الشرط هذا

if wep == 3 and theWL >= 1 then 

2- صعب علي التعبير ولكن هو يوجه شخصية اللاعب مثلاً يناظر الشمال و كذا

Link to comment
1- جربته ولا ضبط

2- وش فايدة ذا الكود

setElementRotation 

1- تأكد انك حققت الشرط هذا

if wep == 3 and theWL >= 1 then 

2- صعب علي التعبير ولكن هو يوجه شخصية اللاعب مثلاً يناظر الشمال و كذا

[2001-01-04 00:03:14] WARNING: attacker\server.lua:3: Bad argument @ 'getElementType' [Expected element at argument 1, got nil] 
[2001-01-04 00:03:27] ERROR: attacker\server.lua:16: attempt to call global 'setPedControlState' (a nil value) 
[2001-01-04 00:03:28] WARNING: attacker\server.lua:12: Bad argument @ 'setElementRotation' [Expected element at argument 1, got nil] 
  

Link to comment
-- لم يتم التجربة 
addEventHandler ( "onPlayerDamage", root, 
    function ( attacker, wep ) 
        if getElementType ( attacker ) == "player" then 
            theTeam = getPlayerTeam ( attacker ) 
            theWL = getPlayerWantedLevel ( source ) 
            if theTeam == getTeamFromName ( "police" ) then 
                if wep == 3 and theWL >= 1 then 
                    if isTimer ( theTimer ) then killTimer ( theTimer ) end 
                    theTimer = setTimer (  
                        function ( ) 
                            x, y, z = getElementRotation ( attacker ) 
                            setElementRotation ( source, x, y, z ) 
                        end 
                    , 500, 0 ) 
                    showCursor ( source, true )   
                    setPedControlState ( source, "sprint", true )                    
                end 
            end 
        end 
    end 
) 

مشرفنا عناد، كودك ذا ما يحط اللاعب مواجه للشرطي، لانه ماله علاقة زاوية الشرطي باتجاه اللاعب، لازم تجيب الزاوية من الميل بين نقطتين وثم تجيب الزاوية من الميل، ولحسن الحظ في كود جاهز يسوي عنك الحسبة هذي كلها

+

انت اضفت في كودك

onPlayerDamage ---- سيرفر 
setPedControlState ---- كلينت 

وهذا هو التصحيح للكود، طبعا الكود مو كامل، على صاحب الموضوع انه يكمله

مثل اذا هرب اللاعب او اذا طلع الشرطي او المجرم من السيرفر يلغي التايمر والا تصير اخطاءهذا هو الكود وعليك البقية يا صاحب الموضوع ذذ

local timersT = {} 
  
function followFun ( attacker, wep ) 
    if ( getElementType ( attacker ) == "player" ) then 
        theTeam = getPlayerTeam ( attacker  ) 
        if ( theTeam == getTeamFromName ( "police" ) ) then 
            local wep = getPedWeapon ( attacker ) 
            local theWL = getPlayerWantedLevel ( source ) 
            if ( wep == 3 ) and ( theWL > 0 ) then 
                                if ( isTimer ( timersT[source] ) ) then 
                    killTimer ( timersT[source] ) 
                end 
                            timersT[source] = setTimer ( function ( ) local x,y = getElementPosition( source ) local x1,y1 = getElementPosition( attacker ) local rot = findRotation(x,y,x1,y1) setElementRotation ( source, 0,0,rot ) end, 500, 0 ) 
                showCursor ( source, true ) 
                setControlState ( source, "sprint", true ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerDamage", root, followFun ) 
  
function findRotation(x1,y1,x2,y2) 
    local t = -math.deg(math.atan2(x2-x1,y2-y1)) 
    if t < 0 then t = t + 360 end; 
    return t; 
end 

ايضا تحتاج الى اضافة كود

toggleControl 

لتعطيل القفز وغيره

Link to comment

ما اظن، اظنهم معرفين ذذ

اذا مو معرفين يعرفهم البطل صاحب الموضوع ذذ

timersT[source] = setTimer ( function ( ) local x,y = getElementPosition( source ) local x1,y1 = getElementPosition( attacker ) local rot = findRotation(x,y,x1,y1) setElementRotation ( source, 0,0,rot ) end, 500, 0 ) 

لازم تعرفهم بالتايمر كذا

timersT[source] = setTimer ( function (source, attacker) local x,y = getElementPosition( source ) local x1,y1 = getElementPosition( attacker ) local rot = findRotation(x,y,x1,y1) setElementRotation ( source, 0,0,rot ) end, 500, 0, source, attacker ) 

وذا ما له داعي لان يجي بالأفنت

local wep = getPedWeapon ( attacker ) 

Link to comment

ما اظن، اظنهم معرفين ذذ

اذا مو معرفين يعرفهم البطل صاحب الموضوع ذذ

timersT[source] = setTimer ( function ( ) local x,y = getElementPosition( source ) local x1,y1 = getElementPosition( attacker ) local rot = findRotation(x,y,x1,y1) setElementRotation ( source, 0,0,rot ) end, 500, 0 ) 

لازم تعرفهم بالتايمر كذا

timersT[source] = setTimer ( function (source, attacker) local x,y = getElementPosition( source ) local x1,y1 = getElementPosition( attacker ) local rot = findRotation(x,y,x1,y1) setElementRotation ( source, 0,0,rot ) end, 500, 0, source, attacker ) 

وذا ما له داعي لان يجي بالأفنت

local wep = getPedWeapon ( attacker ) 

مشكؤؤؤؤر تابل وبسول بجرب الكود ارد لكم خبر

المهم عندي سؤال وش معنا هذاي الرموز ؟

>

=>

Link to comment

ما اظن، اظنهم معرفين ذذ

اذا مو معرفين يعرفهم البطل صاحب الموضوع ذذ

timersT[source] = setTimer ( function ( ) local x,y = getElementPosition( source ) local x1,y1 = getElementPosition( attacker ) local rot = findRotation(x,y,x1,y1) setElementRotation ( source, 0,0,rot ) end, 500, 0 ) 

لازم تعرفهم بالتايمر كذا

timersT[source] = setTimer ( function (source, attacker) local x,y = getElementPosition( source ) local x1,y1 = getElementPosition( attacker ) local rot = findRotation(x,y,x1,y1) setElementRotation ( source, 0,0,rot ) end, 500, 0, source, attacker ) 

وذا ما له داعي لان يجي بالأفنت

local wep = getPedWeapon ( attacker ) 

مشكؤؤؤؤر تابل وبسول بجرب الكود ارد لكم خبر

المهم عندي سؤال وش معنا هذاي الرموز ؟

>

=>

هذي رموز تستخدمها عشان تفرق بين الارقام ..

==

يساوي

~=

لايساوي

<=

اقل من او يساوي

>=

اكبر من او يساوي

<

اقل من

>

اكبر من

Link to comment

هذي رموز تستخدمها عشان تفرق بين الارقام ..

==

يساوي

~=

لايساوي

<=

اقل من او يساوي

>=

اكبر من او يساوي

<

اقل من

>

اكبر من

مشكؤؤر سورا

شباب الكود ماضبط هذا الكود بعد ماعدله تابل

local timersT = {} 
  
function followFun ( attacker, wep ) 
    if ( getElementType ( attacker ) == "player" ) then 
        theTeam = getPlayerTeam ( attacker  ) 
        if ( theTeam == getTeamFromName ( "police" ) ) then 
            local wep = getPedWeapon ( attacker ) 
            local theWL = getPlayerWantedLevel ( source ) 
            if ( wep == 3 ) and ( theWL > 0 ) then 
                                if ( isTimer ( timersT[source] ) ) then 
                    killTimer ( timersT[source] ) 
                end 
                            timersT[source] = setTimer ( function (source, attacker) local x,y = getElementPosition( source ) local x1,y1 = getElementPosition( attacker ) local rot = findRotation(x,y,x1,y1) setElementRotation ( source, 0,0,rot ) end, 500, 0, source, attacker ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerDamage", root, followFun ) 
  
function findRotation(x1,y1,x2,y2) 
    local t = -math.deg(math.atan2(x2-x1,y2-y1)) 
    if t < 0 then t = t + 360 end; 
    return t; 
end 

Link to comment

الى تابل بعد قلبي ذذ

جرب هذا المثال ورد لي خبر

function aaaa() 
    local msg = "بسول" 
    setTimer(function() outputChatBox(msg) end,1000,0) 
end 
aaaa() 

بالنسبة لك اخ سوسو

جرب كودي الاول

Link to comment

الى تابل بعد قلبي ذذ

جرب هذا المثال ورد لي خبر

function aaaa() 
    local msg = "بسول" 
    setTimer(function() outputChatBox(msg) end,1000,0) 
end 
aaaa() 

بالنسبة لك اخ سوسو

جرب كودي الاول

[2001-01-04 01:02:58] WARNING: attacker\server.lua:4: Bad argument @ 'getElementType' [Expected element at argument 1, got nil] 

Link to comment

بعدل سطر 4 بهذا

if ( isElement(attacker) ) and ( getElementType ( attacker ) == "player" ) then 

[2001-01-04 01:14:14] ERROR: attacker\server.lua:23: attempt to perform arithmetic on local 'x1' (a boolean value) 
[2001-01-04 01:14:14] WARNING: attacker\server.lua:13: Bad argument @ 'getElementPosition' [Expected element at argument 1, got nil] 
  

Link to comment

هممممممم

الخطأ اما ان اللاعب او الشرطي طلع من السيرفر

او ان طريقتي في التعويض في التايمر خطأ

جرب هذا مثال تابل بعد التعديل

timersT[source] = setTimer ( function ( aaa,bbb ) if ( isElement(aaa) ) and ( isElement(bbb) ) then local x,y = getElementPosition( aaa ) local x1,y1 = getElementPosition( bbb ) local rot = findRotation(x,y,x1,y1) setElementRotation ( aaa, 0,0,rot ) end end, 500, 0, source,attacker ) 

Link to comment

هممممممم

الخطأ اما ان اللاعب او الشرطي طلع من السيرفر

او ان طريقتي في التعويض في التايمر خطأ

جرب هذا مثال تابل بعد التعديل

timersT[source] = setTimer ( function ( aaa,bbb ) if ( isElement(aaa) ) and ( isElement(bbb) ) then local x,y = getElementPosition( aaa ) local x1,y1 = getElementPosition( bbb ) local rot = findRotation(x,y,x1,y1) setElementRotation ( aaa, 0,0,rot ) end end, 500, 0, source,attacker ) 

ما ضبط :cry:

ع العموم مشكؤؤر بسول مالي مصلحه اسوي مود مو فاهم طريقته !

مشكؤؤؤر يغلق :mrgreen:

Link to comment

الى تابل بعد قلبي ذذ

جرب هذا المثال ورد لي خبر

function aaaa() 
    local msg = "بسول" 
    setTimer(function() outputChatBox(msg) end,1000,0) 
end 
aaaa() 

بالنسبة لك اخ سوسو

جرب كودي الاول

إلى بسول بعد قلبي ذذ

جرب ذا المثال ورد لي خبر

function aaaa() 
    setTimer(function() outputChatBox(getPlayerName(source)) end,1000,0) 
end 
addEventHandler("onPlayerChat", root, aaaa) 

وبعد ما تجربه

جرب المثال الثاني ورد لي خبر

function aaaa() 
    setTimer(function(source) outputChatBox(getPlayerName(source)) end,1000,0,source) 
end 
addEventHandler("onPlayerChat", root, aaaa) 

Link to comment

مشكووور يا تابل يا بعد قلبي ذذ

+

يا سوسو، وش الي ما ضبط بالضبط؟؟؟ هل يوجد اخطاء؟؟اذا ما يوجد، وش يصير بالضبط؟

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

زاوية ومدري شنو المهم انا مليت من الكود الصراححة الكود معقد

يغلق...

Link to comment
والله ي بسول الكود انا ما فهمت وش اللي فيه

زاوية ومدري شنو المهم انا مليت من الكود الصراححة الكود معقد

يغلق...

جرب ذا، واعتبرها اخر محاولة ذذ

اظنها تضبط وتخليه يمشي وراك، والباقي عليك

local timersT = {} 
  
function followFun ( attacker, wep ) 
    if ( isElement(attacker) ) and ( getElementType ( attacker ) == "player" ) then 
        theTeam = getPlayerTeam ( attacker  ) 
        if ( theTeam ) and ( theTeam == getTeamFromName ( "police" ) ) then 
            local theWL = getPlayerWantedLevel ( source ) 
            if ( wep == 3 ) and ( theWL > 0 ) then 
                if ( isTimer ( timersT[source] ) ) then 
                    killTimer ( timersT[source] ) 
                end 
                timersT[source] = setTimer ( function ( aaa,bbb ) if ( isElement(aaa) ) and ( isElement(bbb) ) then local x,y = getElementPosition( aaa ) local x1,y1 = getElementPosition( bbb ) local rot = findRotation(x,y,x1,y1) setElementRotation ( aaa, 0,0,rot ) end end, 500, 0, source,attacker ) 
                setPedAnimation ( source,"ped","run_1armed",-1,true,true,false,false) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerDamage", root, followFun ) 
  
function findRotation(x1,y1,x2,y2) 
    local t = -math.deg(math.atan2(x2-x1,y2-y1)) 
    if t < 0 then t = t + 360 end; 
    return t; 
end 

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