how to add Timer for map!?
#1

Hello Guys i already need to know how to add Timer for everymap i have ! ok i send Code for this map

PHP код:
public OnPlayerSpawn(playerid)
{
     
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USEJETPACK);
    
SetPlayerColor(playeridCOLOR_GREEN);
    
GameTextForPlayer(playerid"~w~Kill the other ~r~players ~W~ in the Skybox"30004);
    new 
rand random(sizeof(BattleFieldSpawns));
    
SetPlayerPos(playeridBattleFieldSpawns[rand][0], BattleFieldSpawns[rand][1],BattleFieldSpawns[rand][2]);SetPlayerFacingAngle(playeridBattleFieldSpawns[rand][3]);
     
TextDrawShowForPlayer(playerid,ArmyO);
     
SetPlayerHealth(playerid10);
     
SetPlayerArmour(playerid0);
     
SendClientMessage(playeridCOLOR_YELLOW"If you lost your Jetpack, use /jp to spawn another one!");
    return 
1;

How to add Timer?
Reply
#2

what u mean under "everymap I have" ?

just use
PHP код:
forward MyFunct();
new 
timercreated;
public 
OnPlayerSpawn(playerid)
{
    if(
timercreated == 0)
    {
        
timercreated 1;
        
SetTimer("MyFunct"10000); // 1000 - 1 second, 0 - dont repeat timer.
    
}
}
public 
MyFunct()
{
    
timercreated 0;
     
// your code here.

Reply
#3

Quote:
Originally Posted by BloodyRP
Посмотреть сообщение
what u mean under "everymap I have" ?

just use
PHP код:
forward MyFunct();
SetTimer("MyFunct"10000); // 1000 - 1 second, 1 - repeat timer.
public MyFunct()
{
 
// your code here.

Look Im new and didn't understand What are you mean For Your code here ! i want the Time only 2mintes how to put it?
Reply
#4

Quote:
Originally Posted by Recardo
Посмотреть сообщение
Look Im new and didn't understand What are you mean For Your code here ! i want the Time only 2mintes how to put it?
I just cant understand what u want to do with timer.
May be cuz my english is bad, but I cant help u, cuz cant understand
Reply
#5

Haha i mean When a player Join the MAP /GAME Given him a 2mintes for End Game
Reply
#6

Quote:
Originally Posted by Recardo
Посмотреть сообщение
Haha i mean When a player Join the MAP /GAME Given him a 2mintes for End Game
Okay, and what u mean under 'End Game' ? Quit from the server?
Reply
#7

NOOO The Map is Finish i mean
Reply
#8

PHP код:
forward MyFunct(playerid);
new 
timercreated[MAX_PLAYERS];
new 
mytimer[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
timercreated[playerid] = 1;
    
mytimer[playerid] = SetTimerEx("MyFunct",120000,0,"i",playerid); // Timer for 2 minutes for every player who connect to the server, without repeating
    
return true;
}
public 
OnPlayerDisconnect(playerid)
{
    if(
timercreated[playerid] == 1)
    {
        
KillTimer(mytimer[playerid]);
        
timercreated[playerid] = 0;
    }
    return 
true;
}
public 
MyFunct(playerid)
{
    if(
playerid != INVALID_PLAYER_ID)
    {
        
timercreated[playerid] = 0;
        
// If time goes and he isn't finished.
    
}
    return 
true;

And u need to add

PHP код:
if(timercreated[playerid] == 1)
{
    
KillTimer(mytimer[playerid]);
    
timercreated[playerid] = 0;

in code when player end game.
Reply
#9

Rep added Thanks Worked
Reply
#10

Enjoy it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)