SA-MP Forums Archive
Time Countup - 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: Time Countup (/showthread.php?tid=311662)



Time Countup - sameer419 - 17.01.2012

I am making a timer which goes ++;
so when i do this itz not working..

TIMEUP!

Код:
new GameMinutes = 0;
new GameSeconds = 00;
new GameTimer;
new Text:RaceTime;

forward GameTime(playerid);

public OnGameModeInit()
{

	RaceTime = TextDrawCreate(557.000000, 375.000000, "00:00");
	TextDrawAlignment(RaceTime, 2);
	TextDrawBackgroundColor(RaceTime, 255);
	TextDrawFont(RaceTime, 1);
	TextDrawLetterSize(RaceTime, 0.450000, 1.200000);
	TextDrawColor(RaceTime, -1);
	TextDrawSetOutline(RaceTime, 0);
	TextDrawSetProportional(RaceTime, 0);
	TextDrawSetShadow(RaceTime, 1);
	
	return 1;
}

public GameTime(playerid)
{
    if(GameSeconds || GameMinutes)
    {
        GameSeconds++;
        if(GameSeconds >= 59)
        {
            GameMinutes++;
            GameSeconds=00;
        }
        new TimeString[256];
        format(TimeString,sizeof(TimeString),"%d:%d",GameMinutes,GameSeconds);
        TextDrawSetString(Text:RaceTime, TimeString);
    }

    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, Text:RaceTime);
    GameTimer = SetTimer("GameTime",1000,1);
	return 1;
}



Re: Time Countup - Snowman12 - 17.01.2012

pawn Код:
new GameMinutes = 0;
new GameSeconds = 00;
new GameTimer;
new Text:RaceTime;

forward GameTime(playerid);

public OnGameModeInit()
{

    RaceTime = TextDrawCreate(557.000000, 375.000000, "00:00");
    TextDrawAlignment(RaceTime, 2);
    TextDrawBackgroundColor(RaceTime, 255);
    TextDrawFont(RaceTime, 1);
    TextDrawLetterSize(RaceTime, 0.450000, 1.200000);
    TextDrawColor(RaceTime, -1);
    TextDrawSetOutline(RaceTime, 0);
    TextDrawSetProportional(RaceTime, 0);
    TextDrawSetShadow(RaceTime, 1);
   
    return 1;
}

public GameTime(playerid)
{
    if(GameSeconds || GameMinutes)
    {
        GameSeconds++;
        if(GameSeconds >= 59)
        {
            GameMinutes++;
            GameSeconds=00;
        }
        new TimeString[256];
        format(TimeString,sizeof(TimeString),"%d:%d",GameMinutes,GameSeconds);
        GameSeconds ++;
        if(GameSeconds == 59)
        {
           GameMinutes ++;
           GameSeconds = 0;
        }
        TextDrawSetString(RaceTime, TimeString); // DONT NEED Text:RaceTime here. Just RaceTime.
    }

    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, RaceTime); // NO NEED FOR TEXT
    return 1;
}

public OnGameModeInit()
{
     GameTimer = SetTimer("GameTime",1000,1);
     return 1;
}
Should work


Re: Time Countup - sameer419 - 17.01.2012

No, it's still not working..
and btw " >= " means greater than or equal to.
http://en.wikipedia.org/wiki/List_of...atical_symbols


Re: Time Countup - selten98 - 17.01.2012

Use SetTimerEx instead of SetTimer. And not >=. But > as it shouldnt Equal 59 (that not a full minute!) it should equal 60 or better be bigger then 59.
pawn Код:
new GameMinutes = 0;
new GameSeconds = 00;
new GameTimer;
new Text:RaceTime;

forward GameTime(playerid);

public OnGameModeInit()
{

    RaceTime = TextDrawCreate(557.000000, 375.000000, "00:00");
    TextDrawAlignment(RaceTime, 2);
    TextDrawBackgroundColor(RaceTime, 255);
    TextDrawFont(RaceTime, 1);
    TextDrawLetterSize(RaceTime, 0.450000, 1.200000);
    TextDrawColor(RaceTime, -1);
    TextDrawSetOutline(RaceTime, 0);
    TextDrawSetProportional(RaceTime, 0);
    TextDrawSetShadow(RaceTime, 1);
   
    return 1;
}

public GameTime(playerid)
{
    if(GameSeconds || GameMinutes)
    {
        GameSeconds++;
        if(GameSeconds > 59)
        {
            GameMinutes++;
            GameSeconds=00;
        }
        new TimeString[256];
        format(TimeString,sizeof(TimeString),"%d:%d",GameMinutes,GameSeconds);
        TextDrawSetString(RaceTime, TimeString);
    }

    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, RaceTime); // NO NEED FOR TEXT
    return 1;
}

public OnGameModeInit()
{
     GameTimer = SetTimerEx("GameTime",1000,1,"i",playerid);
     return 1;
}



Re: Time Countup - sameer419 - 17.01.2012

Not Working..


Re: Time Countup - sameer419 - 17.01.2012

Quote:
Originally Posted by selten98
Посмотреть сообщение
Use SetTimerEx instead of SetTimer. And not >=. But > as it shouldnt Equal 59 (that not a full minute!) it should equal 60 or better be bigger then 59.
pawn Код:
public OnGameModeInit()
{
     GameTimer = SetTimerEx("GameTime",1000,1,"i",playerid);
     return 1;
}
"playerid" on OnGameModeInIt() ??

(26) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.


Re: Time Countup - Snowman12 - 17.01.2012

pawn Код:
for(new playerid; playerid < MAX_PLAYERS; playerid++)
{
GameTimer = SetTimerEx("GameTime",1000,1,"i",playerid);
}
Loop it; also sorry I meant > been scripting alot of administrator commands today