Timer updated for a player every minute.
#15

Код:
#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;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)