Jump to content

Problem with client-side script


hemen

Recommended Posts

Client-side script not loaded, because one command don't work. Also, server doesn't return any errors.

File meta.xml:

<meta>
<info author="hemen" description="Hemen's LVDM" version="1" type="gamemode" />
 
<script src="gm_server.lua"/>
<script src="gm_client.lua" type="client"/>
<map src="gm.map"/>
</meta>

When i did set type of "gm_client.lua" to "server", server returned me all errors!

p.s. sorry for my bad english

Link to comment
var0 = 0
gMe = getLocalPlayer()
 
function helpfunc(player,commandName)
if var0 == 0 then
local mainGui = guiCreateWindow(450.0,450.0, 50.0, 50.0, "Hemen's LVDM help.", true)
guiWindowSetMovable(mainGui,false)
guiWindowSetSizeable(mainGui,false)
rulesLabel = guiCreateLabel(455.0,455.0,40.0,40.0,[[
Hemen's LVDM 1. Author: hemen.
	This is the mode-moneygrub. You can do that you like.
	You can earn money on Pirate Ship. You can 
	]],true,mainGui)
	guiSetVisible(mainGui, true)
	var0 = 1
	return
	else
	var0 = 0
	guiSetVisible(mainGui, false)
	return
	end
end
 
addCommandHandler("help",helpfunc);

Link to comment

Omg, how about indentation?

Several mistakes or unneeded lines:

1. The "relative" coords at guiCreateLabel do not have a relative value.

2. A "guiSetVisible(mainGui, true)" is not needed after the creation, because any gui element created is visible by default.

3. The returns are not necessary, because first you don't return any value, second you don't need to end the function at this point, because there won't be anything executed within the function after this point anyways.

4. If your var0 holds 1, you just hide the gui window. At the next call of the function, it is still existing, but you create a new one. You should either check at showing, whether it is already created or not, or destroy the gui elements at hiding.

5. Your function arguments are incorrect. When you are working clientside, addCommandHandler won't pass on the player argument, because it is always the local player, who will trigger this command. Also, you don't even use both of them, so you can just get rid of them (by just writing "function helpfunc()").

This may fix it, but perhaps it won't. If not, also publish your serverside script.

Link to comment
Omg, how about indentation?

Several mistakes or unneeded lines:

1. The "relative" coords at guiCreateLabel do not have a relative value.

2. A "guiSetVisible(mainGui, true)" is not needed after the creation, because any gui element created is visible by default.

3. The returns are not necessary, because first you don't return any value, second you don't need to end the function at this point, because there won't be anything executed within the function after this point anyways.

4. If your var0 holds 1, you just hide the gui window. At the next call of the function, it is still existing, but you create a new one. You should either check at showing, whether it is already created or not, or destroy the gui elements at hiding.

5. Your function arguments are incorrect. When you are working clientside, addCommandHandler won't pass on the player argument, because it is always the local player, who will trigger this command. Also, you don't even use both of them, so you can just get rid of them (by just writing "function helpfunc()").

This may fix it, but perhaps it won't. If not, also publish your serverside script.

Thank you, but why, when i wrote simply text (blablabla) in gm_client.lua , server didn't returned any errors?

Command doesn't works.

Link to comment

Well to think of it, server never returns clientside errors. How on earth should the server know what's happening in your client? That's where debugscript comes in, so you can see the clientside errors in your MTA client. Check the debugging article at wiki if you're not familiar with debugscript.

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