Jump to content

Gui help!


niemi

Recommended Posts

Why this isn't working? I got no errors but the gui doesnt exist. when i type /gui nothing happens, i don't get any errors. In /debugscript 3 or in serverconsole.

  
function createWindow ( thePlayer ) 
guiCreateWindow(45,85,630,492,"test",false)  
guiCreateEdit(0.0444,0.065,0.9302,0.9065,"",true) 
end 
addCommandHandler ( "gui", createWindow, thePlayer ) 
  

And here is meta.xml...

<meta> 
    <info author="Niemi" type="script" name="gui" description="sssa" /> 
    <script src="gui.lua" type="client" /> 
</meta> 

Link to post
function createWindow () 
    guiWindow = guiCreateWindow ( 45, 85, 630, 492, "test", false ) 
    guiEditBox = guiCreateEdit ( 0.0444, 0.065, 0.9302, 0.9065, "", true, guiWindow ) 
end 
addCommandHandler ( "gui", createWindow ) 

Try this, however its not really good to create it everytime you type gui, you should create your window onClientResourceStart and just set the guiSetVisible true / false with your command handler

Link to post

function createExplosion ( source, commandName ) 
  
    local pX, pY, pZ = getElementPosition ( source ) 
    createExplosion ( pX + 5, pY + 5, pZ, 6 ) 
    setTimer ( createExplosion, 1000, 1 ) 
end 
addCommandHandler ( "ce", createExplosion, getRootElement(), source ) 

This is the error i get:

[23:10:47] WARNING: lol.lua: Bad argument @ 'getElementPosition' - Line: 3

[23:10:47] ERROR: ...erver/mods/deathmatch/resources/NiemisGM/lol.lua:4: attempt to perform arithmetic on local 'pX' (a boolean value)

if i take those +5 off, like this:

function createExplosion ( source, commandName ) 
  
    local pX, pY, pZ = getElementPosition ( source ) 
    createExplosion ( pX, pY, pZ, 6 ) 
    setTimer ( createExplosion, 1000, 1 ) 
end 
addCommandHandler ( "ce", createExplosion, getRootElement(), source ) 

I get this error:

[23:12:57] WARNING: lol.lua: Bad argument @ 'getElementPosition' - Line: 3

[23:12:57] ERROR: ...erver/mods/deathmatch/resources/NiemisGM/lol.lua:3: stack overflow

Link to post
  • MTA Team

Sounds like you're using the serverside syntax on a clientside script. It should be noted that in the clientside variant there isnt a first argument.

Be sure to read http://development.mtasa.com/index.php? ... andHandler fully. Its clear to me you arent understanding the function arguments because you're passing more than 2 args (with the exception of restritced)

Try this:

  
function createExplosion ( commandName ) 
    local pX, pY, pZ = getElementPosition ( getLocalPlayer() ) 
    createExplosion ( pX + 5, pY + 5, pZ, 6 ) 
    setTimer ( createExplosion, 1000, 1 ) 
end 
addCommandHandler ( "ce", createExplosion ) 

Link to post

niemi in your code you use getElementPosition ( source ) the source can only be used server side, to find the position of a player client side use getElementPosition ( getLocalPlayer() )

talidan has allready corrected it but a thought a would explain it cause am bored lol :)

Link to post

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