Vice City Multiplayer
General Discussion => Support => Tutorials => Topic started by: NeskWriter on December 31, 2012, 12:44:10 pm
-
Hi! Once I've found a topic of one guy(I don't remember his nick) where he asked us to make gamemode with changing colors.
I think that it must be posted somewhere, and i decided to post it in Tutorials group. Okay, now let's learn it!
[pawn]
forward gtchange01();// we are forwarding the 1st timer
forward gtchange02();// forwarding the 2nd timer
[/pawn]
now public OnGameModeInit
[pawn]
SetTimer("gtchange01", 2000, 0);//we are starting 1st timer(2 secs), which will not be repeated
[/pawn]
[pawn]
public gtchange01()//We made a new public which is named as 1st timer (gtchange01)
{
GameTextForAllBottom("~o~HELL~h~O");//we made a gametext for all in bottom which will be shown after 2 secs of GMInit
SetTimer("gtchange02", 2000, 0);//we are starting the next timer(also 2 secs), and it also will not be repeated
return 1;
}[/pawn]
[pawn]
public gtchange02()// we made a public of the 2nd timer(as 1st)
{
GameTextForAllBottom("~h~HELL~o~O");//we made a gametext with another colours
SetTimer("gtchange01", 2000, 0);//we are locking "the ring" by starting 1st timer
return 1;
}[/pawn]
It works, I mean, it changes it's colours every 2 seconds
(http://i.imgur.com/2GFAV.jpg)
(http://i.imgur.com/TJC4g.jpg)
-
Ahah, sorry, forget to compare timers names. I fixed it now.
-
Why 2 timers ?
Please don't follow the method described above, see this:
[pawn]
new tick = 0;
forward gtchange();
public OnGameModeInit()
{
SetTimer("gtchange", 2000, 1);
}
public gtchange()
{
switch(tick)
{
case 0:
GameTextForAllBottom("Your text with your colour No1 here");
tick = 1;
case 1:
GameTextForAllBottom("Your text with your colour No1 here");
tick = 0;
}
return 1;
}[/pawn]
Don't use too many timers, this version should be better..