Determine winner
#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


Messages In This Thread
Determine winner - by Sh4d0w2 - 05.11.2015, 13:28
Re: Determine winner - by jeffery30162 - 05.11.2015, 13:54
Re: Determine winner - by Sh4d0w2 - 05.11.2015, 13:56
Re: Determine winner - by jeffery30162 - 05.11.2015, 13:58
Re: Determine winner - by Sh4d0w2 - 05.11.2015, 14:01
Re: Determine winner - by jeffery30162 - 05.11.2015, 15:22
Re: Determine winner - by Sh4d0w2 - 05.11.2015, 15:37

Forum Jump:


Users browsing this thread: 1 Guest(s)