norby89 Posted January 8, 2008 Share Posted January 8, 2008 the ones on the main page are a bit outdated, you can download the up to date versions here, in case you're wondering where's #4 and #9, well one is hay which is included in dp1 and the other was take down from the site PS) I gave them a quick try, they seem to be working though I can't guarantee that they work 100% fine, if you spot any errors please post them here Link to comment
bossyboy Posted January 9, 2008 Share Posted January 9, 2008 Awesome thanks a lot for these . Link to comment
Loren_ita Posted June 5, 2008 Share Posted June 5, 2008 Very Very Very Very Very Nice! Thanks Link to comment
XetaQuake Posted October 2, 2008 Share Posted October 2, 2008 Hi, i have a question: The Snow are don´t want to fall down, there stay in the air but get updated positions and so on - only the z-axis don´t changes. I tries already a little bit to repair it - but nothing happens. Also i have to remember that the snow are server side, and the functions gets launches many many times in one second - can that be good for the latency? i think it would be better to script it Client-side. What do you think? But the main question is why the flakes doesn't fall down. PS: Its script2_lua.lua in the rar archive XetaQuake Link to comment
XetaQuake Posted October 5, 2008 Share Posted October 5, 2008 Sorry for this new Post, but the snow script in script2_lua.lua does not work correctly: The Snow flakes doesn't fall down, there stay in the air. I also tries some kinds, but for my eyes, everything is right. Here is the script, so you don´t need to download it: snowflake = {} --This initializes the snowflake IDs table flakeID = 1 --This sets the first flake ID as 1 updaterate = 27 --Positions' update rate in miliseconds height = 4 --Snowflakes starting position above the player's head snowing = false --This is a variable that tells the script whether it is snowing or not. function snow_SnowCommand ( player, commandname, radius, density, speed, size ) --You can pass radius, density, speed and flake size parameters in the command if not snowing then --check the 'snowing' variable and check if it is true. If it is not then it is not snowing snowing = true --set the snowing variable to true snow_CreateSnow ( player, radius, density, speed, size ) --call the snow_CreateSnow function to create our snow! outputChatBox ( "Snow started by " .. getClientName ( player ) ) --announce that snowing was started. else snowing = false --set the snowing variable to false outputChatBox ( "Snow stopped." ) --announce the snowing has stopped end end addCommandHandler ( "snow", snow_SnowCommand ) --This assigns the snow_SnowCommand function to the "snow" command in console function snow_CreateSnow ( player, radius, density, speed, size ) local px, py, pz = getElementPosition ( player ) --If player is invalid or has disconnected, stop the function if not px or not py or not pz then snowing = false return end --If any parameter is not set, the script will give it a default value if not radius then radius = 20 else radius = tonumber ( radius ) end if not density then density = 3 else density = math.ceil ( tonumber ( density ) ) end --density should be an integer (flakes/second) if not speed then speed = 1.5 else speed = math.abs ( tonumber ( speed ) ) end --speed should only be positive (units/second) if not size then size = 0.15 else size = tonumber ( size ) end local counter = 0 --We will repeat the flake creating process one time per flake while counter <= density do --For x and y, we will calculate a random position around the player, within the maximum radius circle. local angle = randInt ( 0, 359 ) local fx = px + math.cos ( math.rad ( angle ) ) * radius * randFloat () local fy = py + math.sin ( math.rad ( angle ) ) * radius * randFloat () --z is just the player's height, plus the height we set before. local fz = pz + height snowflake[flakeID] = createMarker ( fx, fy, fz, "corona", size, 255, 255, 255, 150 ) --We calculate the time it takes for a flake to fall, in miliseconds local time = 1000 * ( height + 1 ) / speed --We tell the script to update the flake as many times as needed, and store the timer ID in a variable setTimer ( snow_moveFlake, updaterate, math.floor ( time / updaterate ), flakeID, speed ) --moveObject ( snowflake[flakeID], time, fx, fy, pz ) --We set a timer to destroy the flake when the time has passed setTimer ( snow_destroyFlake, time, 1, flakeID ) flakeID = flakeID + 1 counter = counter + 1 end --Repeat this function again in a second, if snow is still on if snowing then setTimer ( snow_CreateSnow, 1000, 1, player, radius, density, speed, size ) end end function snow_moveFlake ( flakeID, speed ) local fx, fy, fz = getElementPosition ( snowflake[flakeID] ) setElementPosition ( snowflake[flakeID], fx, fy, fz - ( updaterate / 1000 * speed ) ) end function snow_destroyFlake ( flakeID ) destroyElement ( snowflake[flakeID] ) snowflake[flakeID] = nil end Can anybody help me? Link to comment
tma Posted October 5, 2008 Share Posted October 5, 2008 To get it to run I had to do two things: updaterate = 57 --Positions' update rate in miliseconds The previous rate of 27 seemed to not work at all - maybe the min interval for timers has changed over the lifetime of MTA ? Also: function snow_moveFlake ( flakeID, speed ) if isElement(snowflake[flakeID]) then local fx, fy, fz = getElementPosition ( snowflake[flakeID] ) setElementPosition ( snowflake[flakeID], fx, fy, fz - ( updaterate / 1000 * speed ) ) end end Without the isElement() check it seems to barf - maybe it's to do with my time interval change. Anyhow, I really wouldn't use this script unless you make it client side. As it is, the server will be handling potentially hundreds of flakes and updating them multiple times per second. Link to comment
SpZ Posted October 5, 2008 Share Posted October 5, 2008 Minimum interval value for timers is 50 ms. Link to comment
norby89 Posted October 5, 2008 Author Share Posted October 5, 2008 the snow script was created when there was no client side script support, so it's not something you'd want to run on your server unless you make it client side Link to comment
Ace_Gambit Posted October 5, 2008 Share Posted October 5, 2008 the snow script was created when there was no client side script support, so it's not something you'd want to run on your server unless you make it client side LOL. You are trying to say that there was no client script support prior to DP2 ? I wouldn't know because I came back from my internship and found out the DP version was up 2 already . Link to comment
50p Posted October 5, 2008 Share Posted October 5, 2008 the snow script was created when there was no client side script support, so it's not something you'd want to run on your server unless you make it client side LOL. You are trying to say that there was no client script support prior to DP2 ? I wouldn't know because I came back from my internship and found out the DP version was up 2 already . In DP1 there was support for client scripts (gamemodes like Stealth use GUI). This script was written before any public releases. Link to comment
XetaQuake Posted October 5, 2008 Share Posted October 5, 2008 well currently i see that createMarker works client side too I thought its only server side Hmm, now the question is how its possible to change the script to client side, for my eyes its should work client side too? Link to comment
norby89 Posted October 10, 2008 Author Share Posted October 10, 2008 In DP1 there was support for client scripts (gamemodes like Stealth use GUI). This script was written before any public releases. indeed, it was one of the first tutorials on the site @ xetaQuake: probably the best way would be to rewrite the whole script, you don't even need timers or all those calculations, it can be done a whole lot easier using onClientRender() Link to comment
Guest Posted November 15, 2008 Share Posted November 15, 2008 Thoses are some good tuts, theres some more that could be added but thats for you to know Link to comment
Thehookerkiller01 Posted May 12, 2009 Share Posted May 12, 2009 What about changing .rar file in .zip file,, because I can't open it Link to comment
Thehookerkiller01 Posted May 18, 2009 Share Posted May 18, 2009 Can't install winrar on school ;p Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now