zuraw13
Wiek: 27 Na forum: 5074 dni Posty: 95
Nick w MP: zuraw113
Piwa : 191
Nie dzia?a opcja rejestracji w panelu logowania.
Klikam rejestruj i wyskakuje w konsoli serwera:
Cytat: [2014-03-24 19] WARNING: [gameplay]\xyz\login\login_s.lua:20: Access denied @ 'addAccount'
[2014-03-24 19] WARNING: [gameplay]\xyz\login\login_s.lua:21: Bad argument @ 'logIn' [Expected account at argument 2, got nil]
Miejsce b??du jest po stronie serwera:
account = addAccount ( username , password )
if ( logIn ( player , account , password ) == true ) then
Kod, strona klienta:
sWidth , sHeight = guiGetScreenSize ()
anims = { "dnce_M_b" , "DAN_Left_A" , "DAN_Down_A" , "DAN_Loop_A" }
StartSkin = 0
NewSkin = false
local localPlayer = getLocalPlayer ()
local x = 1024
local y = 768
local sm = {}
sm . moov = 0
sm . object1 , sm . object2 = nil , nil
local months = {
[ 0 ] = "stycznia" ,
[ 1 ] = "lutego" ,
[ 2 ] = "marca" ,
[ 3 ] = "kwietnia" ,
[ 4 ] = "maja" ,
[ 5 ] = "czerwca" ,
[ 6 ] = "lipca" ,
[ 7 ] = "sierpnia" ,
[ 8 ] = "wrze?nia" ,
[ 9 ] = "pa?dziernika" ,
[ 10 ] = "listopada" ,
[ 11 ] = "grudnia"
}
local function camRender ()
if isElement ( sm . object1 ) and ( sm . object2 ) then
local x1 , y1 , z1 = getElementPosition ( sm . object1 )
local x2 , y2 , z2 = getElementPosition ( sm . object2 )
setCameraMatrix ( x1 , y1 , z1 , x2 , y2 , z2 )
end
end
local function removeCamHandler ()
if( sm . moov == 1 ) then
sm . moov = 0
removeEventHandler ( "onClientPreRender" , getRootElement (), camRender )
end
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
return true
end
login_edit = guiCreateEdit (( 465 / x )* sWidth , ( 550 / y )* sHeight , ( 271 / x )* sWidth , ( 44 / y )* sHeight , "" .. getPlayerName ( getLocalPlayer ()), false )
guiEditSetMaxLength ( login_edit , 50 )
haslo_edit = guiCreateEdit (( 465 / x )* sWidth , ( 600 / y )* sHeight , ( 271 / x )* sWidth , ( 44 / y )* sHeight , "" , false )
guiEditSetMasked ( haslo_edit , true )
guiEditSetMaxLength ( haslo_edit , 50 )
login_btn = guiCreateButton (( 250 / x )* sWidth , ( 680 / y )* sHeight , ( 200 / x )* sWidth , ( 50 / y )* sHeight , "Zaloguj si?" , false )
guiSetProperty ( login_btn , "NormalTextColour" , "FFAAAAAA" )
register_btn = guiCreateButton (( 550 / x )* sWidth , ( 680 / y )* sHeight , ( 200 / x )* sWidth , ( 50 / y )* sHeight , "Zarejestruj si?" , false )
guiSetProperty ( register_btn , "NormalTextColour" , "FFAAAAAA" )
function renderujemy ()
dxDrawRectangle (( 0 / x )* sWidth , ( 320 / y )* sHeight , ( 1024 / x )* sWidth , ( 430 / y )* sHeight , tocolor ( 0 , 0 , 0 , 200 ), false )
dxDrawImage (( 250 / x )* sWidth , ( 310 / y )* sHeight , ( 450 / x )* sWidth , ( 300 / y )* sHeight , ":xyz/logo.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), true )
dxDrawLine (( 0 / x )* sWidth , ( 320 / y )* sHeight , ( 1024 / x )* sWidth , ( 320 / y )* sHeight , tocolor ( 255 , 0 , 0 , 255 ), 2 , true )
dxDrawLine (( 0 / x )* sWidth , ( 750 / y )* sHeight , ( 1024 / x )* sWidth , ( 750 / y )* sHeight , tocolor ( 255 , 0 , 0 , 255 ), 2 , true )
dxDrawText ( "Nick:" , ( 303 / x )* sWidth , ( 540 / y )* sHeight , ( 502 / x )* sWidth , ( 609 / y )* sHeight , tocolor ( 255 , 0 , 0 , 255 ), 1.6 , "bankgothic" , "left" , "top" , false , false , true , false , false )
dxDrawText ( "Has?o:" , ( 243 / x )* sWidth , ( 590 / y )* sHeight , ( 442 / x )* sWidth , ( 659 / y )* sHeight , tocolor ( 255 , 0 , 0 , 255 ), 1.6 , "bankgothic" , "left" , "top" , false , false , true , false , false )
end
addEventHandler ( "onClientRender" , root , renderujemy )
function init ()
triggerServerEvent ( "destroyPP" , root , getLocalPlayer ())
smoothMoveCamera (- 1592 , 756 , 80 , - 1592 , 756 , 80 , 2140 , 1348 , 70 , 2140 , 1348 , 70 , 150000 )
-- muzyka = playSound ( ":xyz.mp3" )
setSoundVolume ( muzyka , 0.70 )
showCursor ( true )
showPlayerHudComponent ( "all" , false )
showChat ( false )
guiSetInputEnabled ( true )
removeEventHandler ( "onClientRender" , getRootElement (), td )
end
addEventHandler ( "onClientResourceStart" , getResourceRootElement ( getThisResource ()), init )
function tdInit ()
addEventHandler ( "onClientRender" , getRootElement (), td )
end
addEvent ( "renderTD" , true )
addEventHandler ( "renderTD" , getRootElement (), tdInit )
function login ( button , state )
if button == "left" and state == "up" then
local username = guiGetText ( login_edit )
local password = guiGetText ( haslo_edit )
if string . len ( username ) < 5 or string . len ( password ) < 5 then
showBox ( "error" , "D?ugo?? nicku lub has?a jest zbyt kr?tka." )
return
end
if username and password then
triggerServerEvent ( "probaLogowania" , getRootElement (), localPlayer , username , password )
else
showBox ( "info" , "Wpisz sw?j login i has?o." )
end
end
end
function register ( button , state )
if button == "left" and state == "up" then
local username = guiGetText ( login_edit )
local password = guiGetText ( haslo_edit )
if string . len ( username ) < 5 or string . len ( password ) < 5 then
showBox ( "error" , "D?ugo?? nicku lub has?a jest zbyt kr?tka." )
return
end
if username and password then
triggerServerEvent ( "probaRejestracji" , getRootElement (), localPlayer , username , password )
else
showBox ( "info" , "Wpisz sw?j login i has?o." )
end
end
end
function wybieralkaInfo ()
dxDrawText ( "#ffffffWybierz sw?j model postaci. Aby przewija? modele - u?yj #FF9900strza?ek, #ffffffaby zatwierdzi? naci?nij klawisz #FF9900ENTER." , ( 0 / 1680 )* sWidth , ( 856 / 1024 )* sHeight , ( 1679 / 1680 )* sWidth , ( 905 / 1024 )* sHeight , tocolor ( 255 , 255 , 255 , 255 ), 1.5 , "default-bold" , "left" , "top" , false , false , true , true , false )
dxDrawText ( "Wybierz sw?j model postaci. Aby przewija? modele - u?yj strza?ek, aby zatwierdzi? naci?nij klawisz ENTER." , ( 2 / 1680 )* sWidth , ( 856 / 1024 )* sHeight , ( 1681 / 1680 )* sWidth , ( 905 / 1024 )* sHeight , tocolor ( 0 , 0 , 0 , 255 ), 1.5 , "default-bold" , "left" , "top" , false , false , false , false , false )
end
function wylaczPanelLogowania ()
fadeCamera ( false , 0 , 0 , 0 , 0 )
setTimer ( fadeCamera , 2000 , 1 , true , 1.0 )
removeEventHandler ( "onClientRender" , getRootElement (), renderujemy )
guiSetInputEnabled ( false )
destroyElement ( login_btn )
destroyElement ( register_btn )
destroyElement ( login_edit )
destroyElement ( haslo_edit )
destroyElement ( sm . object1 )
destroyElement ( sm . object2 )
removeCamHandler ()
setCameraMatrix (- 2662 , 1587 , 226 , - 2662 , 1594 , 225 )
skin = createPed ( StartSkin , - 2662 , 1594 , 225 , 180 )
setPedAnimation ( skin , "DANCING" , anims [ math . random ( 1 , 4 )])
setElementFrozen ( skin , true )
addEventHandler ( "onClientRender" , root , wybieralkaInfo )
bindKey ( "arrow_r" , "down" , NextSkin )
bindKey ( "arrow_l" , "down" , LastSkin )
bindKey ( "enter" , "down" , zalogowany )
end
function NextSkin ()
if StartSkin == 312 then
StartSkin = - 1
elseif StartSkin == 2 then
StartSkin = 8
end
StartSkin = StartSkin + 1
local x , y , z = getElementPosition ( skin )
setElementModel ( skin , StartSkin )
setPedAnimation ( skin , "DANCING" , anims [ math . random ( 1 , 4 )])
fxAddGlass ( x , y , z + 0.5 , math . random ( 0 , 255 ), math . random ( 0 , 255 ), math . random ( 0 , 255 ), 255 , 0.15 , 5 )
setElementPosition ( skin , - 2662 , 1594 , 225 )
end
function LastSkin ()
if StartSkin == 0 then
StartSkin = 313
elseif StartSkin == 9 then
StartSkin = 3
end
StartSkin = StartSkin - 1
local x , y , z = getElementPosition ( skin )
setElementModel ( skin , StartSkin )
setPedAnimation ( skin , "DANCING" , anims [ math . random ( 1 , 4 )] )
fxAddGlass ( x , y , z + 0.5 , math . random ( 0 , 255 ), math . random ( 0 , 255 ), math . random ( 0 , 255 ), 255 , 0.15 , 5 )
setElementPosition ( skin , - 2662 , 1594 , 225 )
end
function fadeOutAudio ()
if not muzyka then return end
local vol = getSoundVolume ( muzyka )
vol = vol - 0.1
if ( vol < 0 ) then
stopSound ( muzyka )
muzyka = nil
return
end
setSoundVolume ( muzyka , vol )
setTimer ( fadeOutAudio , 300 , 1 )
end
function zalogowany ()
showChat ( true )
unbindKey ( "arrow_r" , "down" , NextSkin )
unbindKey ( "arrow_l" , "down" , LastSkin )
unbindKey ( "enter" , "down" , zalogowany )
setElementData ( localPlayer , "skin" , StartSkin )
setCameraTarget ( getLocalPlayer ())
showPlayerHudComponent ( "all" , true )
showPlayerHudComponent ( "area_name" , false )
showPlayerHudComponent ( "vehicle_name" , false )
showPlayerHudComponent ( "wanted" , false )
showCursor ( false )
setTimer ( fadeOutAudio , 1000 , 1 )
removeEventHandler ( "onClientRender" , root , wybieralkaInfo )
addEventHandler ( "onClientRender" , root , td )
callServerFunction ( "spawn" , localPlayer )
local teraz = getRealTime ()
local lastonline = getRealTime ( getElementData ( localPlayer , "ostanioOnline" )) or "To jest twoja pierwsza wizyta"
outputChatBox ( "Witaj, " .. getPlayerName ( localPlayer ), 0 , 102 , 255 )
outputChatBox ( "Twoja ranga : " .. getElementData ( localPlayer , "Ranga" ) or "Gracz" , 0 , 102 , 255 )
outputChatBox ( "Ostatnio online: " .. lastonline . monthday .. " " .. months [ lastonline . month ].. " " .. 1900 + lastonline . year .. " o " ..( "%02d" ): format ( lastonline . hour ).. ":" ..( "%02d" ): format ( lastonline . minute ), 0 , 102 , 255 )
outputChatBox ( "Mi?ej gry, ?yczy administracja." , 0 , 102 , 255 )
setElementData ( localPlayer , "ostatnioOnline" , tonumber ( teraz . timestamp ))
end
addEvent ( "HideGUI" , true )
addEventHandler ( "HideGUI" , root , wylaczPanelLogowania )
addEventHandler ( "onClientGUIClick" , login_btn , login , false )
addEventHandler ( "onClientGUIClick" , register_btn , register , false )
Kod, strona serwera:
function logowanie ( player , username , password )
local account = getAccount ( username , password )
if ( account ~= false ) then
if ( logIn ( player , account , password ) == true ) then
setCameraTarget ( player , player )
triggerClientEvent ( player , "HideGUI" , getRootElement ())
else
triggerClientEvent ( player , "CreateBox" , getRootElement (), "error" , "Uzupe?nij pole 'login' i 'has?o'." )
end
end
end
addEvent ( "probaLogowania" , true )
addEventHandler ( "probaLogowania" , getRootElement (), logowanie )
function rejestracja ( player , username , password )
local account = getAccount ( username , password )
if ( account ~= false ) then
else
account = addAccount ( username , password )
if ( logIn ( player , account , password ) == true ) then
setCameraTarget ( player , player )
spawn ( player )
triggerClientEvent ( player , "CreateBox" , getRootElement (), "info" , "Zarejestrowa?e? si? pomy?lnie! Witamy na serwerze xyz." )
triggerClientEvent ( player , "HideGUI" , getRootElement ())
end
end
end
addEvent ( "probaRejestracji" , true )
addEventHandler ( "probaRejestracji" , getRootElement (), rejestracja )
function resourceStop ()
setElementData ( source , "admin" , nil )
setElementData ( source , "vip" , nil )
setElementData ( source , "Exp" , nil )
setElementData ( source , "money" , nil )
setElementData ( source , "datetime" , nil )
setElementData ( source , "loggedin" , nil )
end
addEventHandler ( "onResourceStop" , getRootElement (), resourceStop )
addEventHandler ( "onPlayerQuit" , getRootElement (), resourceStop )
addEventHandler ( "onPlayerJoin" , root ,
function( gracz )
if isElement ( gracz ) and getElementType ( gracz ) == "player" then
fadeCamera ( gracz , true )
showPlayerHudComponent ( gracz , "all" , true )
setElementData ( gracz , "Exp" , 0 )
setElementData ( gracz , "Level" , 0 )
setElementData ( gracz , "Ranga" , "Gracz" )
serverDisplayo = textCreateDisplay ()
textDisplayAddObserver ( serverDisplay , gracz )
serverTexto = textCreateTextItem ( "Witaj na serwerze xyz!\nAktualnie trwa pobieranie zasob?w serwera.\nJeste? ciekaw co dla ciebie oferujemy? Chcesz pozna? atrakcje serwera?\nZosta? z nami i poczekaj :)." , 0.75 , 0.5 , "high" , 0 , 153 , 255 , 255 , 255 , 1.5 , "right" , "bottom" , 200 )
textDisplayAddText ( serverDisplay , serverText )
spawn ( gracz )
end
end )
function destroyTextdispJoin ( gracz )
if isElement ( gracz ) and getElementType ( gracz ) == "player" then
if serverDisplayo then
textDisplayRemoveObserver ( serverDisplayo , gracz )
end
end
end
addEvent ( "destroyPP" , true )
addEventHandler ( "destroyPP" , root , destroyTextdispJoin )
function logoutAll ()
local players = getElementsByType ( "player" )
for k , player in ipairs ( players ) do
account = getPlayerAccount ( player )
if ( not isGuestAccount ( account ) ) then
logOut ( player )
end
end
end
addEventHandler ( "onResourceStart" , getResourceRootElement ( getThisResource ()), logoutAll )
Przywo?uje: http://gtao.pl/teleport-w-gui-vt83378,15.htm