SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 17/07/2015, 04:54 PM   #1
hamzajaved780
Big Clucker
 
hamzajaved780's Avatar
 
Join Date: Jan 2015
Location: Karachi
Posts: 144
Reputation: 14
Default SAMP Clock

SAMP Clock

Not my first piece of code, but first public release. Its very simple and took me just 10 mins. Hope you like it



Download Link:
http://pastebin.com/iPZ62fVk
__________________
hamzajaved780 is offline   Reply With Quote
Old 17/07/2015, 08:52 PM   #2
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: SAMP Clock

Quote:
Originally Posted by WASD View Post
Why timer = 6 sec?
And this:
PHP Code:
        TextDrawShowForPlayer(playeridClock[0]);
        
TextDrawShowForPlayer(playeridClock[1]); 
PHP Code:
    for(new 0MAX_PLAYERSi++)
    {
                
TextDrawHideForPlayer(iClock[0]);
                
TextDrawHideForPlayer(iClock[1]);
                
TextDrawShowForPlayer(iClock[0]);
                
TextDrawShowForPlayer(iClock[1]);
    } 
Change to:
PHP Code:
for(new t!= 2t++) TextDrawShowForPlayer(playeridClock[t]); 
PHP Code:
    for(new 0MAX_PLAYERSi++)
    {
                for(new 
t!= 2t++) TextDrawHideForPlayer(iClock[t]),TextDrawShowForPlayer(iClock[t]);
    } 
1. Don't force him to do anything, his version is fine and faster than yours.
2. Are you really still using MAX_PLAYERS as a loop's upper bound? It's 2015, use GetPlayerPoolSize.
3. Using commas to continue a statement is supposed to only work in returns, but either way it is bad coding practice. In fact, I think Y-Less says something about it in a comment on his old Code Optimisations thread.
Crayder is offline   Reply With Quote
Old 17/07/2015, 09:01 PM   #3
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,761
Reputation: 754
Default Re: SAMP Clock

Quote:
Originally Posted by WASD View Post
Why timer = 6 sec?
And this:
PHP Code:
        TextDrawShowForPlayer(playeridClock[0]);
        
TextDrawShowForPlayer(playeridClock[1]); 
PHP Code:
    for(new 0MAX_PLAYERSi++)
    {
                
TextDrawHideForPlayer(iClock[0]);
                
TextDrawHideForPlayer(iClock[1]);
                
TextDrawShowForPlayer(iClock[0]);
                
TextDrawShowForPlayer(iClock[1]);
    } 
Change to:
PHP Code:
for(new t!= 2t++) TextDrawShowForPlayer(playeridClock[t]); 
PHP Code:
    for(new 0MAX_PLAYERSi++)
    {
                for(new 
t!= 2t++) TextDrawHideForPlayer(iClock[t]),TextDrawShowForPlayer(iClock[t]);
    } 
You should avoid using loops for such matters (hiding/showing textdraws), they are actually slower than allotting them internally.

Want proof?

1 variable alternated 50,000 times in two different manners.



SickAttack is offline   Reply With Quote
Old 18/07/2015, 04:06 AM   #4
hamzajaved780
Big Clucker
 
hamzajaved780's Avatar
 
Join Date: Jan 2015
Location: Karachi
Posts: 144
Reputation: 14
Default Re: SAMP Clock

Quote:
Originally Posted by Crayder View Post
1. Don't force him to do anything, his version is fine and faster than yours.
2. Are you really still using MAX_PLAYERS as a loop's upper bound? It's 2015, use GetPlayerPoolSize.
3. Using commas to continue a statement is supposed to only work in returns, but either way it is bad coding practice. In fact, I think Y-Less says something about it in a comment on his old Code Optimisations thread.
Sorry about the max player thing, I personally use foreach so I forgot about that. About the third point can you give an example. I will be very thankful.
__________________
hamzajaved780 is offline   Reply With Quote
Old 18/07/2015, 04:09 AM   #5
hamzajaved780
Big Clucker
 
hamzajaved780's Avatar
 
Join Date: Jan 2015
Location: Karachi
Posts: 144
Reputation: 14
Default Re: SAMP Clock

Quote:
Originally Posted by SickAttack View Post
You should avoid using loops for such matters (hiding/showing textdraws), they are actually slower than allotting them internally.

Want proof?

1 variable alternated 50,000 times in two different manners.



You are right it is faster to execute plain code than loops.
__________________
hamzajaved780 is offline   Reply With Quote
Old 19/07/2015, 06:21 AM   #6
Kursed
Huge Clucker
 
Kursed's Avatar
 
Join Date: Jan 2015
Posts: 235
Reputation: 35
Default Re: SAMP Clock

Keep up the great work I say!
__________________

Founder of Darkside: Darkside - 144.217.19.104:7777 ©
Kursed is offline   Reply With Quote
Old 19/07/2015, 03:41 PM   #7
Blacky4Life
Little Clucker
 
Blacky4Life's Avatar
 
Join Date: Apr 2015
Location: Japan
Posts: 34
Reputation: 11
Default Re: SAMP Clock

Great work!
__________________
Blacky4Life is offline   Reply With Quote
Old 19/07/2015, 04:01 PM   #8
dionisak0s
Huge Clucker
 
dionisak0s's Avatar
 
Join Date: May 2013
Location: Greece
Posts: 252
Reputation: 46
Default Re: SAMP Clock

Quote:
Originally Posted by SickAttack View Post
You should avoid using loops for such matters (hiding/showing textdraws), they are actually slower than allotting them internally.

Want proof?

1 variable alternated 50,000 times in two different manners.



I see that you have a very beautiful PAWN Editor there, mind if you share it with us?
dionisak0s is offline   Reply With Quote
Old 19/07/2015, 08:03 PM   #9
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: SAMP Clock

Quote:
Originally Posted by dionisak0s View Post
I see that you have a very beautiful PAWN Editor there, mind if you share it with us?
Are you serious, you've never heard of Sublime Text?
Crayder is offline   Reply With Quote
Old 20/07/2015, 12:21 PM   #10
BladeFire
Big Clucker
 
Join Date: Jul 2015
Posts: 61
Reputation: 7
Default Re: SAMP Clock

Nice
BladeFire is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clock Fernado Samuel Scripting Help 4 27/02/2013 10:49 AM
[FilterScript] Normal San Andreas Clock For Samp Narimalla Filterscripts 16 28/01/2012 02:19 PM
[FilterScript] Clock 0.1 Jorge_Hard Filterscripts 29 16/05/2011 01:27 AM
[FilterScript] [FS]LuX TDC! (The Digital Clock) (Realistic and advanced clock) LuxurioN™ Filterscripts 50 02/02/2011 02:07 PM
It's about gta samp's clock: Read please blackwave Help Archive 3 07/11/2010 02:44 PM


All times are GMT. The time now is 08:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.