SA-MP Forums Archive
Set timer inside a textdraw - 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: Set timer inside a textdraw (/showthread.php?tid=659278)



Set timer inside a textdraw - Zeus666 - 29.09.2018

PHP код:
      TDEditor_TD[1] = TextDrawCreate(27.000020423.540802"RESPAWN IN 10");
    
TextDrawLetterSize(TDEditor_TD[1], 0.2360001.259851);
    
TextDrawAlignment(TDEditor_TD[1], 1);
    
TextDrawColor(TDEditor_TD[1], -1);
    
TextDrawSetShadow(TDEditor_TD[1], 1);
    
TextDrawBackgroundColor(TDEditor_TD[1], 255);
    
TextDrawFont(TDEditor_TD[1], 2);
    
TextDrawSetProportional(TDEditor_TD[1], 1); 
Instead of 10, how can I add my timer

PHP код:
timer RespawnGeneral[1800000]() 
?


Re: Set timer inside a textdraw - TheToretto - 29.09.2018

Format the desired message, you should make a countdown also.


Re: Set timer inside a textdraw - Zeus666 - 29.09.2018

PHP код:
forward RespawnCount(playerid);
public 
OnPlayerConnect(playerid)
{
if(
RespawnGeneral() == 0)
{
playertimer[playerid] = SetTimerEx("RespawnCount"1000true"i"playerid);
}
public 
RespawnCount(playerid)
{
    if(
RespawnGeneral() == 0)
    {
        
KillTimer(playertimer[playerid]);
    }
    else
    {
        new 
str[32];
        
format(strsizeof(str), "%s"TimeConvert(RespawnGeneral()));
    }
    return 
1;

?


Re: Set timer inside a textdraw - Zeus666 - 29.09.2018

I don't know what to do from here

PHP код:
    format(respawnupdate,sizeof(respawnupdate),"RESPAWN IN: %i",TimeConvert(RespawnGeneral()));
      
TDEditor_TD[1] = TextDrawCreate(27.000020423.540802"RESPAWN IN 10");
    
TextDrawLetterSize(TDEditor_TD[1], 0.2360001.259851);
    
TextDrawAlignment(TDEditor_TD[1], 1);
    
TextDrawColor(TDEditor_TD[1], -1);
    
TextDrawSetShadow(TDEditor_TD[1], 1);
    
TextDrawBackgroundColor(TDEditor_TD[1], 255);
    
TextDrawFont(TDEditor_TD[1], 2);
    
TextDrawSetProportional(TDEditor_TD[1], 1); 



Re: Set timer inside a textdraw - d3Pedro - 29.09.2018

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
I don't know what to do from here

PHP код:
    format(respawnupdate,sizeof(respawnupdate),"RESPAWN IN: %i",TimeConvert(RespawnGeneral()));
      
TDEditor_TD[1] = TextDrawCreate(27.000020423.540802"RESPAWN IN 10");
    
TextDrawLetterSize(TDEditor_TD[1], 0.2360001.259851);
    
TextDrawAlignment(TDEditor_TD[1], 1);
    
TextDrawColor(TDEditor_TD[1], -1);
    
TextDrawSetShadow(TDEditor_TD[1], 1);
    
TextDrawBackgroundColor(TDEditor_TD[1], 255);
    
TextDrawFont(TDEditor_TD[1], 2);
    
TextDrawSetProportional(TDEditor_TD[1], 1); 
Use TextDrawSetString

PHP код:
    format(respawnupdate,sizeof(respawnupdate),"RESPAWN IN: %i",TimeConvert(RespawnGeneral()));
        
TextDrawSetString(TDEditor_TD[1], respawnupdate);
      
TDEditor_TD[1] = TextDrawCreate(27.000020423.540802"RESPAWN IN 10");
    
TextDrawLetterSize(TDEditor_TD[1], 0.2360001.259851);
    
TextDrawAlignment(TDEditor_TD[1], 1);
    
TextDrawColor(TDEditor_TD[1], -1);
    
TextDrawSetShadow(TDEditor_TD[1], 1);
    
TextDrawBackgroundColor(TDEditor_TD[1], 255);
    
TextDrawFont(TDEditor_TD[1], 2);
    
TextDrawSetProportional(TDEditor_TD[1], 1); 



Re: Set timer inside a textdraw - Zeus666 - 29.09.2018

Quote:
Originally Posted by ConnorW
Посмотреть сообщение
Use TextDrawSetString

PHP код:
    format(respawnupdate,sizeof(respawnupdate),"RESPAWN IN: %i",TimeConvert(RespawnGeneral()));
        
TextDrawSetString(TDEditor_TD[1], respawnupdate);
      
TDEditor_TD[1] = TextDrawCreate(27.000020423.540802"RESPAWN IN 10");
    
TextDrawLetterSize(TDEditor_TD[1], 0.2360001.259851);
    
TextDrawAlignment(TDEditor_TD[1], 1);
    
TextDrawColor(TDEditor_TD[1], -1);
    
TextDrawSetShadow(TDEditor_TD[1], 1);
    
TextDrawBackgroundColor(TDEditor_TD[1], 255);
    
TextDrawFont(TDEditor_TD[1], 2);
    
TextDrawSetProportional(TDEditor_TD[1], 1); 
What about respawn in 10

I need to delete it.


Re: Set timer inside a textdraw - UFF - 29.09.2018

Код:
new RESPAWN_COUNT[MAX_PLAYERS] = 0;
public OnPlayerConnect(playerid)
{

    RESPAWN_COUNT[playerid] = 0; // reseting variable.
 
	if(RESPAWN_COUNT[playerid] == 0)
	{
       RESPAWN_COUNT[playerid] = 10; // setting respawn count to 10 seconds
	   playertimer[playerid] = SetTimerEx("RespawnCount", 1000, true, "i", playerid);
	}
	return 1;
}





public RespawnCount(playerid)
{
    RESPAWN_COUNT[playerid] --; //decreases the count every 1 secoond. (10, 9, 8...,0)
    if(RESPAWN_COUNT[playerid] == 0)
    {
        KillTimer(playertimer[playerid]);
    }
    else
    {
        new str[32];
        format(str, sizeof(str), "RESPAWN IN %d", RESPAWN_COUNT[playerid]);
        TextDrawSetString(TDEditor_TD[1],str); 
    }
    return 1;
}
Something like this!


Re: Set timer inside a textdraw - Zeus666 - 29.09.2018

Quote:
Originally Posted by UFF
Посмотреть сообщение
Код:
new RESPAWN_COUNT[MAX_PLAYERS] = 0;
public OnPlayerConnect(playerid)
{

    RESPAWN_COUNT[playerid] = 0; // reseting variable.
 
	if(RESPAWN_COUNT[playerid] == 0)
	{
       RESPAWN_COUNT[playerid] = 10; // setting respawn count to 10 seconds
	   playertimer[playerid] = SetTimerEx("RespawnCount", 1000, true, "i", playerid);
	}
	return 1;
}





public RespawnCount(playerid)
{
    RESPAWN_COUNT[playerid] --; //decreases the count every 1 secoond. (10, 9, 8...,0)
    if(RESPAWN_COUNT[playerid] == 0)
    {
        KillTimer(playertimer[playerid]);
    }
    else
    {
        new str[32];
        format(str, sizeof(str), "RESPAWN IN %d", RESPAWN_COUNT[playerid]);
        SendClientMessage(playerid, -1, str);
    }
    return 1;
}
Something like this!
What if I want to show countdown to already existing timer ?

PHP код:
timer RespawnGeneral[1800000]()
{
    
DayZSA_RespawnItems();
    return 
1;


eg. if timer is at 20:53 and player enters in game it will show 20:53 not 30:00


Re: Set timer inside a textdraw - UFF - 29.09.2018

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
What if I want to show countdown to already existing timer ?

PHP код:
timer RespawnGeneral[1800000]()
{
    
DayZSA_RespawnItems();
    return 
1;


eg. if timer is at 20:53 and player enters in game it will show 20:53 not 30:00
oh,

I saw the replies and your issue, you have show the textdraw first in OnPlayerConnect and then you have to use TextDrawSetString.

Try this
Код:
Remove 10 from the TextDrawCreate code.

TDEditor_TD[1] = TextDrawCreate(27.000020, 423.540802, "RESPAWN IN:");


public OnPlayerConnect(playerid)
{

  TextDrawShowForPlayer(playerid, TDEditor_TD[1]);

  format(respawnupdate,sizeof(respawnupdate),"RESPAWN IN: %d",TimeConvert(RespawnGeneral())); 
  TextDrawSetString(TDEditor_TD[1], respawnupdate);
  return 1;
}



Re: Set timer inside a textdraw - Zeus666 - 29.09.2018

Now it appears to be

"respawn in 48"

instead to appear "respawn in 30:00" (30 minutes, 00 seconds)



And it won't refresh


Whole script


PHP код:
new respawnupdate[285];
public 
OnPlayerConnect(playerid)
{
     
TextDrawShowForPlayer(playeridTDEditor_TD[1]);
      
format(respawnupdate,sizeof(respawnupdate),"RESPAWN IN: %d",TimeConvert(RespawnGeneral()));
      
TextDrawSetString(TDEditor_TD[1], respawnupdate);
timer RespawnGeneral[1800000]()
{
    
DayZSA_RespawnItems();
    return 
1;
}
public 
RespawnCount(playerid)
{
    if(
RespawnGeneral() == 0)
    {
        
KillTimer(playertimer[playerid]);
    }
    else
    {
        new 
str[32];
        
format(strsizeof(str), "%s"TimeConvert(RespawnGeneral()));
    }
    return 
1;