Jump to content

DarkM

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by DarkM

  1. That's not Valhalla's RP server... RPG servers are the ones you choose your faction which is bad RP. Valhalla's RP server is a strict RP server where you gotta actually work your way into a faction.
  2. Have you seen ValhallaGaming's RP server? That right there proves you can create an awesome RP server. I play there all the time. I'm currently trying to learn to script so I can create an RP server myself.
  3. I don't know what I did but the teleport window shows up at the start and the cursor doesn't go away after teleporting the second time it pops up. Please fix and clean up my script. I haven't a clue what I did and cant seem to fix it. script.lua(server): function joinHandler() local x = 1743 local y = -1863 local z = 14 -- spawnPlayer(source, x, y, z) -- fadeCamera(source, true) outputChatBox("--------------------", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) local time = getRealTime() setMinuteDuration(60000) setTime(time.hour, time.minute) -- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel function createVehicleForPlayer(thePlayer, command, vehicleModel) -- create a vehicle and stuff local x,y,z = getElementPosition(thePlayer) x = x + 5 -- ensures vehicle wont spawn in player -- create the vehicle and store the returned vehicle element in the ''createdVehicle'' variable local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if (createdVehicle == false) then -- FIX: createVehicle > createdVehicle outputChatBox("Failed to create vehicle.",thePlayer) end end -- create a command handler addCommandHandler("createvehicle", createVehicleForPlayer) -- create our loginHandler function, with username and password parameters (passed from the client gui) function loginHandler(username,password) -- check that the username and password are correct if username == "user" and password == "apple" then -- the player has successfully logged in, so spawn them if (source) then setCameraTarget(source, source) fadeCamera(source, false) outputChatBox("Thank you for logging in.", source) end else -- if the username or password are not correct, output message to player outputChatBox("Invalid username and/or password. Please try again.",source) end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) function kickInactivePlayer() kickPlayer(client,"Please accept our rules.") end function moveThePlayer(x,y,z,rotation) if x and y and z and rotation then local skin = getElementModel(client) spawnPlayer(client,x,y,z,rotation,skin) setCameraTarget(client,client) end end addEvent("movePlayerToPosition",true) addEventHandler("movePlayerToPosition",root,moveThePlayer) addEvent("clientKickInactivePlayer",true) addEventHandler("clientKickInactivePlayer",root,kickInactivePlayer) gui.lua(client): local rulesWarningTimer = nil function createLoginWindow() -- define the X and Y positions of the window local X = 0.375 local Y = 0.375 -- define the width and height of the window local Width = 0.25 local Height = 0.25 -- create the window and save its element value into the variable 'wdwLogin' -- click on the function's name to read its documentation wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) -- define new X and Y positions for the first label X = 0.0825 Y = 0.2 -- define new Width and Height values for the first label Width = 0.25 Height = 0.25 -- create the first label, note the final argument passed is 'wdwLogin' meaning the window -- we created above is the parent of this label (so all the position and size values are now relative to the position of that window) guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) -- alter the Y value, so the second lebel is slightly below the first Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) -- Max chars to 50 guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) -- make the window invisible guiSetVisible(wdwLogin, false) -- stop players from being able to simply move the window out of the way guiWindowSetMovable(rulesWindow,false) -- stop players from being able to resize the window guiWindowSetSizable(rulesWindow,false) -- now add our onClientGUIClick event to the button we just created addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end -- attach the event handler to the root element of the resource -- this means it will only trigger when ts own resource is started addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () -- create the log in window and its components createLoginWindow() -- output a bried welcome message tot he player outputChatBox("Welcome to DarkM's RP, please log in.") -- if the GUI was successfully created, the show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasn't been properly created, tell the player outputChatBox("An unexpected error has occured and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on components) showCursor(true) -- set the input focus onto the GUI, allowing players (For example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) -- create the function and define the 'button' and 'state' parameters -- (these are passed automatically by onClientGUIClick) function clientSubmitLogin(button,state) if button == "left" and state == "up" then -- get the text entered in the 'unsername' field local username = guiGetText(edtUser) -- get the text entered in the 'password' field local password = guiGetText(edtPass) -- if the username and password both exist if username and password then -- trigger the server event 'submitLogin' and pass the username and password to it triggerServerEvent("submitLogin", getLocalPlayer(), username, password) else -- otherwise, output a message to the player, do not trigger the server -- and do not hide thr gui outputChatBox("Please enter a username and password.") end if username == "user" and password == "apple" then guiGetEnabled(false) guiSetVisible(wdwLogin, false) guiSetVisible(rulesWindow,true) end end end -- create the function that will hold our gui creation code function createRulesWindow() -- get the screen width and height local sWidth, sHeight = guiGetScreenSize() -- create the window, using some maths to find the centre of the screen local Width, Height = 445,445 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) -- create the window rulesWindow = guiCreateWindow(X,Y,Width,Height,"Rules",false) -- stop players from being able to simply move the window out of the way guiWindowSetMovable(rulesWindow,false) -- stop players from being able to resize the window guiWindowSetSizable(rulesWindow,false) guiSetVisible(rulesWindow,false) -- create the button and save the button gui element in a variable called 'rulesButton' rulesButton = guiCreateButton(137,394,158,37,"Accept",false,rulesWindow) -- create the label and save the label gui element in a variable calle 'rulesLabel' -- we set the text odf the label to our rules rulesLabel = guiCreateLabel(10,25,425,359,[[ Welcome to DarkM's RP Please carefully read the rules before accepting. By accepting the rules, you are agreeing to play by them. Anyone caught breaking these rules will be kicked and/or banned from this server. If you do not accept the rules within 90 seconds, you will be kicked. 1: No cheating. 2: No bug abuse. 3: No vehicle handling mods or other beneficial mods. 4: RP at all times. This is a strict RP server, any non-RP is punishable.]],false,rulesWindow) -- set the horizontal alignment of the label to center (ie: in the middle of the window) -- also note the final argument "true" -- this turns on wordwrap so if your text goes over the edge of the label, it will wrap around and start a new line automatically guiLabelSetHorizontalAlign(rulesLabel,"center",true) rulesWarningTimer = setTimer(inactivePlayer,30000,1,1) addEventHandler("onClientGUIClick", rulesButton, acceptRules, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () -- call the createRulesWindow function to create our gui createRulesWindow() -- show the cursor to the player showCursor(true,true) end ) function acceptRules(button,state) if button == "left" and state == "up" then guiSetVisible(rulesWindow, false) guiSetVisible(teleportWindow, true) showCursor(false,false) outputChatBox("Thank you for accepting the rules. Have fun RPing!") if rulesWarningTimer then killTimer(rulesWarningTimer) rulesWarningTimer = nil end end end function inactivePlayer(status) if status == 1 then outputChatBox("Please accept rules or else you will be kicked.") rulesWarningTimer = setTimer(inactivePlayer,30000,1,2) elseif status == 2 then triggerServerEvent("clientKickInactivePlayer",getLocalPlayer()) end end function createTeleportWindow() local sWidth, sHeight = guiGetScreenSize() local Width,Height = 231,188 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) teleportWindow = guiCreateWindow(X,Y,Width,Height,"Starting Area",false) guiWindowSetSizable(teleportWindow,false) teleportLabel = guiCreateLabel(18,23,191,33,"Bus or Plane?",false,teleportWindow) guiLabelSetHorizontalAlign(teleportLabel,"center",true) teleportButtonBus = guiCreateButton(18,63,195,35,"Bus",false,teleportWindow) teleportButtonPlane = guiCreateButton(18,143,195,35,"Plane",false,teleportWindow) addEventHandler("onClientGUIClick",teleportButtonBus,teleportPlayer,false) addEventHandler("onClientGUIClick",teleportButtonPlane,teleportPlayer,false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createTeleportWindow() end ) function teleportPlayer(button,state) if button == "left" and state == "up" then if source == teleportButtonBus then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1743,-1863,14,0) outputChatBox("You have arrived to Los Santos from the bus. Happy RPing!") elseif source == teleportButtonPlane then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1686,-2239,14,0) outputChatBox("You have arrived to Los Santos from the plane. Happy RPing!") end guiSetVisible(teleportWindow, false) showCursor(false) fadeCamera(true) end end EDIT: fixed the teleport window popping up early but the mouse still wont go away...
  4. I'm using the login system from the guide on the wiki but what do I do if i want dozens of accounts? I don't want to be putting them all into gui.lua so how can I make this easier and cleaner? gui.lua (client): function createLoginWindow() -- define the X and Y positions of the window local X = 0.375 local Y = 0.375 -- define the width and height of the window local Width = 0.25 local Height = 0.25 -- create the window and save its element value into the variable 'wdwLogin' -- click on the function's name to read its documentation wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) -- define new X and Y positions for the first label X = 0.0825 Y = 0.2 -- define new Width and Height values for the first label Width = 0.25 Height = 0.25 -- create the first label, note the final argument passed is 'wdwLogin' meaning the window -- we created above is the parent of this label (so all the position and size values are now relative to the position of that window) guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) -- alter the Y value, so the second lebel is slightly below the first Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) -- Max chars to 50 guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) -- make the window invisible guiSetVisible(wdwLogin, false) -- stop players from being able to simply move the window out of the way guiWindowSetMovable(rulesWindow,false) -- stop players from being able to resize the window guiWindowSetSizable(rulesWindow,false) -- now add our onClientGUIClick event to the button we just created addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end -- attach the event handler to the root element of the resource -- this means it will only trigger when ts own resource is started addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () -- create the log in window and its components createLoginWindow() -- output a bried welcome message tot he player outputChatBox("Welcome to DarkM's RP, please log in.") -- if the GUI was successfully created, the show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasn't been properly created, tell the player outputChatBox("An unexpected error has occured and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on components) showCursor(true) -- set the input focus onto the GUI, allowing players (For example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) -- create the function and define the 'button' and 'state' parameters -- (these are passed automatically by onClientGUIClick) function clientSubmitLogin(button,state) if button == "left" and state == "up" then -- get the text entered in the 'unsername' field local username = guiGetText(edtUser) -- get the text entered in the 'password' field local password = guiGetText(edtPass) -- if the username and password both exist if username and password then -- trigger the server event 'submitLogin' and pass the username and password to it triggerServerEvent("submitLogin", getLocalPlayer(), username, password) else -- otherwise, output a message to the player, do not trigger the server -- and do not hide thr gui outputChatBox("Please enter a username and password.") end if username == "user" and password == "apple" then guiGetEnabled(false) guiSetVisible(wdwLogin, false) guiSetVisible(rulesWindow,true) end end end script.lua(server): function loginHandler(username,password) -- check that the username and password are correct if username == "user" and password == "apple" then -- the player has successfully logged in, so spawn them if (source) then setCameraTarget(source, source) fadeCamera(source, false) outputChatBox("Thank you for logging in.", source) end else -- if the username or password are not correct, output message to player outputChatBox("Invalid username and/or password. Please try again.",source) end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler)
  5. Thank you, I tried putting those in the wrong function after posting. EDIT: Alright so now the buttons work and it teleports me but I can't move. EDIT2: Switched setElementPosition back to spawnPlayer and I can now move around
  6. The buttons for my teleport window don't work. Also, how would i go about making the camera fade in after teleporting? (I made it so that the screen is black until teleporting.) gui.lua (from the beginning of teleport window): function createTeleportWindow() local sWidth, sHeight = guiGetScreenSize() local Width,Height = 231,188 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) teleportWindow = guiCreateWindow(X,Y,Width,Height,"Starting Area",false) guiWindowSetSizable(teleportWindow,false) teleportLabel = guiCreateLabel(18,23,191,33,"Bus or Plane?",false,teleportWindow) guiLabelSetHorizontalAlign(teleportLabel,"center",true) teleportButtonBus = guiCreateButton(18,63,195,35,"Bus",false,teleportWindow) teleportButtonPlane = guiCreateButton(18,143,195,35,"Plane",false,teleportWindow) guiSetVisible(teleportWindow,false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createTeleportWindow() end ) function teleportPlayer(button,state) if button == "left" and state == "up" then if source == teleportButtonBus then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1743,-1863,14) outputChatBox("You have arrived to Los Santos from the bus. Happy RPing!") elseif source == teleportButtonPlane then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1686,-2239,14) outputChatBox("You have arrived to Los Santos from the plane. Happy RPing!") end guiSetVisible(teleportWindow, false) showCursor(false) end addEventHandler("onClientGUIClick",teleportButtonBus,teleportPlayer,false) addEventHandler("onClientGUIClick",teleportButtonPlane,teleportPlayer,false) end script.lua (from moveThePlayer): function moveThePlayer(x,y,z) if x and y and z then local skin = getElementModel(client) spawnPlayer(client,x,y,z,skin) setCameraTarget(client,client) end end addEvent("clientKickInactivePlayer",true) addEventHandler("clientKickInactivePlayer",root,kickInactivePlayer) addEvent("movePlayerToPosition",true) addEventHandler("movePlayerToPosition",root,moveThePlayer) Am I missing something?
  7. Wow that is simple. Thank you You are Jesus for noobs like me. lol
  8. I'm working with the tutorials on the wiki and when I test it out, all the GUI's are open at the same time. How can I make it so that after I log in, the rules window pups up and then after I click accept, the teleport window pops up? Please explain in detail since I'm very new.
  9. That didn't work either. How can I fix the "ACL denied access to debugscript" so that I can debug?
  10. Okay the Login GUI shows up but now nothing happpens when I click on the login button. I tried doing the debugscript command but I get ACL: Denied access.
  11. Alright, so I'm following the guides on the wiki and so far I've hit 2 walls. The command to spawn a vehicle doesn't work and the Login GUI doesn't show up. Here is my script.lua: function joinHandler() local x = 1743 local y = -1863 local z = 14 -- spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to DarkM's RP", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) -- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel function createVehicleForPlayer(thePlayer, command, vehicleModel) -- create a vehicle and stuff local x,y,z = getElementPosition(thePlayer) x = x + 5 -- ensures vehicle wont spawn in player -- create the vehicle and store the returned vehicle element in the ''createdVehicle'' variable local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if (createVehicle == false) then outputChatBox("Failed to create vehicle.",thePlayer) end end -- create a command handler addCommandHandler("createvehicle", createVehicleForPlayer) -- create our loginHandler function, with username and password parameters (passed from the client gui) function loginHandler(username,password) -- check that the username and password are correct if username == "user" and password == "apple" then -- the player has successfully logged in, so spawn them if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) outputChatBox("Welcome to DarkM's RP.", client) end else -- if the username or password are not correct, output message to player outputChatBox("Invalid username and/or password. Please re-connect and try again.",client) end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) This is my gui.lua: function createLoginWindow() -- define the X and Y positions of the window local X = 0.375 local Y = 0.375 -- define the width and height of the window local Width = 0.25 local Height = 0.25 -- create the window and save its element value into the variable 'wdwLogin' -- click on the function's name to read its documentation wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) -- define new X and Y positions for the first label X = 0.0825 Y = 0.2 -- define new Width and Height values for the first label Width = 0.25 Height = 0.25 -- create the first label, note the final argument passed is 'wdwLogin' meaning the window -- we created above is the parent of this label (so all the position and size values are now relative to the position of that window) guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) -- alter the Y value, so the second lebel is slightly below the first Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) -- Max chars to 50 guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Wdith = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) -- make the window invisible guiSetVisible(wdwLogin, false) -- now add our onClientGUIClick event to the button we just created addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end -- attach the event handler to the root element of the resource -- this means it will only trigger when ts own resource is started addEventHandler("OnClientResourceStart", getResourceRootElement(getThisResource()), function () -- create the log in window and its components createLoginWindow() -- output a bried welcome message tot he player outputChatBox("Welcome to DarkM's RP, please log in.") -- if the GUI was successfully created, the show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasn't been properly created, tell the player outputChatBox("An unexpected error has occured and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on components) showCursor(true) -- set the input focus onto the GUI, allowing players (For example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end -- create the function and define the 'button' and 'state' parameters ) -- (these are passed automatically by onClientGUIClick) function clientSubmitLogin(button,state) if button == "left" and state == "up" then -- get the text entered in the 'unsername' field local username = guiGetText(edtUser) -- get the text entered in the 'password' field local password = guiEditText(edtPass) -- if the username and password both exist if username and password then -- trigger the server event 'submitLogin' and pass the username and password to it triggerServerEvent("submitLogin", getRootElement(), username, password) -- hide the gui, hide the cursor and return control to the player guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) else -- otherwise, output a message to the player, do not trigger the server -- and do not hide thr gui outputChatBox("Please enter a username and password.") end end end Please help. P.S. I'm using the MTA Script Editor (updated to 2.9.3)
×
×
  • Create New...