Jump to content

Tutorial for beginners


daftagg

Recommended Posts

Posted (edited)

Are there tutorials for totally beginners that just started scripting?

look at this crappy 25+ errors script i made, i dont even know what im doing myself

i probably only understanded 2% of the introduction of scripting

-- crappy 25 error+ rpg script

players = getElementsByType ( "player" )

root = getRootElement ()

function spawnPlayer (thePlayer)

local playerSpawnPoint = WHAT SHOULD I PUT HERE

fadeCamera ( source, true )

givePlayerMoney ( player thePlayer, 10000 amount )

end

function onPlayerKill (thePlayer)

playersname= getClientName(source)

outputChatBox("zomfgz bitchass you just killed someone you stupid f***face dmer/cheater your going to be banned!(or you get spawned 10 minutes later)", source)

KillPlayer(source)

setTimer(spawnPlayer, 600000, 1, source)

end

addEventHandler("onPlayerKill", root, onPlayerKill)

function onPlayerJoin ()

playerName = getClientName(source)

outputChatBox("welcome, " .. playerName .. ", you have been given 10000 for joining this server, and DON'T DM because its a RPG server, thank you.", source)

spawnPlayer(source)

end

addEventHandler("onPlayerJoin", root, onPlayerJoin)

function onPlayerDeath ()

outputChatBox("You died! Please wait 10 seconds to respawn", source)

setTimer(spawnPlayer, 10000, 1, source)

end

addEventHandler("onPlayerWasted", root, onPlayerDeath)

what does root mean?

what does (source) mean?

Edited by Guest
Posted

Root is the element that is the parent of all the elements on the server. If you do something with the root, it'll get done to all the players/vehicles/obects etc.. on the server.

Source inside event handlers is the element that an event was triggered on. For example in onPlayerJoin, onPlayerQuit and other onPlayer* events the source is the player.

Posted

Hey Frank, I need the same thing, a tutorial or at least a hint where to start learning......

I only know VB.net and it seems to completely different to this!

Posted

That's not creepy it's fairly easy... If you read it properly, don't just copy and paste it but try to write it yourself again without looking at the wiki, and trying to understand what's written there about all different functions, you'll get to know it pretty fast. Then again, if you can't understand that, coding/scripting might not be the thing for you.. take a look at this LUA Manual too tho: http://www.lua.org/manual/5.0/

Posted

The Scripting Introduction introduces into Lua Scripting for MTA, not Lua Scrpting in general. You still need to know how to code first.

Posted

I believe this is what the MTA wiki is supposed to be for? I'm sure the team will create tutorials for beginners, and if not there is always experts scattered around to help. ;)

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