SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 02/02/2017, 10:35 AM   #1
Loinal
Gangsta
 
Loinal's Avatar
 
Join Date: Feb 2016
Posts: 817
Reputation: 9
Default Timer

i have a problem with timer

Code:
 SetTimer("RandBotMsgs", 3000, true);
And after the timer

Code:
new bmsgTDswitch;
forward RandBotMsgs();
public RandBotMsgs()
{
	bmsgTDswitch ++;
	switch(bmsgTDswitch)
	{
		case 1:
		{
		new string[130];
		format(string,sizeof(string),"Text 1");
		TextDrawSetString(Textdraw7,string);
		}
		case 2:
		{
		Topscore();
		}
		case 3:
		{
		Topcash();
		}
  	}
  	bmsgTDswitch = 0;
	return true;
}
But it only after i spawn it show Text 1 and not changing to the next
__________________
Loinal is offline   Reply With Quote
Old 02/02/2017, 10:44 AM   #2
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,698
Reputation: 1177
Default Re: Timer

Because it keeps getting reset to 0 at the end of RandBotMsgs.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 02/02/2017, 10:56 AM   #3
Loinal
Gangsta
 
Loinal's Avatar
 
Join Date: Feb 2016
Posts: 817
Reputation: 9
Default Re: Timer

It work but not showing topcash also i want it when it reachs topcash it reset to the first textdraw
__________________
Loinal is offline   Reply With Quote
Old 02/02/2017, 11:00 AM   #4
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,698
Reputation: 1177
Default Re: Timer

Then you've to reset your bmsgTDswitch variable to zero under 3rd (or last) case. Post your Topcash() function here if it's not working.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 02/02/2017, 06:56 PM   #5
Loinal
Gangsta
 
Loinal's Avatar
 
Join Date: Feb 2016
Posts: 817
Reputation: 9
Default Re: Timer

Ok it works also got onther thing

PHP Code:
stock Topscore()
{
    
mysql_tquery(mysql ,"SELECT Username,Score FROM players WHERE ID ORDER BY Score DESC LIMIT 1;""ShowBestScore","");
    return 
true;
}
forward ShowBestScore();
public 
ShowBestScore()
{
      new 
rows;
    
cache_get_row_count(rows);
    if(
rows)
    {
        new 
playername[35];
        new 
playerscore;
        new 
str[1303];
        
        
cache_get_value_index(00playername);
        
cache_get_value_name_int(0,"Score",playerscore);
        
cache_get_value_index_int(0,1playerscore);

        
format(strsizeof(str), "News: Player with the most score is~g~~h~ %s~w~ have (~r~~h~%d score~w~)~n~~n~"playernameplayerscore);
        
TextDrawSetString(Textdraw7,str);
        
TextDrawShowForAll(Textdraw7);
    }
    return 
1;
}
stock Topcash()
{
    
mysql_tquery(mysql ,"SELECT Username,Money FROM players WHERE ID ORDER BY Money LIMIT 1;""ShowBestCash","");
    return 
true;
}
forward ShowBestCash();
public 
ShowBestCash()
{
      new 
rows;
    
cache_get_row_count(rows);
    if(
rows)
    {
        new 
playername[35];
        new 
playermoney;
        new 
str[1303];

        
cache_get_value_index(00playername);
        
cache_get_value_name_int(0,"Money",playermoney);
        
cache_get_value_index_int(0,1playermoney);

        
format(strsizeof(str), "News:~g~~h~ %s~w~ Is the reachest player (~r~~h~%d cash~w~)~n~~n~"playernameplayermoney);
        
TextDrawSetString(Textdraw7,str);
        
TextDrawShowForAll(Textdraw7);
    }
    return 
1;

If i changed my cash or my score to onther thing it doesn't change
__________________
Loinal is offline   Reply With Quote
Old 02/02/2017, 10:04 PM   #6
Loinal
Gangsta
 
Loinal's Avatar
 
Join Date: Feb 2016
Posts: 817
Reputation: 9
Default Re: Timer

Help?
__________________
Loinal is offline   Reply With Quote
Old 02/02/2017, 10:29 PM   #7
ranme15
Big Clucker
 
ranme15's Avatar
 
Join Date: Aug 2010
Posts: 178
Reputation: 3
Default Re: Timer

You should mysql-update your money/cash when you do so.
__________________
INACTIVE
ranme15 is offline   Reply With Quote
Old 03/02/2017, 10:37 AM   #8
Loinal
Gangsta
 
Loinal's Avatar
 
Join Date: Feb 2016
Posts: 817
Reputation: 9
Default Re: Timer

Thanks
__________________
Loinal 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
Performance Question , Per Player Timer vs Timer that loops through all players BiosMarcel Scripting Help 14 12/12/2016 09:50 AM
If /foodsearch doesn't find item, set wait timer (TIMER HELP) Josh_Main Scripting Help 7 14/09/2016 04:13 PM
Which is better Per Player Timer or Global timer? (issue with timer) Dokins Scripting Help 4 07/06/2016 09:50 AM
Slice's Timer Fix include --> timer public function isn't getting called Riwerry Scripting Help 0 02/01/2016 03:50 PM
[Timer Help] Score saving timer, should it always be running or should it be killed? Ghost100 Scripting Help 6 08/10/2012 10:12 PM


All times are GMT. The time now is 02:52 PM.


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