Jump to content

مشكله السالب


Mars2

Recommended Posts

السلام عليكم

local marker1 = createMarker(207.19234,1920.68762,16.64063, 'cylinder',2,143, 155, 154) 
  
function markerHiteko1(playerTeam1) 
if getElementType(playerTeam1) == "player" then 
if getPlayerTeam(playerTeam1) and getTeamName(getPlayerTeam(playerTeam1)) == "Team" then 
if getPlayerMoney ( playerTeam1 ) then 
takePlayerMoney ( playerTeam1, 40000 ) 
setElementDimension (playerTeam1, 2 ) 
setElementPosition (playerTeam1, 202.87492,1896.65649,17.64063 ) 
outputChatBox ( "تم نقلك الى العالم الوهمي", playerTeam1,0,255,0 ) 
else  
outputChatBox ( "انت لست بالتيم" ,playerTeam1,255,0,0 ) 
end 
end 
end 
end 
addEventHandler( "onMarkerHit", marker1,markerHiteko1) 
  

الكود عند لمس الماركر يتحقق من اسم التيم لو موجود ينقله ويخصم منه فلوس وينقله لعالم وهمي

لكن المشكله انه لما تكون الفلوس 0 تصير بالسالب ابي يقوله لا تملك المال ما ابيها تصير سالب

ابي الكود فقط الي ما يخليه سالب

وما ابي احد يعطيني جاهز مشان اعرف خطأي

Link to comment

ليش صاف الكود فوق بعضه

رتب الكود ذا راح يساعدك قبل ما يساعدنا بقراءة و فهم الكود

local marker1 = createMarker(207.19, 1920.688, 16.64, "cylinder", 2, 143, 155, 154) 
  
function markerHiteko1(playerTeam1) 
    if getElementType(playerTeam1) == "player" then 
        local team = getPlayerTeam(playerTeam1) 
        if team and getTeamName(team) == "Team" then 
            if getPlayerMoney(playerTeam1) >= 40000 then 
                takePlayerMoney(playerTeam1, 40000) 
                setElementDimension(playerTeam1, 2) 
                setElementPosition(playerTeam1, 202.88, 1896.65, 17.65) 
                outputChatBox("تم نقلك الى العالم الوهمي", playerTeam1, 0, 255, 0) 
            else 
                outputChatBox("لا تملك المال ", playerTeam1, 255, 0, 0) 
            end 
        else 
            outputChatBox("انت لست بالتيم", playerTeam1, 255, 0, 0) 
        end 
    end 
end 
addEventHandler("onMarkerHit", marker1, markerHiteko1) 

Link to comment

اخوي ترا انا ما استفدت منك انت غيرت وحطيت متغيرات وكذا ما راح افهم بدي تقولي بس وش الاكواد الي اضيفها على كودي لانه انت حطيت عليه متغيرات وانا ما ابي متغيرات

Link to comment

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

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

عموماً بالنسبة لكودك كان تحتاج تغير السطر ذا

if getPlayerMoney ( playerTeam1 ) then 

إلى

if getPlayerMoney ( playerTeam1 ) >= 40000 then 

Link to comment

ذي الصورة تشوف فيها اللون الأخضر والتحقق التابع له

و اللون الأصفر و التحقق التابع له

و اللون الأحمر و التحقق التابع له

0q5omOz.png

متوازين بالمسافة if else 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...