textdraw that showing settimer - 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 that showing settimer (
/showthread.php?tid=325322)
textdraw that showing settimer -
marik1322 - 12.03.2012
i tried to do a textdraw that showing the settimer that i put in command.
but it is not working.
i did like that:
PHP код:
forward sd();
new rd;
new Text:Textdraw8;
forward bomber1();
public OnGameModeInit()
{
SetTimer("bomber1",1000,1);
Textdraw8 = TextDrawCreate(255,23, "Time till carrier will bomb: --");
}
command(platebomb, playerid, params[])
{
if(gTeam[playerid] == Allied)
{
if( PlayerToPoint( 10, playerid, 2619.00000000,442.39999390,12.00000000 ) )
{
new pname[128];
GetPlayerName(playerid, pname, sizeof(pname));
new string[128];
format(string, sizeof(string), "%s(%d) has plated bomb on russian carrier.", pname, playerid);
SendClientMessageToAll(Yellow, string);
rd = SetTimer("sd", 300000, false);
new newtext[41];
format(newtext, sizeof(newtext), "Time till carrier will bomb: %d", rd);
TextDrawSetString(Textdraw8, newtext);
TextDrawShowForAll(Textdraw8);
}
}
return 1;
}
public sd()
{
// this i will update later.
return 1;
}
public bomber1()
{
new newtext[41];
format(newtext, sizeof(newtext), "Time till carrier will bomb: %d", rd);
TextDrawSetString(Textdraw8, newtext);
TextDrawShowForAll(Textdraw8);
return 1;
}
Re: textdraw that showing settimer -
Mike_Peterson - 12.03.2012
SetTimer doesn't returns the amount of time left, but it returns the ID of the timer.
what about a variable like 'new timeleft;', @ platebomb, timeleft = 300; then @ bomber1 timer, above the format, timeleft--; and instead of rd in the format, using timeleft.
so it's looking like this
pawn Код:
forward sd();
new rd;
new timeleft;
new Text:Textdraw8;
forward bomber1();
public OnGameModeInit()
{
SetTimer("bomber1",1000,1);
Textdraw8 = TextDrawCreate(255,23, "Time till carrier will bomb: --");
}
command(platebomb, playerid, params[])
{
if(gTeam[playerid] == Allied)
{
if( PlayerToPoint( 10, playerid, 2619.00000000,442.39999390,12.00000000 ) )
{
new pname[128];
GetPlayerName(playerid, pname, sizeof(pname));
new string[128];
format(string, sizeof(string), "%s(%d) has plated bomb on russian carrier.", pname, playerid);
SendClientMessageToAll(Yellow, string);
rd = SetTimer("sd", 300000, false);
timeleft = 300;
new newtext[41];
format(newtext, sizeof(newtext), "Time till carrier will bomb: %d", timeleft);
TextDrawSetString(Textdraw8, newtext);
TextDrawShowForAll(Textdraw8);
}
}
return 1;
}
public sd()
{
// this i will update later.
return 1;
}
public bomber1()
{
new newtext[41];
timeleft--;
format(newtext, sizeof(newtext), "Time till carrier will bomb: %d", timeleft);
TextDrawSetString(Textdraw8, newtext);
TextDrawShowForAll(Textdraw8);
return 1;
}
rep++ if helped.
Re: textdraw that showing settimer -
marik1322 - 12.03.2012
tnx man