Jump to content

ابي تصليح كود


Recommended Posts

ذا كود جبته من زاحف

    local Url = "crown.png" --- اسسم الصورة هنا 
    local zUP = 16 ---- ارتفأع الصورة 
      
    addEventHandler( "onClientRender", root, function (  ) 
           local x, y, z = getElementPosition( localplayer ) 
           local Mx, My, Mz = getCameraMatrix(   ) 
           local accName = getAccountName ( getPlayerAccount ( localplayer ) ) 
           if isObjectInACLGroup ("user."..accName, aclGetGroup ( "V.I.P" ) ) then 
            if ( getDistanceBetweenPoints3D( x, y, z, Mx, My, Mz ) <= 15 ) then 
               local WorldPositionX, WorldPositionY = getScreenFromWorldPosition( x, y, z + zUP, 0.07 ) 
                if ( WorldPositionX and WorldPositionY ) then 
                   dxDrawImage( WorldPositionX, WorldPositionY, WorldPositionX, WorldPositionY, Url ) 
              end 
          end 
       end 
    end ) 

Link to comment

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

هذي طريقة عشان الصورة تكون لقروب محدد ..

Client Side !

local Url = "crown.png" --- اسسم الصورة هنا 
local zUP = 10 ---- ارتفأع الصورة 
      
addEventHandler( "onClientRender", root, function (  ) 
  if ( getElementData ( localPlayer, "VIPData" ) == true ) then 
    local x, y, z = getElementPosition( localPlayer ) 
    local Mx, My, Mz = getCameraMatrix(   ) 
    if ( getDistanceBetweenPoints3D( x, y, z, Mx, My, Mz ) <= 15 ) then 
       local WorldPositionX, WorldPositionY = getScreenFromWorldPosition( x, y, z + zUP, 0.07 ) 
        if ( WorldPositionX and WorldPositionY ) then 
             dxDrawImage( WorldPositionX, WorldPositionY, WorldPositionX, WorldPositionY, Url ) 
         end 
      end 
   end 
end ) 

Server Side !

addEventHandler ( "onResourceStart", resourceRoot, function (  ) 
  for _,players in ipairs ( getElementsByType ( "player" ) ) do 
    if  ( getPlayerAccount( players ) and not isGuestAccount( getPlayerAccount( players ) ) ) then 
     if ( isObjectInACLGroup ( "user."..getAccountName ( getPlayerAccount ( players ) ), aclGetGroup ( "V.I.P" ) ) ) then 
             setElementData ( players, "VIPData", true ) 
          end 
       end 
    end 
end )    
  
  
addEventHandler ( "onPlayerLogin", root, function ( _,acc ) 
  if ( isObjectInACLGroup ( "user."..getAccountName( acc ), aclGetGroup ( "V.I.P" ) ) ) then 
       setElementData ( source, "VIPData", true ) 
    end 
end ) 
Edited by Guest
Link to comment
... وهذا فنكشن بجانب سيرفر isObjectInACLGroup انت مستخدم

هذي طريقة عشان الصورة تكون لقروب محدد ..

Client Side !

local Url = "crown.png" --- اسسم الصورة هنا 
local zUP = 10 ---- ارتفأع الصورة 
      
addEventHandler( "onClientRender", root, function (  ) 
  if ( getElementData ( localPlayer, "VIPData" ) and getElementData ( localPlayer, "VIPData" ) == true ) then 
    local x, y, z = getElementPosition( localPlayer ) 
    local Mx, My, Mz = getCameraMatrix(   ) 
    if ( getDistanceBetweenPoints3D( x, y, z, Mx, My, Mz ) <= 15 ) then 
       local WorldPositionX, WorldPositionY = getScreenFromWorldPosition( x, y, z + zUP, 0.07 ) 
        if ( WorldPositionX and WorldPositionY ) then 
             dxDrawImage( WorldPositionX, WorldPositionY, WorldPositionX, WorldPositionY, Url ) 
         end 
      end 
   end 
end ) 

Server Side !

addEventHandler ( "onResourceStart", resourceRoot, function (  ) 
  for _,players in ipairs ( getElementsByType ( "player" ) ) do 
   if ( isObjectInACLGroup ( "user."..getAccountName ( getPlayerAccount ( players ) ), aclGetGroup ( "V.I.P" ) ) ) then 
          setElementData ( players, "VIPData", true ) 
       end 
    end 
end )    
  
  
addEventHandler ( "onPlayerLogin", root, function ( _,acc ) 
  if ( isObjectInACLGroup ( "user."..getAccountName( acc ), aclGetGroup ( "V.I.P" ) ) ) then 
       setElementData ( source, "VIPData", true ) 
    end 
end )    
  
addEventHandler ( "onPlayerJoin", root, function (  ) 
    setElementData ( source, "VIPData", false ) 
end ) 

ليه ضايف بجانب سيرفر حدث عند دخول اللاعب وبعدها توخر الداتا منه؟

مايحتاج تضيف هالحدث بالأساس؛ لأنه اللاعب لما يخرج من السيرفر كل الداتا المخزنة عليه راح تنحذف

onResourceStart ناقصك تتحقق من أن اللاعب مسجل دخوله بحسابه قبل أن تحقق من القروب الي هو فيه بحدث +

isGuestAccount من خلال وظيفة ^

عندك تحقق زايد بجانب الكلاينت حق الداتا في سطر 5 ( الشرط الثاني )ـ +

Link to comment
.. بالنسبة للـداتا فـ ما ياثر لو شلتها او خليتها .. بس ذي طريقتي .

وش دخل طريقتي وطريقتك؟

+

حق السيرفر (CPU) مين قالك انه ما راح يأثر؟ الداتا لو ماكان فيه داعي انك تستخدمها لاتستخدمها .. لأنها تستهلك من وحدة المعالجة المركزية

network traffic بالإضافة إلى أنها تنتج الكثير من الـ

:لاحظ الويكي وش يقولك

This function stores element data under a certain key, attached to an element. Element data set using this is then synced with all clients and the server. The data can contain server created elements, but you should avoid passing data that is not able to be synced such as xmlnodes, acls, aclgroups etc.

As element data is synced to all clients, it can generate a lot of network traffic and consume server CPU. Events are much more efficient for sending data from a client to the server only, or from the server to a specific client.

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