Jump to content

Problem with my GUI


CTCCoco

Recommended Posts

I have a little problem with the GUI. First the " player se ha conectado " doesn't appears. That means that the onClientPlayerJoin doesn't active :S but why?

Second the GUI doesn't appears when the player is in the " posicionjug1 ". wtf?

I have the client script in client/guibotones.lua in my resource RLC and this is my resource meta:

<meta>
<?xml version="1.0" encoding="UTF-8" ?>
<info author="Coco" type="gamemode" name="RLC" description="RLC" />
<script src="spawn.lua" />
<script src="comandos.lua" />
<script src="registrarse.lua" />
<script src="client/guibotones.lua" type="client" />
meta>

I don't receive any errors on the console and anything.

And this is the Client GUI code:

---------------------------------SCRIPT DE LOS BOTONES ( GUI ) CLIENT-SIDE
 
---------------------------------SE CREA LA VENTANA
function crearComprarCasasWindow()
for houses=0 , casasnum do
local hEntrancex = xmlNodeGetAttribute ( casasxml, "hEntradax." .. houses )
local hEntrancey = xmlNodeGetAttribute ( casasxml, "hEntraday." .. houses )
local hEntrancez = xmlNodeGetAttribute ( casasxml, "hEntradaz." .. houses )
local posicionjugS1 = createColSphere( hEntrancex, hEntrancey, hEntrancez, 3.0)
local posicionjug1 = isElementWithinColShape ( thePlayer, posicionjugS1 )
if(posicionjug1) then
local casasxml = xmlLoadFile("casas.xml")
windowTituloCasa = guiCreateWindow(460,289,357,171,"Sistema de casas por CTCCoco",false)
local hOwner = xmlNodeGetAttribute (casasxml, "hOwner." .. houses )
labelDuenoCasa = guiCreateLabel(10,29,335,18,"Dueno:" .. hOwner,false,windowTituloCasa)
guiLabelSetColor(labelDuenoCasa,255,255,255)
guiLabelSetVerticalAlign(labelDuenoCasa,"top")
guiLabelSetHorizontalAlign(labelDuenoCasa,"left",false)
local hDesc = xmlNodeGetAttribute (casasxml, "hDesc." .. houses )
labelDescripcionCasa = guiCreateLabel(8,47,340,45,"Descripcion: " .. hDesc,false,windowTituloCasa)
guiLabelSetColor(labelDescripcionCasa,255,255,255)
guiLabelSetVerticalAlign(labelDescripcionCasa,"top")
guiLabelSetHorizontalAlign(labelDescripcionCasa,"left",false)
local hValue = xmlNodeGetAttribute (casasxml, "hValue." .. houses )
labelPreAlqCasa = guiCreateLabel(8,94,334,34,"Precio: " .. hValue .. "$              Alquiler:",false,windowTituloCasa)
guiLabelSetColor(labelPreAlqCasa,255,255,255)
guiLabelSetVerticalAlign(labelPreAlqCasa,"top")
guiLabelSetHorizontalAlign(labelPreAlqCasa,"left",false)
botonComprarCasa = guiCreateButton(10,136,89,25,"Comprar",false,windowTituloCasa)
botonCancelarCasa = guiCreateButton(259,136,89,25,"Cancelar",false,windowTituloCasa)
guiSetVisible(windowTituloCasa, true)
return 1
else
guiSetVisible(windowTituloCasa, false)
return 1
end
end
end
function WindowComprarCasa()
crearComprarCasasWindow()
--outputChatBox("* " .. getPlayerName(source) .. " esta owneando el server.")
end
--------------------CUANDO EL JUGADOR SE CONECTA REPITE ESTO CADA SEG.
function remotePlayerJoin()
--outputChatBox("* " .. getPlayerName(source) .. " has joined the server")
setTimer (WindowComprarCasa, 3000, 0)
outputDebugString("* " .. getPlayerName(source) .. " se a conectado.")
end
addEventHandler("onClientPlayerJoin", getRootElement(), remotePlayerJoin)

Please I need some help. Thanks.

Edited by Guest
Link to comment
  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Hy CTCCoco !

maybe there are an error in the function crearComprarCasasWindow() because you can't use the xml functions on xmls files which are in the server, you must put the .xml file as client in the meta.

So all the remainder of your guibotones.lua doesn't work !

I propose to you to put this for PlayerJoin:

In your server:

function remotePlayerJoin()
outputChatBox("* " .. getPlayerName(source) .. " has joined the server")
outputDebugString("* " .. getPlayerName(source) .. " se a conectado.")
setTimer(triggerClientEvent,3000, 0, source, "crearComprarCasasWindow", getRootElement())
end
addEventHandler("onPlayerJoin", getRootElement(), remotePlayerJoin)

Normaly it will work except the setTimer because of error in guibotones.lua !

And for your GUI I can't help you (maybe Famas knows how work xml functions :?: )

The Famas's brother

Link to comment
Hy CTCCoco !

maybe there are an error in the function crearComprarCasasWindow() because you can't use the xml functions on xmls files which are in the server, you must put the .xml file as client in the meta.

So all the remainder of your guibotones.lua doesn't work !

I propose to you to put this for PlayerJoin:

In your server:

function remotePlayerJoin()
outputChatBox("* " .. getPlayerName(source) .. " has joined the server")
outputDebugString("* " .. getPlayerName(source) .. " se a conectado.")
setTimer(triggerClientEvent,3000, 0, source, "crearComprarCasasWindow", getRootElement())
end
addEventHandler("onPlayerJoin", getRootElement(), remotePlayerJoin)

Normaly it will work except the setTimer because of error in guibotones.lua !

And for your GUI I can't help you (maybe Famas knows how work xml functions :?: )

The Famas's brother

What do you mean to XML in Client? How I can use the XML in both server side and client ?

And what do you mean saying the SetTimer is bugged? :S

Please help. and thanks men. :D

Link to comment

There are several problems with your code, CTCCoco.

General tips

- Try scripting in English, even if your English isn't good. Practice makes perfect anyway, and it gives us more of an idea what you're trying to do, making support easier. (currently most variable and function names are not easy to understand for anyone outside of your language)

- Indent your code properly. At the moment, your "crearComprarCasasWindow" (whatever it might mean) is an unreadable chunk of code. Put a few tabs or spaces in front of lines to make the code a lot more readable, making support yet again a lot faster

Possible issues

- Line: 5 / Where is "casasnum" defined?

- Line: 9 / Col sphere "posicionjugS1" is created, but never destroyed or used. (except for line 10) Delete the col sphere as soon as it has outlived it's use

- *** Skipping to remotePlayerJoin() due to difficulty understanding the code ***

- Line: 46 / setTimer - I don't know what you're trying to do, but you do realize that putting 0 for the 3rd argument means that it would keep running, don't you? Because right now, you're creating a new GUI every 3 seconds for every player that joined after you. Speaking of memory waste.

@Famas... eh... or his brother? : Do note that placing the event server-side will only create more hassle, bandwidth usage and error message spam (while downloading for instance) in the server console.

Link to comment
There are several problems with your code, CTCCoco.

General tips

- Try scripting in English, even if your English isn't good. Practice makes perfect anyway, and it gives us more of an idea what you're trying to do, making support easier. (currently most variable and function names are not easy to understand for anyone outside of your language)

- Indent your code properly. At the moment, your "crearComprarCasasWindow" (whatever it might mean) is an unreadable chunk of code. Put a few tabs or spaces in front of lines to make the code a lot more readable, making support yet again a lot faster

Possible issues

- Line: 5 / Where is "casasnum" defined?

- Line: 9 / Col sphere "posicionjugS1" is created, but never destroyed or used. (except for line 10) Delete the col sphere as soon as it has outlived it's use

- *** Skipping to remotePlayerJoin() due to difficulty understanding the code ***

- Line: 46 / setTimer - I don't know what you're trying to do, but you do realize that putting 0 for the 3rd argument means that it would keep running, don't you? Because right now, you're creating a new GUI every 3 seconds for every player that joined after you. Speaking of memory waste.

@Famas... eh... or his brother? : Do note that placing the event server-side will only create more hassle, bandwidth usage and error message spam (while downloading for instance) in the server console.

casasnum is defined in another server-side script and I think that I can use it in the script but I see that I can't in Client.

You mean that I will destroy the Col Sphere when it is used? posicionjugS1 is used at line 10.

I am trying to do when a player go to the enter of a House then displays a GUI to buy the house , to see information, etc

I hope you understand me and thanks for trying help me.

Sorry for my bad English.

THANKS!

Link to comment

Hy, CTCCoco

No your setTimer is correct but like the function crearComprarCasasWindow() doesn't work, all the rest in guibotones.lua is locked and they can't work! Do you understand ?

I never used the xml's function but I try to help you :wink:

Do you read the example and the description of XmlNodeGetAttribute on MTA Wiki :?: =>https://wiki.multitheftauto.com/wiki/XmlNodeGetAttribute

And if you look at well you need to open the xml file and other things and In your code I don't see where you open the casas.xml and to open this file you must include this file in meta.xml. Are you agree ?

The Famas's brother

Link to comment
Hy, CTCCoco

No your setTimer is correct but like the function crearComprarCasasWindow() doesn't work, all the rest in guibotones.lua is locked and they can't work! Do you understand ?

I never used the xml's function but I try to help you :wink:

Do you read the example and the description of XmlNodeGetAttribute on MTA Wiki :?: =>https://wiki.multitheftauto.com/wiki/XmlNodeGetAttribute

And if you look at well you need to open the xml file and other things and In your code I don't see where you open the casas.xml and to open this file you must include this file in meta.xml. Are you agree ?

The Famas's brother

No, I think you don't need include it. I know how to use XML fuctions, the system works fine in a command but I mean that doesn't works the GUI :S

Thanks men.

Link to comment

Hi Gamesnert,

If I understand good you tell me that he must to comment my setTimer because the clientside is not debug and so It's spam because it's repeat every 3 second ?

And CTCCoco, If I say REGM does that say something to you ?

Sorry if I not speak English very well :mrgreen:

The Famas's brother

Link to comment
Hy, CTCCoco

No your setTimer is correct but like the function crearComprarCasasWindow() doesn't work, all the rest in guibotones.lua is locked and they can't work! Do you understand ?

I never used the xml's function but I try to help you :wink:

Do you read the example and the description of XmlNodeGetAttribute on MTA Wiki :?: =>https://wiki.multitheftauto.com/wiki/XmlNodeGetAttribute

And if you look at well you need to open the xml file and other things and In your code I don't see where you open the casas.xml and to open this file you must include this file in meta.xml. Are you agree ?

The Famas's brother

No, I think you don't need include it. I know how to use XML fuctions, the system works fine in a command but I mean that doesn't works the GUI :S

Thanks men.

The GUI works with a command ? or just the xml functions ?

casasnum is defined in another server-side script and I think that I can use it in the script but I see that I can't in Client.

the server-side and client-side are separate and you must used triggerClientEvent to send variable (here casanum) to your client-side (guibotones.lua). Possible issue:

Server-side:

function enviarcasanum()
triggerClientEvent("recibircasanum", getRootElement(), casanum)
end

Client-side before "function crearComprarCasasWindow()":

addEvent( "recibircasanum", true )
function recibircasanum(casanum)
casanum = casanum
end
addEventHandler("recibircasanum", getRootElement(),recibircasanum)

that should work if your xml functions work

The Famas's brother

Link to comment

Indeed in your gui there are:

local casasxml = xmlLoadFile("casas.xml")

after

local hEntrancex = xmlNodeGetAttribute ( casasxml, "hEntradax." .. houses )
local hEntrancey = xmlNodeGetAttribute ( casasxml, "hEntraday." .. houses )
local hEntrancez = xmlNodeGetAttribute ( casasxml, "hEntradaz." .. houses )

whereas you must be placed before! Here your 3 xml functions get "hEntrada" of casaxml but casaxml isn't yet defined

I search other errors (if there is still ^^)

The Famas's brother

Link to comment

Doesn't work yet and i don't know what the hell is goin on.

I think the guibotones doesn't loaded because I do errors in the guibotones.lua script on purpose and the console don't say anything, and If I do it in a server-side script, the console say the problems.

What happens? guibotones.lua doesn't loaded?

my meta:

<meta>
    <?xml version="1.0" encoding="UTF-8" ?>
    <info author="Coco" type="gamemode" name="RLC" description="RLC" />
    <script src="spawn.lua" />
    <script src="comandos.lua" />
    <script src="registrarse.lua" />
    <script src="guibotones.lua" type="client" />
</meta>

Please help. Thanks for all people.

EDIT: I see that if you put type="client" ( this says that the script is client-side ) don't detect the problems.

:S

Link to comment
Doesn't work yet and i don't know what the hell is goin on.

I think the guibotones doesn't loaded because I do errors in the guibotones.lua script on purpose and the console don't say anything, and If I do it in a server-side script, the console say the problems.

What happens? guibotones.lua doesn't loaded?

my meta:

<meta>
    <?xml version="1.0" encoding="UTF-8" ?>
    <info author="Coco" type="gamemode" name="RLC" description="RLC" />
    <script src="spawn.lua" />
    <script src="comandos.lua" />
    <script src="registrarse.lua" />
    <script src="guibotones.lua" type="client" />
</meta>

Please help. Thanks for all people.

EDIT: I see that if you put type="client" ( this says that the script is client-side ) don't detect the problems.

:S

When you're debugging script use "debugscript 3" command and you will see a debug box which tells you about problems in server-side and client-side scripts.

Link to comment

The console writes only server-side errors ! Your guibotones.lua is a client so the errors are write in clientscript.log

root: c:\Program Files\MTA San Andreas\MTA\

And I send to you in a mail the guibotones.lua repaired

If not, I put it here to you and try this:

guibotones.lua:

-------------------------------------------------------------------------------------------
-------------------------------- SCRIPT DE LOS BOTONES ( GUI ) CLIENT-SIDE ----------------
-------------------------------------------------------------------------------------------
------------------------------------ Recibir casanum --------------------------------------
addEvent( "recibircasanum", true )
function recibircasanum(casasnum)
  casasnum = casasnum
end
addEventHandler("recibircasanum", getRootElement(),recibircasanum)
 
--------------------------------- SE CREA LA VENTANA ----------------------------------------
function crearComprarCasasWindow()
for houses=0 , casasnum do
local casasxml = xmlLoadFile("casas.xml")--It's here that the casasxml.xml must to be open !!
local hEntrancex = xmlNodeGetAttribute ( casasxml, "hEntradax." .. houses )
local hEntrancey = xmlNodeGetAttribute ( casasxml, "hEntraday." .. houses )
local hEntrancez = xmlNodeGetAttribute ( casasxml, "hEntradaz." .. houses )
local posicionjugS1 = createColSphere( hEntrancex, hEntrancey, hEntrancez, 3.0)
local posicionjug1 = isElementWithinColShape ( thePlayer, posicionjugS1 )
if(posicionjug1) then
		windowTituloCasa = guiCreateWindow(460,289,357,171,"Sistema de casas por CTCCoco",false)
local hOwner = xmlNodeGetAttribute (casasxml, "hOwner." .. houses )
		labelDuenoCasa = guiCreateLabel(10,29,335,18,"Dueno:" .. hOwner,false,windowTituloCasa)
guiLabelSetColor(labelDuenoCasa,255,255,255)
guiLabelSetVerticalAlign(labelDuenoCasa,"top")
guiLabelSetHorizontalAlign(labelDuenoCasa,"left",false)
local hDesc = xmlNodeGetAttribute (casasxml, "hDesc." .. houses )
		labelDescripcionCasa = guiCreateLabel(8,47,340,45,"Descripcion: " .. hDesc,false,windowTituloCasa)
guiLabelSetColor(labelDescripcionCasa,255,255,255)
guiLabelSetVerticalAlign(labelDescripcionCasa,"top")
guiLabelSetHorizontalAlign(labelDescripcionCasa,"left",false)
local hValue = xmlNodeGetAttribute (casasxml, "hValue." .. houses )
		labelPreAlqCasa = guiCreateLabel(8,94,334,34,"Precio: " .. hValue .. "$              Alquiler:",false,windowTituloCasa)
guiLabelSetColor(labelPreAlqCasa,255,255,255)
guiLabelSetVerticalAlign(labelPreAlqCasa,"top")
guiLabelSetHorizontalAlign(labelPreAlqCasa,"left",false)
		botonComprarCasa = guiCreateButton(10,136,89,25,"Comprar",false,windowTituloCasa)
		botonCancelarCasa = guiCreateButton(259,136,89,25,"Cancelar",false,windowTituloCasa)
guiSetVisible(windowTituloCasa, true)
outputChatBox("Se creó la ventana !") 
return 1
else
outputChatBox("casasnum not defined !")
guiSetVisible(windowTituloCasa, false)
return 1
end
end
end

server-side:

function remotePlayerJoin()
outputChatBox("* " .. getPlayerName(source) .. " se a conectado")
outputDebugString("* " .. getPlayerName(source) .. " se a conectado.")
triggerClientEvent("recibircasanum", getRootElement(), casasnum))
setTimer(triggerClientEvent,3000, 0, source, "crearComprarCasasWindow", getRootElement())
end
addEventHandler("onPlayerJoin", getRootElement(), remotePlayerJoin)

The Famas's brother

Link to comment

I found the problems.

The .xml don't load and the fuctions doesn't works because it's needed load the xml.

In server-side the xml load correctly.

Why?

local casasxml = xmlLoadFile("casas.xml")

the SAME works perfect in server-side :S

Link to comment

where you are put the casas.xml ? (give me the root directory)

EDIT: And in your guibotones.lua you must to open this file before the xmls functions like this:

for houses=0 , casasnum do
local casasxml = xmlLoadFile(":RLC/casas.xml")--It's here that the casasxml.xml must to be open !!
local hEntrancex = xmlNodeGetAttribute ( casasxml, "hEntradax." .. houses )
    ...

The Famas's brother

Edited by Guest
Link to comment
where you are put the casas.xml ? (give me the root directory)

The Famas's brother

I put it in my RLC resource. But the code is correct and I try with :RLC/casas.xml too and doesn't work.

For my experience I can think that it some save problem, but it works perfect in server side then... wtf?

Link to comment
you try like this: xmlLoadFile(":RLC/casas.xml") ?

And I edit my precede reply. Read it and answer me please

The Famas's brother

Yes I do it. I tell to you that I use the same on server-side in a command and all works perfect.

I don't know what to do.

Thanks men for all.

Link to comment

Your welcome ! I can't sleep if the problem aren't solved :mrgreen:

Are you change the place of: local casasxml = xmlLoadFile(":RLC/casas.xml") like I you said ??

Here

for houses=0 , casasnum do
local casasxml = xmlLoadFile(":RLC/casas.xml")--It's here that the casasxml.xml must to be open !!

And when you enter your command, the gui works ? or not ?

The Famas's brother

Link to comment
Your welcome ! I can't sleep if the problem aren't solved :mrgreen:

Are you change the place of: local casasxml = xmlLoadFile(":RLC/casas.xml") like I you said ??

Here

for houses=0 , casasnum do
local casasxml = xmlLoadFile(":RLC/casas.xml")--It's here that the casasxml.xml must to be open !!

And when you enter your command, the gui works ? or not ?

The Famas's brother

Yes I put the xmlLoadFile before all I know it. The GUI works , only thing that doesn't works is the fuctions that NEED the LoadXML.

Thanks.

Link to comment

Try this:

--Put this:
local casasxml = xmlLoadFile(":RLC/casas.xml")
if casasxml then 
outputChatBox("xmlFile Loaded !")
else 
outputChatBox("xmlFile NOT Loaded !")
end 
--Before this:
for houses=0 , casasnum do

EDIT:: And tell me what appears when the gui is called (Loaded or NOT Loaded ?)

The Famas's brother

Link to comment
Try this:
--Put this:
local casasxml = xmlLoadFile(":RLC/casas.xml")
if casasxml then 
outputChatBox("xmlFile Loaded !")
else 
outputChatBox("xmlFile NOT Loaded !")
end 
--Before this:
for houses=0 , casasnum do

EDIT:: And tell me what appears when the gui is called (Loaded or NOT Loaded ?)

The Famas's brother

NOT Loaded. I do it before. :|

What a shit xD

Thanks men but looks impossible xD

EDIT: I try to create a new XML in client-side but doesn't work too. It says that the XML was created correct ( I use the if( ) and says that is correct) and don't create anything... I use the same to what I use to create the other server-side XML and works fine.

Well the xmlLoadXML doesn't work yet.

Thanks

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