Jump to content

Problems in script


El_Matador

Recommended Posts

Hi all , i have problem in my script (login) after login camera must be in the interior (garage) but is isn't it. And i don't know what i can create function when i login the music volume falls (down...down...down and stop) , please help me in this script :)

function resourceStart(resource) 
    setGameType("Race World")
    setMapName("RR 1.0")
    setRuleValue("Script Version", scriptVersion)
    setRuleValue("Author", "Shape")
end
 
Info= guiCreateLabel(0.61,0.9333,0.6025,0.1267,"Revolution Racing",true)
guiSetFont ( Info, "clear-normal" )
guiSetFont ( Info, "sa-header" )
guiLabelSetColor ( Info, 000, 000, 000 )
guiSetAlpha ( Info, 0.2222 )
 
 
local function onResourceStart()
    showPlayerHudComponent("weapon", false)
    showPlayerHudComponent("ammo", false)
    showPlayerHudComponent("vehicle_name", false)
    showPlayerHudComponent("money", false)
    showPlayerHudComponent("clock", false)
    showPlayerHudComponent("health", false)
    showPlayerHudComponent("armour", false)
    showPlayerHudComponent("breath", false)
    showPlayerHudComponent("area_name", false)
    showPlayerHudComponent("radar", false)
 
end
addEventHandler( "onClientResourceStart", getResourceRootElement( ), onResourceStart )
 
function cameraMoveSoft(camPosX, camPosY, camPosZ, newCamPosX, newCamPosY, newCamPosZ, camLookX, camLookY, camLookZ, newCamLookX, newCamLookY, newCamLookZ, typeCameraMove)
 local x = 0
 local y = 0
 
 function moveCamera()
 x = x + 0.00009
 y = y + 0.1000
 local cameraX, cameraY, cameraZ = interpolateBetween(camPosX, camPosY, camPosZ, newCamPosX, newCamPosY, newCamPosZ, x, "Linear")
 local lookX, lookY, lookZ = interpolateBetween(camLookX, camLookY, camLookZ, newCamLookX, newCamLookY, newCamLookZ, y, "Linear")
setCameraMatrix(cameraX, cameraY, cameraZ, lookX, lookY, lookZ)
 if cameraX == newCamPosX and cameraY == newCamPosY and cameraZ == newCamPosZ and lookX == newCamLookX and lookY == newCamLookY and lookZ == newCamLookZ then
 removeEventHandler("onClientRender", getRootElement(), moveCamera)
 end
 end
 addEventHandler("onClientRender", getRootElement(), moveCamera)
 
 end
 
 
cameraMoveSoft(1810.669,1108,8, 1806,2037, 8, 0, 0, 0, 0, 200000, 0, "Linear")
 
function spawn(player)
    if not isElement(player) then return end
    repeat until spawnPlayer ( player, -1964+math.random(0,0), 136+math.random(5,9), 28, 90, math.random(9,288) )
    fadeCamera(player, true)
    setCameraTarget(player, player)
end
 
addEventHandler("onPlayerJoin", root,
    function()
        spawn(source)
    end
)
 
 
 
local localPlayer = getLocalPlayer()
local playerName = getPlayerName(localPlayer)
 
sound = playSound("logowanie.ogg")
setSoundVolume(sound, 1)    
 
function createPasswordWindow()
    windowChangepw = guiCreateWindow(0.3859,0.349,0.2219,0.1628,"Zmien haslo",true)
    guiSetSize(windowChangepw, 165, 21)
    guiSetAlpha(windowChangepw,0.80000001192093)
    editOldpw = guiCreateEdit(110,29,165,21,"",false,windowChangepw)
    guiSetAlpha(editOldpw,1)
    guiEditSetMasked(editOldpw,true)
    labelOldpw = guiCreateLabel(10,29,90,21,"Stare hasło:",false,windowChangepw)
    guiSetAlpha(labelOldpw,1)
    guiLabelSetColor(labelOldpw,255,255,255)
    guiLabelSetVerticalAlign(labelOldpw,"center")
    guiLabelSetHorizontalAlign(labelOldpw,"left",false)
    editNewpw = guiCreateEdit(110,60,165,21,"",false,windowChangepw)
    guiSetAlpha(editNewpw,1)
    guiEditSetMasked(editNewpw,true)
    guiEditSetMaxLength(editNewpw,50)
    labelNewpw = guiCreateLabel(10,60,90,21,"Nowe hasło:",false,windowChangepw)
    guiSetAlpha(labelNewpw,1)
    guiLabelSetColor(labelNewpw,255,255,255)
    guiLabelSetVerticalAlign(labelNewpw,"center")
    guiLabelSetHorizontalAlign(labelNewpw,"left",false)
    buttonChangepw = guiCreateButton(10,91,265,23,"Zmień Hasło",false,windowChangepw)
    guiSetAlpha(buttonChangepw,1)
   
    guiSetVisible(windowChangepw, false)
   
    addEventHandler("onClientGUIClick", buttonChangepw, clientSubmitChangepw, false)
end
 
function createLoginWindow()
    windowLogin = guiCreateWindow(0.3345,0.3646,0.2109,0.2018,"Zaloguj się",true)
    guiSetSize(windowLogin, 430, 205, false)
    guiSetAlpha(windowLogin,1)
    labelUsername = guiCreateLabel(90,72,59,24,"Login:",false,windowLogin)
    guiSetAlpha(labelUsername,1)
    guiLabelSetColor(labelUsername,255,255,255)
    guiLabelSetVerticalAlign(labelUsername,"center")
    guiLabelSetHorizontalAlign(labelUsername,"left",false)
    labelPassword = guiCreateLabel(90,100,59,24,"Haslo:",false,windowLogin)
    guiSetAlpha(labelPassword,1)
    guiLabelSetColor(labelPassword,255,255,255)
    guiLabelSetVerticalAlign(labelPassword,"center")
    guiLabelSetHorizontalAlign(labelPassword,"left",false)
    --labelInfo = guiCreateLabel(120,26,250,17,"Witamy na Serwerze",false,windowLogin)
    --labelInfo = guiCreateLabel(120,56,260,27,"ll Revolution Racing ll",false,windowLogin)
    --guiSetAlpha(labelInfo,1)
    --guiLabelSetColor(labelInfo,255,255,255)
    --guiLabelSetVerticalAlign(labelInfo,"top")
    --guiLabelSetHorizontalAlign(labelInfo,"center",false)
    --guiSetFont(labelInfo,"default-bold-small")
    editUsername = guiCreateEdit(140,72,181,25,playerName,false,windowLogin)
    guiSetAlpha(editUsername,1)
    guiEditSetMaxLength(editUsername, 50)
    editPassword = guiCreateEdit(140,100,181,25,"",false,windowLogin)
    guiSetAlpha(editPassword,1)
    guiEditSetMasked(editPassword, true)
    guiEditSetMaxLength(editPassword, 50)
    buttonLogin = guiCreateButton(50,140,137,40,"Zaloguj",false,windowLogin)
    guiSetAlpha(buttonLogin,1)
    buttonRegister = guiCreateButton(240,140,137,40,"Zarejestruj",false,windowLogin)
    guiSetAlpha(buttonRegister,1)
   
--[[
GUIEditor_TabPanel = {}
GUIEditor_Tab = {}
GUIEditor_Button = {}
GUIEditor_Label = {}
GUIEditor_Edit = {}
 
 
windowLogin = guiCreateTabPanel(0.2898,0.3854,0.3994,0.2531,true)
GUIEditor_Tab[1] = guiCreateTab("Logowanie/Rejestracja",windowLogin)
GUIEditor_Edit[1] = guiCreateEdit(138,157,5,5,"",false,GUIEditor_Tab[1])
editUsername = guiCreateEdit(46,26,318,33,"",false,GUIEditor_Tab[1])
editPassword = guiCreateEdit(46,83,318,33,"",false,GUIEditor_Tab[1])
buttonLogin = guiCreateButton(237,125,127,25,"Zaloguj",false,GUIEditor_Tab[1])
guiSetProperty(GUIEditor_Button[1],"Text","Zaloguj")
GUIEditor_Label[1] = guiCreateLabel(51,5,307,17,"Login",false,GUIEditor_Tab[1])
GUIEditor_Label[2] = guiCreateLabel(52,65,271,14,"Haslo",false,GUIEditor_Tab[1])
buttonRegister = guiCreateButton(103,125,127,25,"Zarejestruj",false,GUIEditor_Tab[1])
guiSetProperty(GUIEditor_Button[2],"Text","Zarejestruj")
--]]
    guiSetVisible(windowLogin, false)
   
    addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
    addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false)
end
 
function resourceStart()
    createLoginWindow()
    if (windowLogin ~= nil) then
        guiSetVisible(windowLogin, true)
    else
        outputChatBox("Wystapil blad.")
    end
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function changePw()
    createPasswordWindow()
    guiSetVisible(windowChangepw, true)
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function clientSubmitLogin(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
        else
            guiSetText(labelInfo, "Podaj login i haslo.")
        end
    end
end
 
function clientSubmitRegister(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
            triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
        else
            guiSetText(labelInfo, "Podaj login i haslo.")
        end
    end
end
 
function clientSubmitChangepw(button, state)
    if button == "left" and state == "up" then
        local oldpassword = guiGetText(editOldpw)
        local newpassword = guiGetText(editNewpw)
        if oldpassword and newpassword then
            triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword)
        else
            outputChatBox("Podaj stare i nowe haslo.")
        end
    end
end
 
function hideLoginWindow()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    destroyElement (Info)
    showCursor(false)
    fadeCamera ( false, 2.0, 0, 0, 0)
    setTimer (Kamera, 3000, 1 )
end
 
hidePasswordWindow = function()
    guiSetVisible(windowChangepw, false)
end
 
local screenWidth, screenHeight = guiGetScreenSize ( )
 
local messageLoadnig = "Ladowanie"
 
function Kamera()
     setCameraInterior(200)
    fadeCamera(true,5)
dxDrawText("* ".. messageLoadnig,503.0,16.0,573.0,32.0,tocolor(0,0,255,170),0.8,"sans","left","top",false,false,false)
end
 
function unknownError()
    outputChatBox("Nie wypełniłeś wszystkich pól.", player)
end
 
function loginWrong()
    outputChatBox("Wpisałeś niepoprawne dane.", player)
end
 
function registerTaken()
    outputChatBox("Nazwa użytkownika jest już zajęta.", player)
end
 
addEvent("hidePasswordWindow", true)
addEvent("hideLoginWindow", true)
Link to comment

Client side :

function passwordHandler(player, oldpassword, newpassword) 
    local account = getPlayerAccount(player) 
    if (account) then 
        if (isGuestAccount(account)) then 
            outputChatBox("Musisz być zalogowany by zmienić swoje hasło.", player) 
            return 
        end 
        local playerName = getPlayerName(player) 
        local password_check = getAccount(playerName, oldpassword) 
        if (password_check ~= false) then 
            if (string.len(newpassword) >= 5) then 
                setAccountPassword(account, newpassword) 
                triggerClientEvent(player, "hidePasswordWindow", getRootElement()) 
            else 
                outputChatBox("Hasło musi zawierać przynajmniej 5 liter!", player) 
            end 
        else 
            outputChatBox("Bledne stare haslo.", player) 
        end 
    end 
end 
  
function loginHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        if (logIn(player, account, password) == true) then 
            outputChatBox("Jesli chcesz zmienic haslo wpisz /changepw", player) 
            triggerClientEvent (player, "hideLoginWindow", getRootElement()) 
        else 
            triggerClientEvent (player, "unknownError", getRootElement()) 
        end 
    else 
        triggerClientEvent (player, "loginWrong", getRootElement()) 
    end 
end 
  
function registerHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        triggerClientEvent(player, "registerTaken", getRootElement()) 
    else 
        account = addAccount(username, password) 
        if (logIn(player, account, password) == true) then 
            outputChatBox("If you want to change your password, use /changepw", player) 
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
        else 
            triggerClientEvent(player, "unknownError", getRootElement()) 
        end 
    end 
end 
  
addEvent("submitChangepw", true) 
addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
addEventHandler("submitChangepw", root, passwordHandler) 
addEventHandler("submitLogin", root, loginHandler) 
addEventHandler("submitRegister", root, registerHandler) 

Link to comment

All these functions are server side only, that must be the server side. Also move this to the server side part too:

function resourceStart(resource) 
    setGameType("Race World") 
    setMapName("RR 1.0") 
    setRuleValue("Script Version", scriptVersion) 
    setRuleValue("Author", "Shape") 
end 

Link to comment

Ok , moved , this is actually code :

Client :

  
Info= guiCreateLabel(0.61,0.9333,0.6025,0.1267,"Revolution Racing",true)
guiSetFont ( Info, "clear-normal" )
guiSetFont ( Info, "sa-header" )
guiLabelSetColor ( Info, 000, 000, 000 )
guiSetAlpha ( Info, 0.2222 )
 
 
local function onResourceStart()
    showPlayerHudComponent("weapon", false)
    showPlayerHudComponent("ammo", false)
    showPlayerHudComponent("vehicle_name", false)
    showPlayerHudComponent("money", false)
    showPlayerHudComponent("clock", false)
    showPlayerHudComponent("health", false)
    showPlayerHudComponent("armour", false)
    showPlayerHudComponent("breath", false)
    showPlayerHudComponent("area_name", false)
    showPlayerHudComponent("radar", false)
 
end
addEventHandler( "onClientResourceStart", getResourceRootElement( ), onResourceStart )
 
function cameraMoveSoft(camPosX, camPosY, camPosZ, newCamPosX, newCamPosY, newCamPosZ, camLookX, camLookY, camLookZ, newCamLookX, newCamLookY, newCamLookZ, typeCameraMove)
 local x = 0
 local y = 0
 
 function moveCamera()
 x = x + 0.00009
 y = y + 0.1000
 local cameraX, cameraY, cameraZ = interpolateBetween(camPosX, camPosY, camPosZ, newCamPosX, newCamPosY, newCamPosZ, x, "Linear")
 local lookX, lookY, lookZ = interpolateBetween(camLookX, camLookY, camLookZ, newCamLookX, newCamLookY, newCamLookZ, y, "Linear")
setCameraMatrix(cameraX, cameraY, cameraZ, lookX, lookY, lookZ)
 if cameraX == newCamPosX and cameraY == newCamPosY and cameraZ == newCamPosZ and lookX == newCamLookX and lookY == newCamLookY and lookZ == newCamLookZ then
 removeEventHandler("onClientRender", getRootElement(), moveCamera)
 end
 end
 addEventHandler("onClientRender", getRootElement(), moveCamera)
 
 end
 
 
cameraMoveSoft(1810.669,1108,8, 1806,2037, 8, 0, 0, 0, 0, 200000, 0, "Linear")
 
function spawn(player)
    if not isElement(player) then return end
    repeat until spawnPlayer ( player, -1964+math.random(0,0), 136+math.random(5,9), 28, 90, math.random(9,288) )
    fadeCamera(player, true)
    setCameraTarget(player, player)
end
 
addEventHandler("onPlayerJoin", root,
    function()
        spawn(source)
    end
)
 
 
 
local localPlayer = getLocalPlayer()
local playerName = getPlayerName(localPlayer)
 
sound = playSound("logowanie.ogg")
setSoundVolume(sound, 1)    
 
function createPasswordWindow()
    windowChangepw = guiCreateWindow(0.3859,0.349,0.2219,0.1628,"Zmien haslo",true)
    guiSetSize(windowChangepw, 165, 21)
    guiSetAlpha(windowChangepw,0.80000001192093)
    editOldpw = guiCreateEdit(110,29,165,21,"",false,windowChangepw)
    guiSetAlpha(editOldpw,1)
    guiEditSetMasked(editOldpw,true)
    labelOldpw = guiCreateLabel(10,29,90,21,"Stare hasło:",false,windowChangepw)
    guiSetAlpha(labelOldpw,1)
    guiLabelSetColor(labelOldpw,255,255,255)
    guiLabelSetVerticalAlign(labelOldpw,"center")
    guiLabelSetHorizontalAlign(labelOldpw,"left",false)
    editNewpw = guiCreateEdit(110,60,165,21,"",false,windowChangepw)
    guiSetAlpha(editNewpw,1)
    guiEditSetMasked(editNewpw,true)
    guiEditSetMaxLength(editNewpw,50)
    labelNewpw = guiCreateLabel(10,60,90,21,"Nowe hasło:",false,windowChangepw)
    guiSetAlpha(labelNewpw,1)
    guiLabelSetColor(labelNewpw,255,255,255)
    guiLabelSetVerticalAlign(labelNewpw,"center")
    guiLabelSetHorizontalAlign(labelNewpw,"left",false)
    buttonChangepw = guiCreateButton(10,91,265,23,"Zmień Hasło",false,windowChangepw)
    guiSetAlpha(buttonChangepw,1)
   
    guiSetVisible(windowChangepw, false)
   
    addEventHandler("onClientGUIClick", buttonChangepw, clientSubmitChangepw, false)
end
 
function createLoginWindow()
    windowLogin = guiCreateWindow(0.3345,0.3646,0.2109,0.2018,"Zaloguj się",true)
    guiSetSize(windowLogin, 430, 205, false)
    guiSetAlpha(windowLogin,1)
    labelUsername = guiCreateLabel(90,72,59,24,"Login:",false,windowLogin)
    guiSetAlpha(labelUsername,1)
    guiLabelSetColor(labelUsername,255,255,255)
    guiLabelSetVerticalAlign(labelUsername,"center")
    guiLabelSetHorizontalAlign(labelUsername,"left",false)
    labelPassword = guiCreateLabel(90,100,59,24,"Haslo:",false,windowLogin)
    guiSetAlpha(labelPassword,1)
    guiLabelSetColor(labelPassword,255,255,255)
    guiLabelSetVerticalAlign(labelPassword,"center")
    guiLabelSetHorizontalAlign(labelPassword,"left",false)
    --labelInfo = guiCreateLabel(120,26,250,17,"Witamy na Serwerze",false,windowLogin)
    --labelInfo = guiCreateLabel(120,56,260,27,"ll Revolution Racing ll",false,windowLogin)
    --guiSetAlpha(labelInfo,1)
    --guiLabelSetColor(labelInfo,255,255,255)
    --guiLabelSetVerticalAlign(labelInfo,"top")
    --guiLabelSetHorizontalAlign(labelInfo,"center",false)
    --guiSetFont(labelInfo,"default-bold-small")
    editUsername = guiCreateEdit(140,72,181,25,playerName,false,windowLogin)
    guiSetAlpha(editUsername,1)
    guiEditSetMaxLength(editUsername, 50)
    editPassword = guiCreateEdit(140,100,181,25,"",false,windowLogin)
    guiSetAlpha(editPassword,1)
    guiEditSetMasked(editPassword, true)
    guiEditSetMaxLength(editPassword, 50)
    buttonLogin = guiCreateButton(50,140,137,40,"Zaloguj",false,windowLogin)
    guiSetAlpha(buttonLogin,1)
    buttonRegister = guiCreateButton(240,140,137,40,"Zarejestruj",false,windowLogin)
    guiSetAlpha(buttonRegister,1)
   
--[[
GUIEditor_TabPanel = {}
GUIEditor_Tab = {}
GUIEditor_Button = {}
GUIEditor_Label = {}
GUIEditor_Edit = {}
 
 
windowLogin = guiCreateTabPanel(0.2898,0.3854,0.3994,0.2531,true)
GUIEditor_Tab[1] = guiCreateTab("Logowanie/Rejestracja",windowLogin)
GUIEditor_Edit[1] = guiCreateEdit(138,157,5,5,"",false,GUIEditor_Tab[1])
editUsername = guiCreateEdit(46,26,318,33,"",false,GUIEditor_Tab[1])
editPassword = guiCreateEdit(46,83,318,33,"",false,GUIEditor_Tab[1])
buttonLogin = guiCreateButton(237,125,127,25,"Zaloguj",false,GUIEditor_Tab[1])
guiSetProperty(GUIEditor_Button[1],"Text","Zaloguj")
GUIEditor_Label[1] = guiCreateLabel(51,5,307,17,"Login",false,GUIEditor_Tab[1])
GUIEditor_Label[2] = guiCreateLabel(52,65,271,14,"Haslo",false,GUIEditor_Tab[1])
buttonRegister = guiCreateButton(103,125,127,25,"Zarejestruj",false,GUIEditor_Tab[1])
guiSetProperty(GUIEditor_Button[2],"Text","Zarejestruj")
--]]
    guiSetVisible(windowLogin, false)
   
    addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
    addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false)
end
 
function resourceStart()
    createLoginWindow()
    if (windowLogin ~= nil) then
        guiSetVisible(windowLogin, true)
    else
        outputChatBox("Wystapil blad.")
    end
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function changePw()
    createPasswordWindow()
    guiSetVisible(windowChangepw, true)
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function clientSubmitLogin(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
        else
            guiSetText(labelInfo, "Podaj login i haslo.")
        end
    end
end
 
function clientSubmitRegister(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
            triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
        else
            guiSetText(labelInfo, "Podaj login i haslo.")
        end
    end
end
 
function clientSubmitChangepw(button, state)
    if button == "left" and state == "up" then
        local oldpassword = guiGetText(editOldpw)
        local newpassword = guiGetText(editNewpw)
        if oldpassword and newpassword then
            triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword)
        else
            outputChatBox("Podaj stare i nowe haslo.")
        end
    end
end
 
function hideLoginWindow()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    destroyElement (Info)
    showCursor(false)
    fadeCamera ( false, 2.0, 0, 0, 0)
    setTimer (Kamera, 3000, 1 )
end
 
hidePasswordWindow = function()
    guiSetVisible(windowChangepw, false)
end
 
local screenWidth, screenHeight = guiGetScreenSize ( )
 
local messageLoadnig = "Ladowanie"
 
function Kamera()
     setCameraInterior(200)
    fadeCamera(true,5)
dxDrawText("* ".. messageLoadnig,503.0,16.0,573.0,32.0,tocolor(0,0,255,170),0.8,"sans","left","top",false,false,false)
end
 
function unknownError()
    outputChatBox("Nie wypełniłeś wszystkich pól.", player)
end
 
function loginWrong()
    outputChatBox("Wpisałeś niepoprawne dane.", player)
end
 
function registerTaken()
    outputChatBox("Nazwa użytkownika jest już zajęta.", player)
end
 
addEvent("hidePasswordWindow", true)
addEvent("hideLoginWindow", true)
addEvent("unknownError", true)
addEvent("loginWrong", true)
addEvent("registerTaken", true)
addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow)
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
addEventHandler("unknownError", getRootElement(), unknownError)
Link to comment

That's because you didn't add the event handler to set the game type.

function resourceStart() 
    setGameType("Race World") 
    setMapName("RR 1.0") 
    setRuleValue("Author", "Shape") 
end 
addEventHandler ( "onResourceStart", resourceRoot, resourceStart ) 
  
function passwordHandler(player, oldpassword, newpassword) 
    local account = getPlayerAccount(player) 
    if (account) then 
        if (isGuestAccount(account)) then 
            outputChatBox("Musisz być zalogowany by zmienić swoje hasło.", player) 
            return 
        end 
        local playerName = getPlayerName(player) 
        local password_check = getAccount(playerName, oldpassword) 
        if (password_check ~= false) then 
            if (string.len(newpassword) >= 5) then 
                setAccountPassword(account, newpassword) 
                triggerClientEvent(player, "hidePasswordWindow", getRootElement()) 
            else 
                outputChatBox("Hasło musi zawierać przynajmniej 5 liter!", player) 
            end 
        else 
            outputChatBox("Bledne stare haslo.", player) 
        end 
    end 
end 
  
function loginHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        if (logIn(player, account, password) == true) then 
            outputChatBox("Jesli chcesz zmienic haslo wpisz /changepw", player) 
            triggerClientEvent (player, "hideLoginWindow", getRootElement()) 
        else 
            triggerClientEvent (player, "unknownError", getRootElement()) 
        end 
    else 
        triggerClientEvent (player, "loginWrong", getRootElement()) 
    end 
end 
  
function registerHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        triggerClientEvent(player, "registerTaken", getRootElement()) 
    else 
        account = addAccount(username, password) 
        if (logIn(player, account, password) == true) then 
            outputChatBox("If you want to change your password, use /changepw", player) 
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
        else 
            triggerClientEvent(player, "unknownError", getRootElement()) 
        end 
    end 
end 
  
addEvent("submitChangepw", true) 
addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
addEventHandler("submitChangepw", root, passwordHandler) 
addEventHandler("submitLogin", root, loginHandler) 
addEventHandler("submitRegister", root, registerHandler) 

Link to comment

Oh , my fault thanks , second problem is big for me , the interior after login is no set and camera is moving further, can you fix this for me? Is in the client side :

  
Info= guiCreateLabel(0.61,0.9333,0.6025,0.1267,"Revolution Racing",true)
guiSetFont ( Info, "clear-normal" )
guiSetFont ( Info, "sa-header" )
guiLabelSetColor ( Info, 000, 000, 000 )
guiSetAlpha ( Info, 0.2222 )
 
 
local function onResourceStart()
    showPlayerHudComponent("weapon", false)
    showPlayerHudComponent("ammo", false)
    showPlayerHudComponent("vehicle_name", false)
    showPlayerHudComponent("money", false)
    showPlayerHudComponent("clock", false)
    showPlayerHudComponent("health", false)
    showPlayerHudComponent("armour", false)
    showPlayerHudComponent("breath", false)
    showPlayerHudComponent("area_name", false)
    showPlayerHudComponent("radar", false)
 
end
addEventHandler( "onClientResourceStart", getResourceRootElement( ), onResourceStart )
 
function cameraMoveSoft(camPosX, camPosY, camPosZ, newCamPosX, newCamPosY, newCamPosZ, camLookX, camLookY, camLookZ, newCamLookX, newCamLookY, newCamLookZ, typeCameraMove)
 local x = 0
 local y = 0
 
 function moveCamera()
 x = x + 0.00009
 y = y + 0.1000
 local cameraX, cameraY, cameraZ = interpolateBetween(camPosX, camPosY, camPosZ, newCamPosX, newCamPosY, newCamPosZ, x, "Linear")
 local lookX, lookY, lookZ = interpolateBetween(camLookX, camLookY, camLookZ, newCamLookX, newCamLookY, newCamLookZ, y, "Linear")
setCameraMatrix(cameraX, cameraY, cameraZ, lookX, lookY, lookZ)
 if cameraX == newCamPosX and cameraY == newCamPosY and cameraZ == newCamPosZ and lookX == newCamLookX and lookY == newCamLookY and lookZ == newCamLookZ then
 removeEventHandler("onClientRender", getRootElement(), moveCamera)
 end
 end
 addEventHandler("onClientRender", getRootElement(), moveCamera)
 
 end
 
 
cameraMoveSoft(1810.669,1108,8, 1806,2037, 8, 0, 0, 0, 0, 200000, 0, "Linear")
 
function spawn(player)
    if not isElement(player) then return end
    repeat until spawnPlayer ( player, -1964+math.random(0,0), 136+math.random(5,9), 28, 90, math.random(9,288) )
    fadeCamera(player, true)
    setCameraTarget(player, player)
end
 
addEventHandler("onPlayerJoin", root,
    function()
        spawn(source)
    end
)
 
 
 
local localPlayer = getLocalPlayer()
local playerName = getPlayerName(localPlayer)
 
sound = playSound("logowanie.ogg")
setSoundVolume(sound, 1)    
 
function createPasswordWindow()
    windowChangepw = guiCreateWindow(0.3859,0.349,0.2219,0.1628,"Zmien haslo",true)
    guiSetSize(windowChangepw, 165, 21)
    guiSetAlpha(windowChangepw,0.80000001192093)
    editOldpw = guiCreateEdit(110,29,165,21,"",false,windowChangepw)
    guiSetAlpha(editOldpw,1)
    guiEditSetMasked(editOldpw,true)
    labelOldpw = guiCreateLabel(10,29,90,21,"Stare hasło:",false,windowChangepw)
    guiSetAlpha(labelOldpw,1)
    guiLabelSetColor(labelOldpw,255,255,255)
    guiLabelSetVerticalAlign(labelOldpw,"center")
    guiLabelSetHorizontalAlign(labelOldpw,"left",false)
    editNewpw = guiCreateEdit(110,60,165,21,"",false,windowChangepw)
    guiSetAlpha(editNewpw,1)
    guiEditSetMasked(editNewpw,true)
    guiEditSetMaxLength(editNewpw,50)
    labelNewpw = guiCreateLabel(10,60,90,21,"Nowe hasło:",false,windowChangepw)
    guiSetAlpha(labelNewpw,1)
    guiLabelSetColor(labelNewpw,255,255,255)
    guiLabelSetVerticalAlign(labelNewpw,"center")
    guiLabelSetHorizontalAlign(labelNewpw,"left",false)
    buttonChangepw = guiCreateButton(10,91,265,23,"Zmień Hasło",false,windowChangepw)
    guiSetAlpha(buttonChangepw,1)
   
    guiSetVisible(windowChangepw, false)
   
    addEventHandler("onClientGUIClick", buttonChangepw, clientSubmitChangepw, false)
end
 
function createLoginWindow()
    windowLogin = guiCreateWindow(0.3345,0.3646,0.2109,0.2018,"Zaloguj się",true)
    guiSetSize(windowLogin, 430, 205, false)
    guiSetAlpha(windowLogin,1)
    labelUsername = guiCreateLabel(90,72,59,24,"Login:",false,windowLogin)
    guiSetAlpha(labelUsername,1)
    guiLabelSetColor(labelUsername,255,255,255)
    guiLabelSetVerticalAlign(labelUsername,"center")
    guiLabelSetHorizontalAlign(labelUsername,"left",false)
    labelPassword = guiCreateLabel(90,100,59,24,"Haslo:",false,windowLogin)
    guiSetAlpha(labelPassword,1)
    guiLabelSetColor(labelPassword,255,255,255)
    guiLabelSetVerticalAlign(labelPassword,"center")
    guiLabelSetHorizontalAlign(labelPassword,"left",false)
    --labelInfo = guiCreateLabel(120,26,250,17,"Witamy na Serwerze",false,windowLogin)
    --labelInfo = guiCreateLabel(120,56,260,27,"ll Revolution Racing ll",false,windowLogin)
    --guiSetAlpha(labelInfo,1)
    --guiLabelSetColor(labelInfo,255,255,255)
    --guiLabelSetVerticalAlign(labelInfo,"top")
    --guiLabelSetHorizontalAlign(labelInfo,"center",false)
    --guiSetFont(labelInfo,"default-bold-small")
    editUsername = guiCreateEdit(140,72,181,25,playerName,false,windowLogin)
    guiSetAlpha(editUsername,1)
    guiEditSetMaxLength(editUsername, 50)
    editPassword = guiCreateEdit(140,100,181,25,"",false,windowLogin)
    guiSetAlpha(editPassword,1)
    guiEditSetMasked(editPassword, true)
    guiEditSetMaxLength(editPassword, 50)
    buttonLogin = guiCreateButton(50,140,137,40,"Zaloguj",false,windowLogin)
    guiSetAlpha(buttonLogin,1)
    buttonRegister = guiCreateButton(240,140,137,40,"Zarejestruj",false,windowLogin)
    guiSetAlpha(buttonRegister,1)
   
--[[
GUIEditor_TabPanel = {}
GUIEditor_Tab = {}
GUIEditor_Button = {}
GUIEditor_Label = {}
GUIEditor_Edit = {}
 
 
windowLogin = guiCreateTabPanel(0.2898,0.3854,0.3994,0.2531,true)
GUIEditor_Tab[1] = guiCreateTab("Logowanie/Rejestracja",windowLogin)
GUIEditor_Edit[1] = guiCreateEdit(138,157,5,5,"",false,GUIEditor_Tab[1])
editUsername = guiCreateEdit(46,26,318,33,"",false,GUIEditor_Tab[1])
editPassword = guiCreateEdit(46,83,318,33,"",false,GUIEditor_Tab[1])
buttonLogin = guiCreateButton(237,125,127,25,"Zaloguj",false,GUIEditor_Tab[1])
guiSetProperty(GUIEditor_Button[1],"Text","Zaloguj")
GUIEditor_Label[1] = guiCreateLabel(51,5,307,17,"Login",false,GUIEditor_Tab[1])
GUIEditor_Label[2] = guiCreateLabel(52,65,271,14,"Haslo",false,GUIEditor_Tab[1])
buttonRegister = guiCreateButton(103,125,127,25,"Zarejestruj",false,GUIEditor_Tab[1])
guiSetProperty(GUIEditor_Button[2],"Text","Zarejestruj")
--]]
    guiSetVisible(windowLogin, false)
   
    addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
    addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false)
end
 
function resourceStart()
    createLoginWindow()
    if (windowLogin ~= nil) then
        guiSetVisible(windowLogin, true)
    else
        outputChatBox("Wystapil blad.")
    end
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function changePw()
    createPasswordWindow()
    guiSetVisible(windowChangepw, true)
    showCursor(true)
    guiSetInputEnabled(true)
end
 
function clientSubmitLogin(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
        else
            guiSetText(labelInfo, "Podaj login i haslo.")
        end
    end
end
 
function clientSubmitRegister(button, state)
    if button == "left" and state == "up" then
        local username = guiGetText(editUsername)
        local password = guiGetText(editPassword)
        if username and password then
            triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
        else
            guiSetText(labelInfo, "Podaj login i haslo.")
        end
    end
end
 
function clientSubmitChangepw(button, state)
    if button == "left" and state == "up" then
        local oldpassword = guiGetText(editOldpw)
        local newpassword = guiGetText(editNewpw)
        if oldpassword and newpassword then
            triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword)
        else
            outputChatBox("Podaj stare i nowe haslo.")
        end
    end
end
 
function hideLoginWindow()
    guiSetInputEnabled(false)
    guiSetVisible(windowLogin, false)
    destroyElement (Info)
    showCursor(false)
    fadeCamera ( false, 2.0, 0, 0, 0)
    setTimer (Kamera, 3000, 1 )
end
 
hidePasswordWindow = function()
    guiSetVisible(windowChangepw, false)
end
 
local screenWidth, screenHeight = guiGetScreenSize ( )
 
local messageLoadnig = "Ladowanie"
 
function Kamera()
     setCameraInterior(200)
    fadeCamera(true,5)
dxDrawText("* ".. messageLoadnig,503.0,16.0,573.0,32.0,tocolor(0,0,255,170),0.8,"sans","left","top",false,false,false)
end
 
function unknownError()
    outputChatBox("Nie wypełniłeś wszystkich pól.", player)
end
 
function loginWrong()
    outputChatBox("Wpisałeś niepoprawne dane.", player)
end
 
function registerTaken()
    outputChatBox("Nazwa użytkownika jest już zajęta.", player)
end
 
addEvent("hidePasswordWindow", true)
addEvent("hideLoginWindow", true)
addEvent("unknownError", true)
addEvent("loginWrong", true)
addEvent("registerTaken", true)
addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow)
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
addEventHandler("unknownError", getRootElement(), unknownError)
Link to comment
function spawn(player) 
    if not isElement(player) then return end 
    repeat until spawnPlayer ( player, -1964+math.random(0,0), 136+math.random(5,9), 28, 90, math.random(9,288) ) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
end 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        spawn(source) 
    end 
) 

That is server side as well.

Link to comment

Ok , but the camera after login moving further, what interior garage i must write? Any interior is no work. Can you edit the code and add the camera turns off?

I write this :

function Kamera()

setCameraInterior(1)

fadeCamera(true,5)

dxDrawText("* ".. messageLoadnig,503.0,16.0,573.0,32.0,tocolor(0,0,255,170),0.8,"sans","left","top",false,false,false)

end

and i see this :

1.jpg

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