Jump to content

Legenden

Members
  • Posts

    10
  • Joined

  • Last visited

Legenden's Achievements

Member

Member (5/54)

0

Reputation

  1. Now it works, thanks. /lock please.
  2. Like that it says: lula\login.lua:64: Bad Argument @ 'addEventHandler [Expected element at argument 2, got nil]
  3. It's me again, this time in the right section. So, I wanted to make a login screen but I get this error: [08:02:43] SCRIPT ERROR: lula\login.lua:64: '>' expected < to c lose '<' at line 42> near addEventHandler function createLoginWindow() local X = 0.375 local Y = 0.385 local Width = 0.25 local Height = 0.25 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 label 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) -- set the maximum character length for the username and password fields to 50 guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.71 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) -- make the window invisible guiSetVisible(wdwLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () -- create the log in window and its components createLoginWindow() -- output a brief welcome message to the player outputChatBox("Welcome to My MTA:SA Server, please log in.") -- if the GUI was successfully created, then show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasnt been properly created, tell the player outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on the components) showCursor(true) -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end -- attach the event onClientGUIClick to btnLogin and set it to trigger the 'clientSubmitLogin' function addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) -- 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 'username' 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", 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 the gui outputChatBox("Please enter a username and password.") end end end
  4. Legenden

    Scripting help

    Thanks now it's working. That "468" was useless.
  5. Legenden

    Scripting help

    Like this it says: [00:49:32] Script error: myserver\newb.lua:9: or "...." expected near '468' Thanks anyway.
  6. Legenden

    Scripting help

    The newb.lua file: local spawnX, spawnY, spawnZ = 386, -1926, 1 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to My Server", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) end function createVehicleForPlayer(thePlayer, spawn, 468) local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(468),x,y,z) if (createdVehicle == false) then outputChatBox("fail",thePlayer) end end addCommandHandler ("createvehicle", createVehicleForPlayer) The meta.xml file: "Legenden" type="gamemode" name="My Server" description="First attempt in scripting" /> (thePlayer, spawn, 468) - if you wonder what this means: -- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel function createVehicleForPlayer(thePlayer, command, vehicleModel) -- create a vehicle and stuff end -- create a command handler addCommandHandler("createvehicle", createVehicleForPlayer)
  7. Legenden

    Scripting help

    I did that at the first time, I just copied the example from wiki.
  8. Legenden

    Scripting help

    Hello, I'd like a hand for my first script. I'm a total rookie. So according to MTA wiki I had to write this: "YourName" type="gamemode" name="My Server" description="My first MTA DM server" /> But as I loaded the resource in my server it said: [04:22:15] SCRIPT ERROR: myserver/newb.lua:9: '' expected near 'end' Help please.
  9. And how exactly can I run a resource?
  10. 1. How can I add an interior to a house? 2. Every time I want to open a new map it says "Cannot load a new map when another one is being saved/loaded. "So, how can I fix it? 3. How can I use this script? https://community.multitheftauto.com/index.php?p= ... ils&id=727 Thanks for your help.
×
×
  • Create New...