Scripting Tutorial 2 - MTA Snow

All Lua scripting topics related to Multi Theft Auto.

Moderators: Moderators, MTA team

Scripting Tutorial 2 - MTA Snow

Postby ijsf on Mon Jan 22, 2007 8:04 am

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

Following last week's scripting tutorials on user created portals, we've just published a new tutorial covering MTA Snow.

The tutorial shows you how to create special entities, how to make them look and fall like snow.. with some imagination of course.

Head over to the Tutorials section to see!
Developer of Multi Theft Auto.

* Music: http://bastage.student.utwente.nl/music/.
* Project blog: http://solid.student.utwente.nl/.
ijsf
The MTA Team
 
Posts: 893
Joined: Thu Mar 13, 2003 10:54 am
Location: EU, Netherlands

Postby Sprinter on Mon Jan 22, 2007 9:32 am

Don't know if it's just me but I can't see all of the script text.
Screenie:

Image

I'm using FF btw.
Sprinter
Regular
 
Posts: 221
Joined: Sun Mar 12, 2006 1:04 pm
Location: Sweden

Postby driver2 on Mon Jan 22, 2007 10:07 am

You should probably use a newline for comments, like it was last time. I'm sure it will be fixed soon.

Nice tutorial by the way. Not quite what I expected, but it shows once again the power of Lua and MTA.

.edit.
The link to the complete script results in a 404. :(
driver2
Regular
 
Posts: 134
Joined: Thu Feb 16, 2006 8:31 am

Postby Ivan(SCG) on Mon Jan 22, 2007 10:32 am

Sprinter wrote:Don't know if it's just me but I can't see all of the script text....


I use opera and when I get sucha problem I go to Tools/Preferences/Web Pages/Fit to width.... i dont know which browser u use, but try something like that
User avatar
Ivan(SCG)
Regular
 
Posts: 110
Joined: Fri Mar 17, 2006 6:09 am
Location: Belgrade, Serbia

Postby Talco on Mon Jan 22, 2007 11:19 am

Good tutorial, but...
the link for the complete script dont work (not found) http://www.mtasa.com/downloads/script2.lua
User avatar
Talco
New User
 
Posts: 27
Joined: Sun Jun 11, 2006 3:57 pm
Location: Italy

Postby kevuwk on Mon Jan 22, 2007 11:23 am

driver2 wrote:You should probably use a newline for comments, like it was last time. I'm sure it will be fixed soon.

Nice tutorial by the way. Not quite what I expected, but it shows once again the power of Lua and MTA.


i think this tutorial was to show the object manipulation which you will have also seen with the hay bails in the xmas vid
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 iam2noob4u on Mon Jan 22, 2007 11:44 am

Talco is right, downloading the scripts give me a "404 - Not Found" error.

Also, for viewing the comments: you cannot see them, but they are copied when you select the whole page :).

Lol will this work?:

[lua]addCommandHandler ( "teleport", "tele_TeleCommand" )

function tele_TeleCommand ( player, commandname, x, y, z )
outputChatBox ( getClientName ( player ) .. " was teleported." ) --Thx eAi for telling me about the space :)
setElementPosition ( player, x, y, z )
end[/lua] Probably not but at least I tried to make something. :)

Also about the outputChatBox function, can i make the text I put in the chatbox purple or red (or wutever color)?
Last edited by iam2noob4u on Mon Jan 22, 2007 1:47 pm, edited 4 times in total.
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 eAi on Mon Jan 22, 2007 12:59 pm

Yes, that looks like it'll work, except you'll want a space before 'was', i.e. " was teleported".

As for colors, yes, you can use them, just by adding the RGB value as arguments. The full definition for outputChatBox is:

[lua]bool outputChatBox ( string text, [ element visibleTo=getRootElement(), int r=255, int g=255, int b=255 ] )[/lua]
eAi
The MTA Team
 
Posts: 2457
Joined: Thu May 08, 2003 12:25 pm

Postby Y_Less on Mon Jan 22, 2007 1:20 pm

How much bandwidth does this thing use as repeatedly setting a load of entities positions for loads of players can't be great. Also, wouldn't:

if not px or not py or not pz then
snowing = false
return

stop the snow if the player was on one of the axis? I.e. stood right in the middle of the world where X and Y would be 0.0, thus evaluating to false?
Y_Less
 

Postby iam2noob4u on Mon Jan 22, 2007 1:32 pm

unless lua knows/sees the diffrence between 0 and 0.0000000 i think you're right. besides, if my teleport 'script' (rather to be called a very small code) will work with the first release, you could try it, and teleport to any position with either x, y, or z as 0

also the correct usage of outputChatBox would be:

[lua]outputChatBox ( getClientName ( player ) .. " was teleported." , 255 , 43 , 43)[/lua]

right?

btw sorry for asking so much time that could be spend on development :P
Last edited by iam2noob4u on Mon Jan 22, 2007 1:48 pm, edited 1 time in total.
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 lil Toady on Mon Jan 22, 2007 1:46 pm

color is not required, if it's not set, mta uses default color

here:
bool outputChatBox ( string text, [ element visibleTo=getRootElement(), int r=255, int g=255, int b=255 ] )


all the stuff in [] brackets is not required
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 iam2noob4u on Mon Jan 22, 2007 1:49 pm

i meant: "if i use colors, this is the right way to use it"

i should have been clearer.
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 Brophy on Mon Jan 22, 2007 1:53 pm

[lua]-- outputChatBox ( "What you wanna say", visibleto, r, g, b )

-- Example

root = getRootElement ()
outputChatBox ( "Sniff me!", root, 255, 80, 60 ) [/lua]
User avatar
Brophy
Super Moderator
 
Posts: 2885
Joined: Sun Oct 05, 2003 1:50 pm
Location: England, UK
Gang: VCES / SAES

Postby bloodeye on Mon Jan 22, 2007 2:07 pm

Sorry i know its not a 'script' question, but what music was that?
User avatar
bloodeye
Regular
 
Posts: 157
Joined: Fri Apr 22, 2005 7:45 pm
Location: England - Wiltshire

Postby erorr404 on Mon Jan 22, 2007 3:39 pm

Y_Less wrote:How much bandwidth does this thing use as repeatedly setting a load of entities positions for loads of players can't be great. Also, wouldn't:

if not px or not py or not pz then
snowing = false
return

stop the snow if the player was on one of the axis? I.e. stood right in the middle of the world where X and Y would be 0.0, thus evaluating to false?

No, it would only be false if one of the values were either false or nil.
erorr404
Super Moderator
 
Posts: 2052
Joined: Sun Jun 13, 2004 11:28 pm
Location: San Fierro, SA

Next

Return to Scripting

Who is online

Users browsing this forum: 50p and 0 guests