Determine winner
#1

I have a script that show a textdraw for both teams ( green = hobo & blue = clown ).When green team killed blue team they will got 1 score and the textdraw will add 1 score for them.And I have a timer that set 5 mins/round.What I want to do is when the time at 4:50 it will announce which team is the winner based on the textdraw score.

My textdraw for score :

PHP код:
new Text:greenheader;
new 
Text:blueheader;
new 
Text:greenkills;
new 
Text:bluekills
PHP код:
greenheader TextDrawCreate(515,280,"HOBO :");//
blueheader TextDrawCreate(515,320,"CLOWN :");//
greenkills TextDrawCreate(515,300," ");//
bluekills TextDrawCreate(515,340," ");// 
PHP код:
SetTimer("TextDrawUpdate",999,true); 
PHP код:
forward TextDrawUpdate();
public 
TextDrawUpdate()
{
        new 
str1[50],str2[50];
        
//format killcounters
        
format(str1,sizeof(str1),"%i",greenkillcount);
        
format(str2,sizeof(str2),"%i",bluekillcount);
        
//set the empty textdraw's
        
TextDrawSetString(greenkills,str1);
        
TextDrawSetString(bluekills,str2);
        
//show textdraw here so that it will update
        
TextDrawShowForAll(greenkills);
        
TextDrawShowForAll(bluekills);
        
TextDrawShowForAll(greenheader);
        
TextDrawShowForAll(blueheader);

Reply
#2

whats the problem, you are not explaining it enough.
Reply
#3

I want to make a textdraw that will announce which team is the winner at 4m 50s as I set for 1 round is 5m.
Reply
#4

ahhh, I think I see now. You want the kills textdraw to update every second and you want to display the winner after 4:50.

ok let me see what I can do.
Reply
#5

Yes,but only the winner at 4m 50s.Ive done the kills textdraw to update every second in my scripts and its work.
Reply
#6

Put this at top of script: these are the global values:
Код:
new Text:greenheader; 
new Text:blueheader; 
new Text:greenkills; 
new Text:bluekills; 
new greenkillcount;
new bluekillcount;

new gametimer;
new gametimeint;
new Text:winner;
these are the textdraws:
Код:
greenheader = TextDrawCreate(515,280,"HOBO :");// 
blueheader = TextDrawCreate(515,320,"CLOWN :");// 
greenkills = TextDrawCreate(515,300," ");// 
bluekills = TextDrawCreate(515,340," ");// 
winner = TextDrawCreate(x,y,"");//  Replace values with whatever
timer:
Код:
 gametimer = SetTimer("TextDrawUpdate",1000,true);   //1 second timer
this is the timer:
Код:
forward TextDrawUpdate(); 
public TextDrawUpdate() 
{ 
        if(gametimeint==300) // 300 seconds in 5 minutes
        {
        	gametimeint=0;
        	KillTimer(gametimer);
	}
	else
	{
		gametimeint++; // adds 1 every time the timer runs

		if(gametimeint==290) // 290 seconds = 4:50
		{
			if(greenkillcount>bluekillcount){TextDrawSetString(winner,"The Winner Is The Green Team");}
			if(greenkillcount<bluekillcount){TextDrawSetString(winner,"The Winner Is The Blue Team");}
			TextDrawShowForAll(winner); 
		}

		new str1[50],str2[50]; 
        	//format killcounters 
        	format(str1,sizeof(str1),"%i",greenkillcount); 
        	format(str2,sizeof(str2),"%i",bluekillcount); 
        	//set the empty textdraw's 
        	TextDrawSetString(greenkills,str1); 
        	TextDrawSetString(bluekills,str2); 
        	//show textdraw here so that it will update 
        	TextDrawShowForAll(greenkills); 
        	TextDrawShowForAll(bluekills); 
        	TextDrawShowForAll(greenheader); 
        	TextDrawShowForAll(blueheader); 
	}
return 1;
}
basically, set the timer to run infinite for 1 second. Every time the timer runs It is counted. You want to run the game for 5 minutes, which is 300 seconds. so the timer will run 300 times. When it runs 300 times it will stop the timer. You also wanted a textdraw to show for all at 4:50, so 300 seconds - 10 seconds = 290 seconds. When the timer reaches that 290 it will compare the number of kills each team has then set the textdraw to the winning teams text, then it will display the textdraw.

Hope this helped, was unable to test, kinda threw this together becuase Im currently in a physics class.


ugh the samp website was down again......... sorry it took so long
Reply
#7

Thanks for your time dude.I really appreciate it.Im gonna test it and will post the results ASAP.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)