luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Witam
Dzi? chce pokaza? ciekawe funkcje lua kt?re u?atwi? pisanie.
________________________________________________________________________________
centerWindow
Sk?adnia:
centerWindow ( element TheElement )
element - Element gui (Window) jaki chcesz ustawi? na ?rodku ekranu.
wy?ej podajemy w pliku kod:
local x , y = guiGetScreenSize ()
guiCreateWindow ( ( sw - 500 ) / 2 , ( sh - 500 ) / 2 , szeroko ??, wysoko ??, "tekst" , false )
smoothMoveCamera
Sk?adnia:
smoothMoveCamera ( x1 , y1 , z1 , rotx1 , roty1 , rotz1 , x2 , y2 , z2 , rotx2 , roty2 , rotz2 , czas )
x1, y1z,z1 - Pozycja na mapie z kt?rej ma kamera lecie?
rotx1, roty1, rotz1 - Rotacja na pocz?tku mapy.
x2, y2, z2 - Pozycja na mapie w kt?rym a si? zako?czy? lataj?ca kamera.
rotx2, roty2, rotz2 - Rotacja na ko?cu mapy.
czas - szybko?? ruchu kamery.
Funkcja ta ustawia gdzie? na mapie i pozwala lecie? jej do punktu 2 przez map? w kierunku patrzenia jakim chcesz.
Funkcje staw tam kiedy kamera ma lecie?.
wy?ej podajemy w pliku kod:
local sm = {}
sm . moov = 0
sm . object1 , sm . object2 = nil , nil
local function removeCamHandler ()
if( sm . moov == 1 ) then
sm . moov = 0
removeEventHandler ( "onClientPreRender" , getRootElement (), camRender )
end
end
local function camRender ()
local x1 , y1 , z1 = getElementPosition ( sm . object1 )
local x2 , y2 , z2 = getElementPosition ( sm . object2 )
setCameraMatrix ( x1 , y1 , z1 , x2 , y2 , z2 )
end
function smoothMoveCamera ( x1 , y1 , z1 , x1t , y1t , z1t , x2 , y2 , z2 , x2t , y2t , z2t , time )
if( sm . moov == 1 ) then return false end
sm . object1 = createObject ( 1337 , x1 , y1 , z1 )
sm . object2 = createObject ( 1337 , x1t , y1t , z1t )
setElementAlpha ( sm . object1 , 0 )
setElementAlpha ( sm . object2 , 0 )
setObjectScale ( sm . object1 , 0.01 )
setObjectScale ( sm . object2 , 0.01 )
moveObject ( sm . object1 , time , x2 , y2 , z2 , 0 , 0 , 0 , "InOutQuad" )
moveObject ( sm . object2 , time , x2t , y2t , z2t , 0 , 0 , 0 , "InOutQuad" )
addEventHandler ( "onClientPreRender" , getRootElement (), camRender )
sm . moov = 1
setTimer ( removeCamHandler , time , 1 )
setTimer ( destroyElement , time , 1 , sm . object1 )
setTimer ( destroyElement , time , 1 , sm . object2 )
return true
end
Wikipedia Multi The Auto : San Andreas :
getOnlineAdmins
Sk?adnia:
Funkcja pokazuje czy jest admin online na serwerze
wy?ej podajemy w pliku kod:
function getOnlineAdmins ()
local t = {}
for k , v in ipairs ( getElementsByType ( "player" ) ) do
while true do
local acc = getPlayerAccount ( v )
if not acc or isGuestAccount ( acc ) then break end
local accName = getAccountName ( acc )
local isAdmin = isObjectInACLGroup ( "user." .. accName , aclGetGroup ( "Admin" ))
if isAdmin == true then
table . insert ( t , v )
end
break
end
end
return t
end
Przyk?ad :
function getOnlineAdmins ()
local t = {}
for k , v in ipairs ( getElementsByType ( "player" ) ) do
while true do
local acc = getPlayerAccount ( v )
if not acc or isGuestAccount ( acc ) then break end
local accName = getAccountName ( acc )
local isAdmin = isObjectInACLGroup ( "user." .. accName , aclGetGroup ( "Admin" ))
if isAdmin == true then
table . insert ( t , v )
end
break
end
end
return t
end
addCommandHandler ( "admins" ,function( p )
local Admins = getOnlineAdmins () -- the function will return 1 table
if #Admins ~= 0 then -- if the admins table not empty then
outputChatBox ( "Online Admins" , p , 255 , 0 , 0 , true )
for k , v in ipairs ( Admins ) do -- loop the table
outputChatBox ( "- " .. getPlayerName ( v ), p , 255 , 0 , 0 , true ) -- output the player name
end
end
end )
Po wpisaniu komendy "admins" (/admins) to na czatcie pisz? czy jest administator jaki? i podaje jego nick
Wikipedia Multi The Auto : San Andreas :
Poradnik stworzony przez luki123luki123 dla forum Gtao.pl. Zakaz umieszczania na innych stronach.
Prosz? administracje o przyklejenie tematu.
Ostatnio zmieniony przez luki123luki123 2014-01-31, 11:01, w całości zmieniany 4 razy