Jump to content

Beginner scripter


ASiT

Recommended Posts

Posted

hey guys,

i just started to try and get into scripting the gui and stuff for MTA and i ran into a problem ( mind you im a beginner and dont be too harsh if my script makes no sense at all) :P

Its supposed to spawn a window that says login and once you type everything in and push the button another window comes up and has 2 buttons saying cops or robbers and so far i only have cops ... so if you push the button it spawns you and gives you weapons but it comes up to black screen...

function CreateLoginWindow()

local X = 0.375

local Y = 0.375

local Width = 0.25

local Height = 0.25

wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true)

X = 0.0825

Y = 0.2

Width = 0.25

Height = 0.25

guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin)

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)

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)

guiSetVisible(wdwLogin, false)

end

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),

function CreateSelectWindow()

local X = 0.375

local Y = 0.375

local Width = 0.25

local Height = 0.25

wdwSelect = guiCreateWindow(X, Y, Width, Height, "Please Select A Character Class", true)

X = 0.415

Y = 0.2

Width = 0.5

Height = 0.25

btnCops = guiCreateButton(X, Y, Width, Height, "Cops", true, wdwSelect)

Y = 0.5

btnRobs = guiCreateButton(X, Y, Width, Height, "Robbers", true, wdwSelect)

X = 0.415

Y = 0.7

Width = 0.25

Height = 0.2

btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwSelect)

guiSetVisible(wdwSelect, false)

end

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),

function createTeamsOnStart ()

teamCivilians = createTeam ( "Civilians", 194, 194, 194 )

teamCops = createTeam ( "LSPD", 101, 101, 215 )

end

addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart )

function ()

CreateLoginWindow()

addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false)

outputChatBox("Welcome to My MTA DM Server, please log in. ")

if (wdwLogin ~= nil) then

guiSetVisible(wdwLogin, true)

end

showCursor(true)

guiSetInputEnabled(true)

end

)

function clientSubmitLogin(button)

if button == "left" then

triggerServerEvent("SubmitLogin", getRootElement(), guiGetText(edtUser), guiGetText(edtPass))

guiSetInputEnabled(false)

guiSetVisible(wdwLogin, false)

showCursor(true)

CreateSelectWindow()

addEventHandler("onClientGUIClick", btnCops, assignCops, false)

outputChatBox("Thankyou for selecting a class,Have fun!... ")

if (wdwSelect ~= nil) then

guiSetVisible(wdwSelect, true)

end

end

end

function joinHandler(username, password)

outputChatBox("Welcome to My Server", client)

end

end

addEvent("SubmitLogin", true)

addEventHandler("SubmitLogin", getRootElement(), joinHandler)

function assigncops()

spawnPlayer ( player, 1552.4109, -1675.0485, 16.1953 )

giveWeapon ( player, 31, 10000 )

giveWeapon ( player, 24, 10000 )

giveWeapon ( player, 25, 10000 )

giveWeapon ( player, 29, 10000 )

giveWeapon ( player, 17, 10000 )

giveWeapon ( player, 42, 10000 )

setPlayerArmor ( player, 0 )

setPlayerSkin ( player, 280 )

setPlayerNametagColor ( player, 101, 101, 215 )

end

Posted

If the screen is black, you need to use fadeCamera().

Also if you use [ code] tags for Lua codes here in the forum, it gets easier to read.

Posted

but for the fadecamera thing the gui doesnt even show up when i start the server and fadecamera isnt that used when you spawn and stuff im saying the gui doesnt even come up ...

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