tomozj Posted January 9, 2008 Share Posted January 9, 2008 (edited) Let me explain what the script does, first. When you press b, it's meant to allow you to click somewhere and when you click it creates an explosion for all players, complete with chatbox messages at various stages. -------------- Edit As I've fixed the script, you may download it a few posts down. Edited January 10, 2008 by Guest Link to comment
Black Dragon Posted January 9, 2008 Share Posted January 9, 2008 Lemme correct some errors. function keydown() if ( mouseon == 0 ) then ActivateMouse() else DeactivateMouse() end end function startup() -- At startup, we'll bind the key. outputChatBox( "Startup." ) bindKey( "b", "down", keydown ) outputChatBox( "Key binded." ) end addEventHandler("onClientResourceStart", getRootElement(), startup) function commands( commandName, arg, arg2 ) if( arg == "keydown" ) keydown() outputChatBox( "key down." ) return elseif( arg == "mouse" ) then if( arg2 == "on" ) then ActivateMouse() outputChatBox( "Mouse activated." ) else DeactivateMouse() outputChatBox( "Mouse deactivated." ) end return else outputChatBox( "Bomber script is active. (c) tomozj 2008" ) outputChatBox( "USAGE: /bomber [start/keydown/mouse] [on/off]" ) return end end addCommandHandler("bomber", commands, arg, arg2) All in all, you added ends before elses, which is a syntax error in Lua. Also, onClientResourceStart actually executes on resource start, (honest!) so it's redundant to have a command to execute it again. Oh, and I didn't check to see if it actually works, it's up to you from here. Link to comment
VRocker Posted January 9, 2008 Share Posted January 9, 2008 Right, theres a few things wrong with this script. Suprised the debug didn't moan at you tbh First of all, i notice you do: if ( mouseon == 0 ) then ActivateMouse() end else DeactivateMouse() end LUA doesn't work that way, you have a stray 'end' before your else. It should be: if ( mouseon == 0 ) then ActivateMouse() else DeactivateMouse() end Its the same with elseif's Down on line 72 you have this: function outputStatus() but with no matching end. Every 'function' needs an end even if it doesn't have anything in. Anyway from a quick glance it looks of except for what i've pointed out. Fix those problems and it should work Sorry if my explaination isn't too good.. its late and i'm tired *EDIT* Doh! Dragon beat me to it Link to comment
tomozj Posted January 10, 2008 Author Share Posted January 10, 2008 Ah, excellent guys. I really appreciate this, as I was going nuts! They seem pretty petty errors, which is probably why I missed them. And that random function with no end was probably something I forgot about (it's strange not using a compiler to check over). Once again, thank you! Link to comment
Sky Posted January 10, 2008 Share Posted January 10, 2008 Hi, I try to take the script and the install on my server but I did not understand everything: I took the code and I save it as a bomber.lua I created a file containing meta.xml: I put the 2 files into an archive bomber.zip then j'aio put in this archive C: \ Program Files \ San Andreas MTA \ server \ mods \ deathmatch \ resources Its marked as a resource has been instructed, I started, but when I want to try it on the server, it does nothing, I press b, does nothing, I made / bomber, does nothing What is the problem? Thank you Link to comment
niemi Posted January 10, 2008 Share Posted January 10, 2008 Hi,I try to take the script and the install on my server but I did not understand everything: I took the code and I save it as a bomber.lua I created a file containing meta.xml: I put the 2 files into an archive bomber.zip then j'aio put in this archive C: \ Program Files \ San Andreas MTA \ server \ mods \ deathmatch \ resources Its marked as a resource has been instructed, I started, but when I want to try it on the server, it does nothing, I press b, does nothing, I made / bomber, does nothing What is the problem? Thank you You have to add this text on server\mods\deathmatch\mtaserver.conf This: scroll the text down and there is these so add that So the text in down must look like that Link to comment
VRocker Posted January 10, 2008 Share Posted January 10, 2008 Hi,I try to take the script and the install on my server but I did not understand everything: I took the code and I save it as a bomber.lua I created a file containing meta.xml: I put the 2 files into an archive bomber.zip then j'aio put in this archive C: \ Program Files \ San Andreas MTA \ server \ mods \ deathmatch \ resources Its marked as a resource has been instructed, I started, but when I want to try it on the server, it does nothing, I press b, does nothing, I made / bomber, does nothing What is the problem? Thank you This is not a server script. its for the client. tomozj hasn't posted the server script for it. Anyway to get client scripts working, change type="server" to type="client" in your meta. But like i said, if you had it working all it would do is output stuff to the chatbox since theres no server script and it doesn't look finished Link to comment
ChrML Posted January 10, 2008 Share Posted January 10, 2008 niemi: That's to start the resource with the server. It doesn't have to be there. Just type "refresh" in the console once you've added your resource and then "start resourcename" to start it. Link to comment
tomozj Posted January 10, 2008 Author Share Posted January 10, 2008 I've fixed it now, and it works great -- thankyou again. This is a client side script, apart from the explosion part - I wanted to test out calling server events from the client. This was my first script. Here's the full thing: http://www.tomozj.com/storage/bomber.zip Note: This zip archive will not work with the MTA Server. Extract and copy the folder to your resources folder. How to use? Start the bomber resource, and press b to start. Tested with multiple people, and they all love it! Link to comment
Sky Posted January 11, 2008 Share Posted January 11, 2008 Thank you very much for your support, everything worked! I have just one last question: Is it possible to limit the blows eg 1 times in 5 minutes? Thank you Link to comment
tomozj Posted January 11, 2008 Author Share Posted January 11, 2008 Add another variable to check if they're allowed to explode, and in the keydown() function if this variable is a true value, then return an error. In the explode function (which calls the server event), you should set this variable to true, and then set a timer to set it back to untrue after 5 minutes. Link to comment
Sky Posted January 11, 2008 Share Posted January 11, 2008 function keydown() -- The key is the bomb one so we'll check whether to activate or deactivate. if ( mouseon == 0 ) then ActivateMouse() where ? Thx. Link to comment
tomozj Posted January 12, 2008 Author Share Posted January 12, 2008 Add another if statement to check that variable straight after that comment. 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