Jump to content

[return-break-tostring-tonumber] : تحديث : شرح


Recommended Posts

يعطيك آلف آلف عآفيهة يَ آلغلآ

شرح منتآز ومفهوم ..

بس حبيت آستفسر عن آلبريك .. ممكن توضح لنآ آكثر وش وظيفتهآ .. وهل ظروري نحطهآ ولآ مو لآزم !

وآصل جديدك ولآ تححرمـنآ منه يَ بطل

.. :wink:

Link to comment

:?break لول المثال اللي تحت مثال تطبيقي على الدرس ما عدا

server side - function

-- player = the man who write the command 
-- command = the command "send" 
-- amount = the number of money he wish to send 
-- sendMoney = name of function 
function sendMoney(player, command, amount) -- start of function 
    if isObjectInACLGroup ( "user." .. getAccountName (getPlayerAccount(player)), aclGetGroup ( "Admin" ) ) then -- if player from admin group (1) 
        if amount ~= "" and amount ~= nil then -- if player forget amount (1) 
            for k,v in ipairs ( getElementsByType( "player" ) ) do -- get all players in server 
                if tonumber(amount) then -- if player write in console number then 
                    num = getPlayerCount ( ) -- get players in server 
                    clear = math.floor( amount ) -- if player write number like this 9.5 it will by 9 
                    real = num * clear -- players in server x amount 
                else -- if player write anything else numbers then 
                    outputChatBox("please write numbers not words", getRootElement(), 255,0,0,true) -- out to chat box 
                end -- end of if tonumber(amount) 
                if real > getPlayerMoney( player ) then outputChatBox("if you will send "..amount.."$ to "..num.." player in server you need to "..real.."$", player, 255,0,0,true) return end -- close anything by "return end" if player does not have enough money 
                        takePlayerMoney ( player, real ) -- take from player who write the command total money 
                        givePlayerMoney( v, clear ) -- give all players money v = all players 
                        outputChatBox("Admin ["..getPlayerName(player).."] give all players ["..clear.."$]", getRootElement(), 255,0,0,true) -- out to chat box 
            end -- end of for k,v in ipairs 
        else -- if player forget amount (2) then 
            outputChatBox("send ", getRootElement(), 255,0,0,true) -- out to chat box & nosting happend 
        end -- end of if amount ~= "" and amount ~= nil 
    else -- if player from admin group (2) then 
        outputChatBox("you are not in admin group", getRootElement(), 255,0,0,true) -- out to chat box & nosting happend 
    end -- end of if isObjectInACLGroup 
end -- end of function 
addCommandHandler("send", sendMoney) -- addCommand with this function named sendMoney 
Edited by Guest
Link to comment
^ وليه يعني تشوفه كود خارق ؟

تراه كود بسيط ذذ

وانت كذا تعقد الناس عطهم امثله سهله اذا انت عندك خبره غيرك ما عنده :?

:?انا ما قلت الكود خارق الكود عباره عن خلاصة الدرس كله في اسكربت

Link to comment
:?break لول المثال اللي تحت مثال تطبيقي على الدرس ما عدا

server side - function

-- player = the man who write the command 
-- command = the command "send" 
-- amount = the number of money he wish to send 
-- sendMoney = name of function 
function sendMoney(player, command, amount) -- start of function 
    if isObjectInACLGroup ( "user." .. getAccountName (getPlayerAccount(player)), aclGetGroup ( "Admin" ) ) then -- if player from admin group (1) 
        if amount ~= "" and amount ~= nil then -- if player forget amount (1) 
            for k,v in ipairs ( getElementsByType( "player" ) ) do -- get all players in server 
                if tonumber(amount) then -- if player write in console number then 
                    num = getPlayerCount ( ) -- get players in server 
                    clear = math.floor( amount ) -- if player write number like this 9.5 it will by 9 
                    real = num * clear -- players in server x amount 
                else -- if player write anything else numbers then 
                    outputChatBox("please write numbers not words", getRootElement(), 255,0,0,true) -- out to chat box 
                end -- end of if tonumber(amount) 
                if real > getPlayerMoney( player ) then outputChatBox("if you will send "..amount.."$ to "..num.." player in server you need to "..real.."$", player, 255,0,0,true) return end -- close anything by "return end" if player does not have enough money 
                        takePlayerMoney ( player, real ) -- take from player who write the command total money 
                        givePlayerMoney( v, clear ) -- give all players money v = all players 
                        outputChatBox("Admin ["..getPlayerName(player).."] give all players ["..clear.."$]", getRootElement(), 255,0,0,true) -- out to chat box 
            end -- end of for k,v in ipairs 
        else -- if player forget amount (2) then 
            outputChatBox("send ", getRootElement(), 255,0,0,true) -- out to chat box & nosting happend 
        end -- end of if amount ~= "" and amount ~= nil 
    else -- if player from admin group (2) then 
        outputChatBox("you are not in admin group", getRootElement(), 255,0,0,true) -- out to chat box & nosting happend 
    end -- end of if isObjectInACLGroup 
end -- end of function 
addCommandHandler("send", sendMoney) -- addCommand with this function named sendMoney 

ماتحس لو قريت القوانين حق ذا القسم احسن ؟ :roll:

viewtopic.php?f=119&t=49609

Link to comment
  • 2 weeks later...
  • 1 month later...
can some one explain ipairs for me plz in arabic !

 

اولا هذا قسم عربي فـ ياريت لو تتكلم عربي

 

فهي تستخدم لجلب المفاتيح او القيم ipairs بالنسبه لـ

 

مثال,

 

تسوي اول شيء جدول ,

 

table = {'darhal','darhal2','darhal3'} 

ipairs والحين تستخدم

for k,v in ipairs( table ) do 

k = key المفتاح

v = value القيمه

والحين تسوي الشيء الي تبيه مثلا نص بالشات

outputChatBox('Count : '..k..'  Text :'..v)   

كذا راح يجيب عدد المفاتيح , وهي ثلاثه,

darhal darhal2 darhal3 = 3

والقيم راح يجيب لك الكلام,

darhal darhal2 darhal3

  • Thanks 1
Link to comment
  • 2 weeks later...
allah y5alik w ythibk 3la chr7k el wafi w asf 3la el english ma3ndi keyboard 3arabi fi el hatf

وش جابك ب حارتنا ذذ ^_$

~~

شررح بططران ومفيدد

اكثر المبرمجين دوافير ب الدراسسه خاصتن الرياضيات نادر جدا تحصل فاشل ب الدراسه مبرمج << خششه غلط q1

برب نراجع الشرح

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