@@ -30,46 +30,40 @@ MSK = exports.msk_core:GetLib()
3030---- ------------------------------------------------------------
3131--  MSK.Input(header, placeholder, field, cb)
3232setmetatable (MSK .Input , {
33-     __call  =  function (self , header ,  placeholder ,  field ,  cb )
34-         self .Open (header ,  placeholder ,  field ,  cb )
33+     __call  =  function (self , ... )
34+         self .Open (... )
3535    end 
3636})
3737
3838--  MSK.Numpad(pin, showPin, cb)
3939setmetatable (MSK .Numpad , {
40-     __call  =  function (self , pin ,  showPin ,  cb )
41-         self .Open (pin ,  showPin ,  cb )
40+     __call  =  function (self , ... )
41+         self .Open (... )
4242    end 
4343})
4444
4545--  MSK.Progress(data)
4646setmetatable (MSK .Progress , {
47-     __call  =  function (self , data ,  text ,  color )
48-         self .Start (data ,  text ,  color )
47+     __call  =  function (self , ... )
48+         self .Start (... )
4949    end 
5050})
5151
5252---- ------------------------------------------------------------
5353--  MSK.Player
5454---- ------------------------------------------------------------
5555if  context  ==  ' client'  then 
56-     local  Player  =  {
57-         clientId  =  MSK .Player .clientId ,
58-         serverId  =  MSK .Player .serverId ,
59-         playerId  =  MSK .Player .playerId ,
60-         state  =  Player (MSK .Player .serverId ).state ,
61-         ped  =  MSK .Player .ped ,
62-         playerPed  =  MSK .Player .ped ,
63-         coords  =  MSK .Player .coords ,
64-         heading  =  MSK .Player .heading ,
65-         vehicle  =  MSK .Player .vehicle ,
66-         seat  =  MSK .Player .seat ,
67-         weapon  =  MSK .Player .weapon ,
68-         isDead  =  MSK .Player .isDead ,
69-         Notify  =  MSK .Player .Notify ,
70-     }
71- 
72-     MSK .Player  =  Player 
56+     setmetatable (MSK .Player , {
57+         __index  =  function (self , key )
58+             if  key  ==  ' coords'  then 
59+                 return  GetEntityCoords (self .ped )
60+             elseif  key  ==  ' heading'  then 
61+                 return  GetEntityHeading (self .ped )
62+             elseif  key  ==  ' state'  then 
63+                 return  PlayerState (self .serverId ).state 
64+             end 
65+         end 
66+     })
7367
7468    AddEventHandler (' msk_core:onPlayer'  , function (key , value , oldValue )
7569        MSK .Player [key ] =  value 
@@ -81,9 +75,31 @@ if context == 'client' then
8175end 
8276
8377if  context  ==  ' server'  then 
78+     local  metatable  =  {
79+         __index  =  function (self , key )
80+             if  type (key ) ==  " string"  then 
81+                 return  rawget (self , tonumber (key ))
82+             end 
83+         end 
84+     }
85+     setmetatable (MSK .Player , metatable )
86+ 
87+     local  playerMeta  =  {
88+         __index  =  function (self , key )
89+             if  key  ==  ' coords'  then 
90+                 return  GetEntityCoords (self .ped )
91+             elseif  key  ==  ' heading'  then 
92+                 return  GetEntityHeading (self .ped )
93+             elseif  key  ==  ' state'  then 
94+                 return  PlayerState (self .serverId ).state 
95+             end 
96+         end 
97+     }
98+ 
8499    AddEventHandler (' msk_core:OnPlayer'  , function (playerId , key , value , oldValue )
85100        if  not  MSK .Player [playerId ] then 
86101            MSK .Player [playerId ] =  {}
102+             setmetatable (MSK .Player [playerId ], playerMeta )
87103        end 
88104
89105        MSK .Player [playerId ][key ] =  value 
@@ -93,4 +109,10 @@ if context == 'server' then
93109        if  not  MSK .Player [playerId ] then  return  end 
94110        MSK .Player [playerId ][key ] =  nil 
95111    end )
112+ 
113+     for  playerId , data  in  pairs (MSK .Player ) do 
114+         if  not  getmetatable (MSK .Player [playerId ]) then 
115+             setmetatable (MSK .Player [playerId ], playerMeta )
116+         end 
117+     end 
96118end 
0 commit comments