masch1na Posted September 4, 2010 Share Posted September 4, 2010 Hello there. This is my first GUI script and I basically predicted that it won't work at all. What I want to do: Create two buttons after you log in saying 'Crips' and 'Bloods' - Done Create two different teams - Crips and Bloods - Failed After you click one of the buttons, it will spawn you at the position with certain skin and team, according to the button you have clicked on - Failed I start the server and load up my script, the window with buttons is there, however nothing happens after I click the buttons. I know the problem is in my serverside lua script, however I've got no clue how to fix it. My clientside script with the GUI - http://pastebin.com/Etwg8cUJ My serverside script - http://pastebin.com/BZPfqgpr There should be something with spawmTeam = createTeam, according to MTA Wiki, but I'm really lost at this moment. And yes, I'm working on this script for five hours non-stop, and tried to look on several internet pages, haven't found anything though. Thank you in advance. Link to comment
Remp Posted September 4, 2010 Share Posted September 4, 2010 First, you spelt button wrong: ... if [b]buttom[/b] == 'left' and state == 'up' then ... If you look at the wiki page for triggerServerEvent you will see the first argument is supposed to be a string with the name of a function, not a function itself Your onClientGUIClick event handles for your buttons should be inside your createTeamWindow function. Any code outside a function is run as soon as the resource starts, meaning at the moment you are trying to add event handlers to buttons that don't actually exist (yet) You are checking for a 'spawnButtonBloods', which doesnt exist: ... elseif source == spawnButtonBloods then ... You will want to use fadeCamera on the player when they spawn or their screen will be black All of these things can be found in a matter of minutes with some simple debugging After fixing the first one the others would show up in debugscript as errors which makes it even easier Formatting your code properly also makes it much easier to see whats going on and where the problems are: ... function movePlayer(button,state) if button == 'left' and state == 'up' then if source == teamButtonCrips then triggerServerEvent('movePlayer', getLocalPlayer(), 2642.4440917969, -2004.3111572266, 13.5546875, 0, 106, 0, 0) outputChatBox('If you Crip throw it up!') ... Link to comment
dzek (varez) Posted September 4, 2010 Share Posted September 4, 2010 If you look at the wiki page for triggerServerEvent you will see the first argument is supposed to be a string with the name of a function, not a function itself actually it's a event name (as string), not function. Link to comment
masch1na Posted September 5, 2010 Author Share Posted September 5, 2010 Thank you all, I made this working properly, and it's even better now, I made pictures instead of classic GUI buttons and added music when you connect to the server. I'm currently working on garg ares in radar, after player enters area it will blip, after some time it will change color according to players team. I'm done with radar and blipping, I guess the hardest part is just in front of me, it's a pity that community isn't working so I could work with something. Thank you anyway! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now