SA-MP Forums Archive
Textdraw update help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Textdraw update help (/showthread.php?tid=601009)



Textdraw update help - Hellman92 - 15.02.2016

Trying do make textdraw update every second but won't do it.


Gamemodeint
Код:
SetTimer("UpdateMapTimer", 1000, 1);
PHP код:
public UpdateMapTimer()
{
    foreach (
Playeri)
    {
        
TextDrawShowForPlayer(iMapdraw0);
     }
     return 
1;




Re: Textdraw update help - Lowsamp98 - 15.02.2016

Try:
PHP код:
public UpdateMapTimer() 

    foreach (
Playeri
    { 
        
TextDrawHideForPlayer(iMapdraw0); 
        
TextDrawShowForPlayer(iMapdraw0); 
     } 
     return 
1




Re: Textdraw update help - thewildlima - 15.02.2016

Why don't you make a global boolean variable and make function like this:

PHP код:
new bool:mapTextDrawShowing[MAX_PLAYERS]; // On top
public UpdateMapTimer()
{
    foreach (
Playeri)
    {
        if(
mapTextDrawShowing[i])
            
// Set Map Showing Variable to: FALSE
            
mapTextDrawShowing[i] = false;
            
            
// Return Hide Function
            
return TextDrawHideForPlayer(iMapdraw0);
        } else {
            
// Set Map Showing Variable to: TRUE
            
mapTextDrawShowing[i] = true;
        
            
// Return Show Function
            
return TextDrawShowForPlayer(iMapdraw0);
        }
     }
     return 
1;


Quote:
Originally Posted by Hellman92
Посмотреть сообщение
Trying do make textdraw update every second but won't do it.


Gamemodeint
Код:
SetTimer("UpdateMapTimer", 1000, 1);
PHP код:
public UpdateMapTimer()
{
    foreach (
Playeri)
    {
        
TextDrawShowForPlayer(iMapdraw0);
     }
     return 
1;




Re: Textdraw update help - Danx - 16.02.2016

Quote:
Originally Posted by Hellman92
Посмотреть сообщение
Trying do make textdraw update every second but won't do it.


PHP код:
public UpdateMapTimer()
{
    foreach (
Playeri)
    {
        
TextDrawShowForPlayer(iMapdraw0);
     }
     return 
1;

What do you want exactly?

Your first code will show only the textdraw in every second.

Do you want update the text of the textdraw?

Use this:

Код:
TextDrawSetString(Mapdraw0, string);
If you want just change the String, this is a better way, than hide and show the textdraw.


Re: Textdraw update help - Hellman92 - 16.02.2016

Quote:
Originally Posted by Danx
Посмотреть сообщение
What do you want exactly?

Your first code will show only the textdraw in every second.

Do you want update the text of the textdraw?

Use this:

Код:
TextDrawSetString(Mapdraw0, string);
If you want just change the String, this is a better way, than hide and show the textdraw.
Can u give me an ect?


Re: Textdraw update help - Amunra - 16.02.2016

Quote:
Originally Posted by Hellman92
Посмотреть сообщение
Can u give me an ect?
PHP код:
public OnGamemodeInit()
{
    
SetTimer("UpdateMapTimer"1000false);
    return 
1;
}
public 
UpdateMapTimer()
{
    foreach (
Playeri)
    {
        
TextDrawShowForPlayer(iMapdraw0);
        
SetTimer("UpdateMapTimer2",1000,false);
       }
    return 
1;
}
forward UpdateMapTimer2();
public 
UpdateMapTimer2()
{
    foreach(
player,i)
    {
        
TextDrawHideForPlayer(i,Mapdraw0);
        
TextDrawSetString(Mapdraw0,"New Map Name 2");
        
SetTimer("UpdateMapTimer3",1000,false);
    }
    return 
1;
}
forward UpdateMapTimer3();
public 
UpdateMapTimer3()
{
    foreach(
player,i)
    {
        
TextDrawHideForPlayer(i,Mapdraw0);
        
TextDrawSetString(Mapdraw0,"New Map Name 3");
        
SetTimer("UpdateMapTimer",1000,false);
    }
    return 
1;
}
//Back to Map 1 , Keep do It 
Replace That !

And dont Forget to Change String"" !


Re: Textdraw update help - Hellman92 - 16.02.2016

Quote:
Originally Posted by Amunra
Посмотреть сообщение
PHP код:
public OnGamemodeInit()
{
    
SetTimer("UpdateMapTimer"1000false);
    return 
1;
}
public 
UpdateMapTimer()
{
    foreach (
Playeri)
    {
        
TextDrawShowForPlayer(iMapdraw0);
        
SetTimer("UpdateMapTimer2",1000,false);
       }
    return 
1;
}
forward UpdateMapTimer2();
public 
UpdateMapTimer2()
{
    foreach(
player,i)
    {
        
TextDrawHideForPlayer(i,Mapdraw0);
        
TextDrawSetString(Mapdraw0,"New Map Name 2");
        
SetTimer("UpdateMapTimer3",1000,false);
    }
    return 
1;
}
forward UpdateMapTimer3();
public 
UpdateMapTimer3()
{
    foreach(
player,i)
    {
        
TextDrawHideForPlayer(i,Mapdraw0);
        
TextDrawSetString(Mapdraw0,"New Map Name 3");
        
SetTimer("UpdateMapTimer",1000,false);
    }
    return 
1;
}
//Back to Map 1 , Keep do It 
Replace That !

And dont Forget to Change String"" !
is that necessary with so many timers?


Re: Textdraw update help - Amunra - 16.02.2016

Quote:
Originally Posted by Hellman92
Посмотреть сообщение
is that necessary with so many timers?
1 Second / Every Second ..


Re: Textdraw update help - Danx - 16.02.2016

Quote:
Originally Posted by Hellman92
Посмотреть сообщение
Can u give me an ect?
Код:
public OnPlayerConnect(playerid)
{
        TextDrawShowForPlayer(playerid, Mapdraw0);
	return 1;
}
Код:
public UpdateMapTimer()
{
    foreach (Player, i)
    {
        new string[25];
        new hour,minute,second;
	gettime(hour,minute,second);

	format(string, sizeof(string), "Time: %d:%d:%d", hour,minute,second);
	TextDrawSetString(Mapdraw0, string);
     }
     return 1;
}