Jump to content

تحت التطوير :كود - Useful Arab functions


Booo

Recommended Posts

zWDoHTl.png

getGuestPlayers

وظيفة جلب جميع الاعبين غير مسجيلن الدخول

Syntax :

table getGuestPlayers (  ) 

Returns

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

الفنكشن نوعه سيرفر سايد فقط

Code :

function getGuestPlayers (  ) 
  
    local Guest = { } ; 
  
    for _ , players_ in ipairs ( getElementsByType ( "player" ) ) do  
  
    local playerAcc = getPlayerAccount ( players_ ) 
  
    if isGuestAccount ( playerAcc ) then 
  
    table.insert ( Guest , players_ ) 
  
                end 
            end  
        return Guest 
    end 
  

Ex 1 :

addCommandHandler ( "getGuestPlayers_" , function ( ) 
  
    local GuestPlayers = getGuestPlayers (  ) 
  
    if ( #GuestPlayers ~= 0 ) then 
  
    for _ , v in ipairs ( GuestPlayers ) do  
  
    outputChatBox (  getPlayerName ( v ) : gsub ( "#%x%x%x%x%x%x", "" ) .. "plz Login or Register" , v , 255 , 255 , 255 , true ) 
  
            end 
        end 
    end 
    ) ; 
     
-- F8 Say : getGuestPlayers_ 

Ex 2 :

addCommandHandler ( "killGuestPlayers" , function ( ) 
  
    local GuestPlayers = getGuestPlayers (  ) 
  
    if ( #GuestPlayers ~= 0 ) then 
  
    for _ , v in ipairs ( GuestPlayers ) do  
  
    killPed ( v ) 
  
            end 
        end 
    end 
    ) ; 
  
--F8 Say : killGuestPlayers 

Ex 3 :

outputChatBox ( #getGuestPlayers (  )  ) 

Author : Abdul KariM

اتمنى ان الفنكشن اعجبكم

والسلام عليكم ورحمة الله وبركاته , في امان الله

Link to comment

setPlayerHealthAndArmor

code

function  setPlayerHealthAndArmor(plr,hb,ar) 
if ( getElementType(plr) == "player" )  then   
if ( type(hb) == "number" and type(ar) == "number"  )then  
setElementHealth(plr,tonumber(hb)) 
setPedArmor(plr,tonumber(ar)) 
else 
error("Bad Argument 1 and 2 must number") 
end 
else 
error("Bad Argument 1  must player") 
end 
end 

  
-- مثال 
addCommandHandler("p", 
function (playerr) 
setPlayerHealthAndArmor(playerr,100,100) 
end 
) 

Link to comment

getVehiclesInServer

code

function getVehiclesInServer () 
local cars = { } 
for _,v in ipairs ( getElementsByType ( "vehicle" ) ) do 
table.insert (cars,v) 
end  
return cars 
end 
  

مثال

addCommandHandler("p", 
function (playerr) 
outputChatBox(""..#getVehiclesInServer().."",playerr,0,255,0) 
end 
) 
  

------

isVehiclesidInServer

Code

function isVehiclesidInServer(id1) 
    if type(id1) == "number" then 
        for __,cc in ipairs ( getElementsByType ( "vehicle" ) ) do 
            local idd = getElementModel(cc) 
            if  ( idd  == tonumber(id1)  ) then 
                return true 
            end 
        end 
        return false 
    else 
        error("Bad Argument 1 must number") 
    end 
end 

Edited by Guest
Link to comment
  • Moderators

isVehiclesidInServer

Code

function isVehiclesidInServer(id1) 
if type(id1) == "number" then  
for __,cc in ipairs ( getElementsByType ( "vehicle" ) ) do 
local idd = getElementModel(cc) 
if  ( idd  == tonumber(id1)  ) then  
return true  
else 
return false 
end 
end 
else 
error("Bad Argument 1 must number") 
end 
end 

مثالك ذا فيه خطأ تخيل حاليأ انا ابي السياره الي رقمها 411 وفيه بالسيرفر مثلا 5 سيارات

الاولي مثلا الايدي حقها 500 و الثانيه 411 و الثالثه 400

false الكود حقك بيشوف اول سياره هل الايدي حقها 411 ؟ اذا مو 411 راح يوقف الوظيفة ويرسل القيمة

فـ يصير كودك بهذا الشكل

function isVehiclesidInServer(id1) 
    if type(id1) == "number" then  
        for __,cc in ipairs ( getElementsByType ( "vehicle" ) ) do 
            local idd = getElementModel(cc) 
            if  ( idd  == tonumber(id1)  ) then  
                return true  
            end 
        end 
        return false 
    else 
        error("Bad Argument 1 must number") 
    end 
end 
Link to comment
  • 3 weeks later...
function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing ( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

function dxDrawHoverRectangle(x, y, w, h, color, color2, post)
local x = x or 0
local y = y or 0
local w = w or 0
local h = h or 0
local color = color or tocolor(255, 255, 255, 255)
local color2 = color2 or tocolor(255, 255, 255, 150)
local post = post or false
if isMouseInPosition(x, y, w, h) then
dxDrawRectangle(x, y, w, h, color2, post)
else
dxDrawRectangle(x, y, w, h, color, post)
end
end

السلام عليكم اليوم سويت وظيفة لمساعدة الناس الي يستعملون الدي اكس اكتير

بصراحة معرف اذا مفيدة ولا لا لكم بس هي بالنسبة لي اشوفها مفيدة للي يحبون يسو تأثيرات للدي اكس

المتطلبات ان تكون واضع وظيفة isMouseInPosition 

+ ملعرف اذا الأسم مناسب او لا لاني ما لقيت اسم كويس لها

------------------------------------------------------------------

اسم الوظيفة : dxDrawHoverRectangle
Type : Client Side only
Requiard Arg. :
x = X احداثيات
y = Y احداثيات
w = Rectangle Width
h = Rectangle Height
color = the main color of the Rectangle
color2 = the color of the Rectangle when the Cursor pass on it

Example : 

addEventHandler("onClientRender", root,
function()
dxDrawHoverRectangle(100, 100, 50, 50, tocolor(255, 255, 255, 150), tocolor(0, 0, 0, 150), false)
end)

 

  • Like 2
Link to comment
On 9/15/2016 at 9:03 AM, x1AhMeD,-09 said:

السلام عليكم اليوم سويت وظيفة لمساعدة الناس الي يستعملون الدي اكس اكتير

بصراحة معرف اذا مفيدة ولا لا لكم بس هي بالنسبة لي اشوفها مفيدة للي يحبون يسو تأثيرات للدي اكس

المتطلبات ان تكون واضع وظيفة isMouseInPosition 

+ ملعرف اذا الأسم مناسب او لا لاني ما لقيت اسم كويس لها

------------------------------------------------------------------

اسم الوظيفة : dxDrawHoverRectangle
Type : Client Side only
Requiard Arg. :
x = X احداثيات
y = Y احداثيات
w = Rectangle Width
h = Rectangle Height
color = the main color of the Rectangle
color2 = the color of the Rectangle when the Cursor pass on it

Example : 

 


function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing ( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

function dxDrawHoverRectangle(x, y, w, h, color, color2, post)
local x = x or 0
local y = y or 0
local w = w or 0
local h = h or 0
local color = color or tocolor(255, 255, 255, 255)
local color2 = color2 or tocolor(255, 255, 255, 150)
local post = post or false
if isMouseInPosition(x, y, w, h) then
dxDrawRectangle(x, y, w, h, color2, post)
else
dxDrawRectangle(x, y, w, h, color, post)
end
end

addEventHandler("onClientRender", root,
function()
dxDrawHoverRectangle(100, 100, 50, 50, tocolor(255, 255, 255, 150), tocolor(0, 0, 0, 150), false)
end)

الكود مفيد ولا لا ما حد رد .. اسبوع 

  • Like 1
Link to comment
2 hours ago, back!_ said:

حلوه بنسبه لي

بس يآ أحمد

وش تقصد بي التآثيرات

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

يتغير لون الدي اكس ^

زي زر 

GUI

مو لما تقف عليه يتغير لونو ؟ 

هوا هيك نفس الحكاية

function dxDrawHoverRectangle(x, y, w, h, color, color2, post)
local x = x or 0
local y = y or 0
local w = w or 0
local h = h or 0
local color = color or tocolor(255, 255, 255, 255)
local color2 = color2 or tocolor(255, 255, 255, 150)
local post = post or false
if isMouseInPosition(x, y, w, h) then
MainColor = color2
else
MainColor = color
end
dxDrawRectangle(x, y, w, h, MainColor, post)
end

+ اختصرت الكود شوي

Edited by x1AhMeD,-09
Link to comment
Just now, x1AhMeD,-09 said:

زي زر 

GUI

مو لما تقف عليه يتغير لونو ؟ 

هوا هيك نفس الحكاية

+ اختصرت الكود شوي


function dxDrawHoverRectangle(x, y, w, h, color, color2, post)
local x = x or 0
local y = y or 0
local w = w or 0
local h = h or 0
local color = color or tocolor(255, 255, 255, 255)
local color2 = color2 or tocolor(255, 255, 255, 150)
local post = post or false
if isMouseInPosition(x, y, w, h) then
MainColor = color2
else
MainColor = color
end
dxDrawRectangle(x, y, w, h, MainColor, post)
end

ممكن مثال على زر دي اكس

Link to comment
Just now, x1AhMeD,-09 said:

 


addEventHandler("onClientRender", root,function()dxDrawHoverRectangle(100, 100, 50, 50, tocolor(255, 255, 255, 150), tocolor(0, 0, 0, 150), false)end)

الي فهمته ان الارقام الي بعد 

tocolor الاول

هي الون قبل المس على المستطيل

وبعد المس على المستطيل تصير لونه 

tocolor(0, 0, 0, 150)

صح 

انا ما اعرف لدي اكس ابدا ^^

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

 


function dxDrawHoverRectangle(x, y, w, h, color, color2, post)
local x = x or 0
local y = y or 0
local w = w or 0
local h = h or 0
local color = color or tocolor(255, 255, 255, 255)
local color2 = color2 or tocolor(255, 255, 255, 150)
local post = post or false
if isMouseInPosition(x, y, w, h) then
MainColor = color2
else
MainColor = color
end
dxDrawRectangle(x, y, w, h, MainColor, post)
end
-------------------------------------------------------------------------

addEventHandler("onClientRender", root,
function()
r_button1 = dxDrawHoverRectangle(100, 100, 50, 50, tocolor(255, 255, 255, 150), tocolor(0, 0, 0, 150), false)
end
)

-------------------------------------------------------------------------
addEventHandler ( "onClientGUIClick", root,
  function ()
   if source == r_button1 then
     outputChatBox ( "--------", getRootElement(), 250, 0, 0, True )
	end
end

)

 

Link to comment

تفضل ^ .. 
 

function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing ( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

addEventHandler("onClientRender",root, function ( )
dxDrawRectangle(206, 241, 367, 26,(isMouseInPosition (206,241,367,26) and tocolor ( 0,153 , 255 , 255 ) or tocolor(0, 0, 0, 140)) , false)
end );

addEventHandler ( "onClientClick" , root , function ( Button , State )
if ( Button == "left" and state == "up" ) then 
if ( isMouseInPosition (206,241,367,26) ) then 
outputChatBox ( "Your Name is : "..getPlayerName(localPlayer) )
end
end
end );

 

 

Edited by Default
Added LUA Code
Link to comment
Just now, Default said:

تفضل ^ .. 
 


function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing ( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

addEventHandler("onClientRender",root, function ( )
dxDrawRectangle(206, 241, 367, 26,(isMouseInPosition (206,241,367,26) and tocolor ( 0,153 , 255 , 255 ) or tocolor(0, 0, 0, 140)) , false)
end );

addEventHandler ( "onClientClick" , root , function ( Button , State )
if ( Button == "left" and state == "up" ) then 
if ( isMouseInPosition (206,241,367,26) ) then 
outputChatBox ( "Your Name is : "..getPlayerName(localPlayer) )
end
end
end );

 

 

ممكن توصلي هذا السطر

if ( Button == "left" and state == "up" ) then

وش ممعنا left and state and up

Link to comment
  • Moderators

button = هذا الزر حق الماوس , اهو حاط يسار يعني كلك يسار يمديك تحط يمين او الكوره الي في وسط الماوس

state = يعني لما تضغط الزر حق الماوس وترفع اصبعك من عليه , ولكن لو خليتها " داون " بيكون لما تضغط الزر لتحت راح يشتغل اتمني وصلت .

 

Link to comment
Just now, NssoR said:

button = هذا الزر حق الماوس , اهو حاط يسار يعني كلك يسار يمديك تحط يمين او الكوره الي في وسط الماوس

state = يعني لما تضغط الزر حق الماوس وترفع اصبعك من عليه , ولكن لو خليتها " داون " بيكون لما تضغط الزر لتحت راح يشتغل اتمني وصلت .

 

مشكور وصلت يآ نصور

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