Jump to content

Bomber script -- press b and click to explode


tomozj

Recommended Posts

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 by Guest
Link to comment

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

Link to comment

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

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

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

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

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

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