SA-MP Forums Archive
Timer updated for a player every minute. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer updated for a player every minute. (/showthread.php?tid=64443)



Timer updated for a player every minute. - SpiderPork - 04.02.2009

Could somebody help me with this?
I need some help with a textdraw. It has to be changed for +1 every 1 minute. So it counts how many minutes you spent on the server.
If you disconnect, it kills the timer, when you connect, it sets the timer back up.
The textdraw should be under the cash.

Thanks in advance.


Re: Timer updated for a player every minute. - Yaheli_Faro - 04.02.2009

There are a few real time clock FS's in the showroom, take a look at those


Re: Timer updated for a player every minute. - SpiderPork - 04.02.2009

I looked at them a while ago. But none of them realy helped me. I'm pretty a begginer.


Re: Timer updated for a player every minute. - SpiderPork - 04.02.2009

Anyone?


Re: Timer updated for a player every minute. - Jonte92 - 04.02.2009

pawn Код:
forward Time();

new PlayTime[MAX_PLAYERS];
new Timer;

public OnGameModeInit()
{
   Timer = SerTimer("Time", 60000, 1);
   return 0;//Or 1 , im not sure
}

public OnGameModeExit()
{
   KillTimer(Timer);
   return 1;
}
public Time()
{
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
     if(IsPlayerConnected(i))
     {
        PlayerTime[i] +1;
     }
   }
   return 1;
}
Something like that I this!


Re: Timer updated for a player every minute. - SpiderPork - 04.02.2009

Argh... I got this:

pawn Код:
// Defines
forward Time();
forward ScoreUpdate();

new PlayerTime[MAX_PLAYERS];
new Timer;
new Text:Score[MAX_PLAYERS];

// OnPlayerConnect

TextDrawShowForPlayer(playerid, Score[playerid]);
Timer = SetTimerEx("Time", 60000, 0, "ii", playerid);

// On the end of the script

public ScoreUpdate()
{
    new string[100];
    format(string,sizeof(string),"%d", PlayerTime);
    TextDrawSetString(Score[playerid], string);
    Score[playerid] = TextDrawCreate(493.000000,98.000000,"00000000");
    TextDrawAlignment(Score[playerid],0);
    TextDrawBackgroundColor(Score[playerid],0x000000ff);
    TextDrawFont(Score[playerid],3);
    TextDrawLetterSize(Score[playerid],0.699999,2.000000);
    TextDrawColor(Score[playerid],0xff0000ff);
    TextDrawSetOutline(Score[playerid],1);
    TextDrawSetProportional(Score[playerid],1);
    TextDrawSetShadow(Score[playerid],1);
}

public Time()
{
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
     if(IsPlayerConnected(i))
     {
        PlayerTime[i] += 1;
     }
   }
   return 1;
}
And the errors:

Код:
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoS\gamemodes\Stunt.pwn(3387) : error 017: undefined symbol "playerid"
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoSr\gamemodes\Stunt.pwn(3388) : error 017: undefined symbol "playerid"
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoS\gamemodes\Stunt.pwn(3389) : error 017: undefined symbol "playerid"
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoS\gamemodes\Stunt.pwn(3390) : error 017: undefined symbol "playerid"
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoS\gamemodes\Stunt.pwn(3391) : error 017: undefined symbol "playerid"
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoS\gamemodes\Stunt.pwn(3392) : error 017: undefined symbol "playerid"
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoS\gamemodes\Stunt.pwn(3393) : error 017: undefined symbol "playerid"
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoS\gamemodes\Stunt.pwn(3394) : error 017: undefined symbol "playerid"
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoS\gamemodes\Stunt.pwn(3395) : error 017: undefined symbol "playerid"
G:\Program Files\Rockstar Games\San Andreas Online\SAMP Server RoS\gamemodes\Stunt.pwn(3396) : error 017: undefined symbol "playerid"



Re: Timer updated for a player every minute. - Auto-Sized - 04.02.2009

pawn Код:
forward ScoreUpdate(playerid);

public ScoreUpdate(playerid)
{
I only looked at that.


Re: Timer updated for a player every minute. - SpiderPork - 07.02.2009

How stupid I am lol. Thanks for help. It compiles fine. I'm gonna test it now and tell you if it works fine.

Thanks again.

EDIT: The textdraw doesn't show.
I put TextDrawShowForPlayer(playerid, Score[playerid]); under OnPlayerSpawn, but it's not working.


Re: Timer updated for a player every minute. - Jonte92 - 07.02.2009

Quote:
Originally Posted by SpiderPork
How stupid I am lol. Thanks for help. It compiles fine. I'm gonna test it now and tell you if it works fine.

Thanks again.

EDIT: The textdraw doesn't show.
I put TextDrawShowForPlayer(playerid, Score[playerid]); under OnPlayerSpawn, but it's not working.
You need to create a TextDraw


Re: Timer updated for a player every minute. - SpiderPork - 07.02.2009

I did.


Re: Timer updated for a player every minute. - Jonte92 - 07.02.2009

Hmm... Then im not really sure , im using commands for showing textdraws , but i don't know why it won't work you yah , sorry...


Re: Timer updated for a player every minute. - Mikep - 07.02.2009

Quote:
Originally Posted by Jonte92
Timer = SerTimer("Time", 60000, 1);
return 0;//Or 1 , im not sure
return 1;.


Re: Timer updated for a player every minute. - SpiderPork - 07.02.2009

I have return 1;, I created the textdraw and there's a TextDrawShowForPlayer under OnPlayerSpawn. What's the problem?


Re: Timer updated for a player every minute. - Auto-Sized - 07.02.2009

Would be better mate if you posted the code you have.


Re: Timer updated for a player every minute. - Jefff - 07.02.2009

Код:
#include <a_samp>
// Defines
forward Time();
forward ScoreUpdate();

new PlayerTime[MAX_PLAYERS];
new Text:Score[MAX_PLAYERS];
new bool:HaveIt[200];

public OnFilterScriptInit(){
	SetTimer("Time",60000,1);
	for(new i = 0; i < GetMaxPlayers(); i++){
		if(IsPlayerConnected(i)){
			PlayingTime(i);
			TextDrawShowForPlayer(i, Score[i]);
		}
	}
	return 1;
}

public OnPlayerConnect(playerid){
PlayingTime(playerid);
PlayerTime[playerid]=0;
TextDrawShowForPlayer(playerid, Score[playerid]);
return 1;
}

public OnPlayerDisconnect(playerid,reason){
DestroyPlayerDraw(playerid);
return 1;
}

public Time()
{
	new string[128];
	for(new i = 0; i < MAX_PLAYERS; i++){
		if(IsPlayerConnected(i)){
			PlayerTime[i]++;
			format(string,sizeof(string),"%d", PlayerTime[i]);
			TextDrawSetString(Score[i], string);
		}
	}
}

stock PlayingTime(playerid){
	if(!HaveIt[playerid]){
	Score[playerid] = TextDrawCreate(493.0,98.0,"0");
	TextDrawAlignment(Score[playerid],0);
	TextDrawBackgroundColor(Score[playerid],0x000000ff);
	TextDrawFont(Score[playerid],3);
	TextDrawLetterSize(Score[playerid],0.699999,2.000000);
	TextDrawColor(Score[playerid],0xff0000ff);
	TextDrawSetOutline(Score[playerid],1);
	TextDrawSetProportional(Score[playerid],1);
	TextDrawSetShadow(Score[playerid],1);
	HaveIt[playerid]=true;
	}
	return 1;
}

stock DestroyPlayerDraw(playerid){
	if(HaveIt[playerid]){
	TextDrawHideForPlayer(playerid, Score[playerid]);
	TextDrawDestroy(Score[playerid]);
	PlayerTime[playerid]=0;
	HaveIt[playerid]=false;
	}
	return 1;
}



Re: Timer updated for a player every minute. - SpiderPork - 07.02.2009

Ok, I got the texdraw.
Now, I need it to save the score and set it back when the player reconnects.


Re: Timer updated for a player every minute. - SpiderPork - 08.02.2009

Anyone...