Jump to content

Scripting Tutorial 8 - Ion Cannon and Nuke (from C&C '95)


Ransom

Recommended Posts

Posted
Here you go.

Screenie.jpg

Very interesting and clever, but a screenshot of forum text is not really what i meant. Maybe I should be alittle more specific and direct: May we please see a in-game screen shot of your Ion cannon in action? Thanks :)

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

Posted

What would you like to see there? It's just a text which says smth like "Ion cannon has strike near you, you have been damaged by 87,3 hp". It's even lees realistic than CTF. Well, everything will change in MTA. :)

Posted

Thank you for repeating yourself; as if I didn't see it the first time.

See how the MTA team made one in their scripting tutorial? By saying that you made an Ion Cannon in SA-MP, actually sounds like you made one like MTA's, when in turn, you didn't. What's the significance of a text-based Ion Cannon? lol.

Posted
I just thought of an idea. It must be possible to make some kind of DBZ game-mode with this :lol:. That in combination with Low Grav could work. Just make the ION blast smaller and come out of the player's hand. Maybe I should learn scripting and put all these tutorials to good use :P

I actually made a script a while back where you could jump real high, glide on air, teleport around and shoot fireballs using key combinations (think hadooken).

Sweet! Is this script being hosted anywhere? And for which mod? I'd surely give it a go 8).

Posted

This is the best tutorial ever! I love cnc, and this has just given me an idea of cnc type battles. I hope you can make cars and tanks drive without people in them? xD

Posted
Ransom, that is really awesome, serious!

I wish I knew how to LUA Script. But it's harder than it look like.

Learn me the power how to script!

lol :oops:

Its actually pretty easy to pickup

Posted
Ransom, that is really awesome, serious!

I wish I knew how to LUA Script. But it's harder than it look like.

Learn me the power how to script!

lol :oops:

Its actually pretty easy to pickup

But it is hard to test ;)

What do you say about a earlier release :P

Posted

It's actually very hard to fin a way to test your LUA scripts, but it's easy for the peoples that know where ther scripts are going. Just like MTA their scripts go to MTASA:DM, but I consider to start scripting for Gmod :)

  • 3 weeks later...
Posted

to bad this can't be made in single gta sa.. that would be cool too, and easy for missions :P

Posted
Ransom, that is really awesome, serious!

I wish I knew how to LUA Script. But it's harder than it look like.

Learn me the power how to script!

lol :oops:

Its actually pretty easy to pickup

But it is hard to test ;)

What do you say about a earlier release :P

Hard to test? Says who?

  • 1 month later...
  • 2 weeks later...
Posted

Good tutorial :)

What would be Very nice is if functions like addEventHandler would also take an actual function reference as an argument, instead of a string with the name of the function. That way you'd be able to write compact code like:

addEventHandler("onPlayerJoin", root, function()
   outputChatBox(getClientName(source) .. " has joined the game.")
end)

Just a suggestion of course, not a disaster if it isn't going to be included. :)

(used code tags because [lua][/lua] doesn't work for some reason)

Posted
Good tutorial :)

What would be Very nice is if functions like addEventHandler would also take an actual function reference as an argument, instead of a string with the name of the function. That way you'd be able to write compact code like:

addEventHandler("onPlayerJoin", root, function()
   outputChatBox(getClientName(source) .. " has joined the game.")
end)

Just a suggestion of course, not a disaster if it isn't going to be included. :)

(used code tags because [lua][/lua] doesn't work for some reason)

I think you're right, also if we want to pass some custom arguments to the function we can't actually do that.

There is a problem like that in the pawno( :? )timers function, you cant pass arguments to the functions you use if you have to call it in a string..

Posted

At the moment you cant pass a function as an argument im afraid. It doesnt really affect things massively - it just means you have to add an extra line of code

addEventHandler("onPlayerJoin", getRootElement(), "myScriptJoin" )

function myScriptJoin()

outputChatBox(getClientName(source) .. " has joined the game.")

end

However, there is a solution to your problem. I could easilly write an alternative function - something like addEventFuncHandler which takes a function instead. it could look something similar to this:

local eventNumber = 0 
function addEventFuncHandler ( eventName, handleFor, func ) 
    local functionName = "dummyFunction"..eventNumber 
    local codeChunk = functionName.." = func" 
    loadstring(codeChunk)() 
    addEventHandler ( eventName, handleFor, functionName ) 
    eventNumber = eventNumber + 1 
end 

Basically it's assigning a random variable as a function and attaching that to the event. Alternatively, you could replace the addEventHandler as a whole

local eventNumber = 0 
local old_addEventHandler = addEventHandler 
function addEventHandler ( eventName, handleFor, func ) 
    if type(func) == "string" then 
        old_addEventHandler ( eventName, handleFor, func ) 
    elseif type(func) == "function" then     
        local functionName = "dummyFunction"..eventNumber 
        local codeChunk = functionName.." = func" 
        loadstring(codeChunk)() 
        old_addEventHandler ( eventName, handleFor, functionName ) 
        eventNumber = eventNumber + 1 
    end 
end 

Here you're defining addEventHandler as old_addEventHandler and effectively replacing it with your own function. It then checks if its a string - if it is then continue as normal, if its a function then do as above. This is entirely untested though it should work.

Also, MTA has and has always had unlimited parameters for timers.

  • 2 months later...
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...