Scripting Tutorial 4 - Hay

All Lua scripting topics related to Multi Theft Auto.

Moderators: Moderators, MTA team

Scripting Tutorial 4 - Hay

Postby kevuwk on Mon Feb 05, 2007 2:28 pm

NOTICE: THIS TUTORIAL MAY BE OUTDATED! PLEASE READ: http://forum.mtasa.com/viewtopic.php?f=91&t=22270

This is our respond thread for our fourth weekly scripting tutorial.

You can respond to the tutorial here if you have any questions, etc.

Here's the link to the first tutorial: Scripting Tutorial IV - Hay
Kevuwk
Image
Image
Any comments made are purely my own and do not represent the interests of the MTA Team
kevuwk
The MTA Team
 
Posts: 433
Joined: Wed May 04, 2005 5:08 pm
Location: UK

Postby jhxp on Mon Feb 05, 2007 3:40 pm

Technical problems sorted. Enjoy.
One of the [VCP] leaders // honorary member of =PCP=
Image Image
User avatar
jhxp
Super Moderator
 
Posts: 1368
Joined: Mon Jan 26, 2004 6:51 am
Location: Poland
Gang: VCP/PCP

Postby iam2noob4u on Mon Feb 05, 2007 4:05 pm

Thats very cool... the script looks a bit more complicated compared to the others, so I'll read it through tommorow...

The movie is great, it shows a lot more then the Christmas movie did.

50 Levels:
<Name> (a/b) x%


Is added by the script and shows how far you [and others] are right?
I should probably put something more interesting here... but... who cares anyway?
iam2noob4u
Regular
 
Posts: 189
Joined: Mon Mar 13, 2006 1:41 pm
Location: Purmerend, The Netherlands.

Postby [TDH]Boss on Mon Feb 05, 2007 4:06 pm

You forgot to include .lua file, some headers and links in the tutorial itself. Check it out and compare with previous ones.
Image
Image
User avatar
[TDH]Boss
Regular
 
Posts: 122
Joined: Sun Jan 21, 2007 3:51 am
Location: Russia, Moscow
Gang: Team Dies Hard

Postby Michilus_nimbus on Mon Feb 05, 2007 5:25 pm

Pure freakin genious.
Lovely how such a simple source file can produce a stunning gamemode like that.
Umbrellas are like humans: you use them when it rains.

When you play a Windows 95 CD backwards, you hear a message from the devil. Even worse, if you just play it, it installs Windows 95.
Michilus_nimbus
New User
 
Posts: 10
Joined: Fri Jun 18, 2004 3:40 pm
Location: Belgium

Postby Phat Looser on Mon Feb 05, 2007 6:47 pm

iam2noob4u wrote:Thats very cool... the script looks a bit more complicated compared to the others, so I'll read it through tommorow...

The movie is great, it shows a lot more then the Christmas movie did.

50 Levels:
<Name> (a/b) x%


Is added by the script and shows how far you [and others] are right?

Looks like it, yes.
User avatar
Phat Looser
Regular
 
Posts: 244
Joined: Wed Dec 31, 2003 10:47 am

Postby erorr404 on Mon Feb 05, 2007 8:57 pm

iam2noob4u wrote:Thats very cool... the script looks a bit more complicated compared to the others, so I'll read it through tommorow...

The movie is great, it shows a lot more then the Christmas movie did.

50 Levels:
<Name> (a/b) x%


Is added by the script and shows how far you [and others] are right?

It shows your name and health.
erorr404
Super Moderator
 
Posts: 2052
Joined: Sun Jun 13, 2004 11:28 pm
Location: San Fierro, SA

Postby Hedning on Tue Feb 06, 2007 12:42 am

Nice
User avatar
Hedning
Experienced
 
Posts: 501
Joined: Sun Apr 23, 2006 1:05 pm
Location: Sweden

Postby [TDH]Boss on Tue Feb 06, 2007 2:32 am

1) When a player joins, would the current hay bails be cynced for him?
2) If any rock falls and destroys every hay bail below, would all the players still be able to climb to the top?
3) I have also noticed, that someone's nick was cut as it was too long. IS there any way to avoid it and if yes, why wasn't it made in the video?
4) Is there any way to manage text outputs, like moving them to any point on the screen, changing styles, fonts, sizes etc? If yes, could you please give a sample of the needed function?
Image
Image
User avatar
[TDH]Boss
Regular
 
Posts: 122
Joined: Sun Jan 21, 2007 3:51 am
Location: Russia, Moscow
Gang: Team Dies Hard

Postby lil Toady on Tue Feb 06, 2007 4:58 am

[TDH]Boss wrote:1) When a player joins, would the current hay bails be cynced for him?
2) If any rock falls and destroys every hay bail below, would all the players still be able to climb to the top?
3) I have also noticed, that someone's nick was cut as it was too long. IS there any way to avoid it and if yes, why wasn't it made in the video?
4) Is there any way to manage text outputs, like moving them to any point on the screen, changing styles, fonts, sizes etc? If yes, could you please give a sample of the needed function?


1) Yes it will be synced for everyone
2) I'm not sure about this
3/4) Those text displays were made by scripting and you can change their position, size, color etc. It was probably not changed in the video cause of lazy scripter :P
[lua]textCreateTextItem ( string text, float x, float y, priority, R, G, B, Alpha, Scale )

--This will display "hello" in the center of player's screen
textDisplay = textCreateDisplay ()
textItem = textCreateTextItem ( "hello", 0.5, 0.5, 1, 0, 0, 255, 255, 3 )
textDisplayAddText ( textDisplay, textItem )
textDisplayAddObserver ( textDisplay, myPlayer ) --Display it for myPlayer only[/lua]
Image
Do not PM me or bant! I won't reply anyway.
User avatar
lil Toady
The MTA Team
 
Posts: 1813
Joined: Sun Apr 24, 2005 8:07 pm
Location: Russia, Moscow
Gang: Full Metal Jacket

Postby Brophy on Tue Feb 06, 2007 9:08 am

erorr404 wrote:
iam2noob4u wrote:Thats very cool... the script looks a bit more complicated compared to the others, so I'll read it through tommorow...

The movie is great, it shows a lot more then the Christmas movie did.

50 Levels:
<Name> (a/b) x%


Is added by the script and shows how far you [and others] are right?

It shows your name and health.


erm, doesnt it show name and how far up you are / furthest you have gone
User avatar
Brophy
Super Moderator
 
Posts: 2885
Joined: Sun Oct 05, 2003 1:50 pm
Location: England, UK
Gang: VCES / SAES

Postby So'lide on Tue Feb 06, 2007 9:11 am

Name, player's current level, player's highest level and hp in %.
User avatar
So'lide
Off. Pie Addict
 
Posts: 521
Joined: Wed Oct 20, 2004 6:16 am
Location: Pirate ship, sailing around the thousand lakes of Finland

Postby [TDH]Boss on Tue Feb 06, 2007 9:18 am

textCreateTextItem ( string text, float x, float y, priority, R, G, B, Alpha, Scale )


As far as I understand, "priority" gives the ability to show one text above the other.
But where is the parameter for changing font?
Image
Image
User avatar
[TDH]Boss
Regular
 
Posts: 122
Joined: Sun Jan 21, 2007 3:51 am
Location: Russia, Moscow
Gang: Team Dies Hard

Postby BTH on Tue Feb 06, 2007 9:42 am

Whats the point of this? [lua]function copyTable ( src, des )
for k,v in pairs(src) do
if (type(v) == "table") then
des[k] = {}
copyTable(src[k],des[k])
else
des[k] = v
end
end
end[/lua]
User avatar
BTH
Regular
 
Posts: 103
Joined: Mon Aug 22, 2005 9:36 pm
Location: 127.0.0.1

Postby Aeron on Tue Feb 06, 2007 10:19 am

[TDH]Boss wrote:1) When a player joins, would the current hay bails be cynced for him?
2) If any rock falls and destroys every hay bail below, would all the players still be able to climb to the top?
3) I have also noticed, that someone's nick was cut as it was too long. IS there any way to avoid it and if yes, why wasn't it made in the video?
4) Is there any way to manage text outputs, like moving them to any point on the screen, changing styles, fonts, sizes etc? If yes, could you please give a sample of the needed function?


1. Yes
2. If a bail is 'destroyed' it 'respawns' the next time that bail moves. (Quite nasty :))
3. Don't pick long names
4. Script is editble.

[TDH]Boss wrote:
textCreateTextItem ( string text, float x, float y, priority, R, G, B, Alpha, Scale )


As far as I understand, "priority" gives the ability to show one text above the other.
But where is the parameter for changing font?


Font changing isn't possible. Priority stands for how quick the text in the display must be updated on a change.

BTH wrote:Whats the point of this? [lua]function copyTable ( src, des )
for k,v in pairs(src) do
if (type(v) == "table") then
des[k] = {}
copyTable(src[k],des[k])
else
des[k] = v
end
end
end[/lua]


The script makes a copy of the current matrix, fills in the player positions then checks bail movement, at the next check we don't want the players position of the previous check in the matrix, thats why the copy and that functions copies the matrix.
Last edited by Aeron on Tue Feb 06, 2007 10:24 am, edited 1 time in total.
"Never argue with an idiot. They bring you down to their level and beat you with experience."
"Arguing on the internet is like the Special Olympics. Even if you win, you're still retarded."
Image
Image
User avatar
Aeron
Off. MTA Supporter
 
Posts: 1067
Joined: Thu Sep 18, 2003 1:30 am
Location: getClientIP( getPlayerFromNick( "Aeron" ) )

Next

Return to Scripting

Who is online

Users browsing this forum: 50p and 0 guests