Timer robbank
#1

Hello !
I used to play on a local server with my high-school friends. Can anyone add a timer for me, to make the bank "rob-able" once per hour?
Код:
    if(strcmp(cmd,"/rob",true)==0)
	{
		if(IsPlayerConnected(playerid))
		{
			if(PlayerInfo[playerid][pLevel] >= 3)
			{
				if(PlayerToPoint(10.0, playerid, 2311.8804,-10.4994,26.7422) && GetPlayerVirtualWorld(playerid) == 41)
				{
					if(robbinghour>=1)
					{
					    if(allowedrob == 1)
					    {
							PlayerInfo[playerid][pRobbingBank] = 1;
							SendClientMessage(playerid, COLOR_LIGHTRED, "{a9c4e4}Du-te la {ee5555}checkpoint-ul{a9c4e4} marcat in cladire si ia banii.");
							SetPlayerCheckpoint(playerid, 2306.3003,-7.3777,26.7422, 2);
							CP[playerid] = 792;
							robbinghour = 0;
							return 1;
    	 }
						else
						{
						    SendClientMessage(playerid, COLOR_LIGHTRED, "{DC0C0C}Rob: {FFFFFF}Adminul a inchis temporar sistemul de jafuri.");
						    return 1;
						}
					}
					else { SendClientMessage(playerid, COLOR_LIGHTRED, "Cineva deja a jefuit banca!"); return 1; }
				}
    			if(PlayerToPoint(10.0, playerid, 2311.8804,-10.4994,26.7422) && GetPlayerVirtualWorld(playerid) == 42)
				{
					if(lvrobbinghour>=72)
					{
					    if(allowedrob == 1)
					    {
							PlayerInfo[playerid][pRobbingBank] = 1;
							SendClientMessage(playerid, COLOR_LIGHTRED, "{a9c4e4}Du-te la {ee5555}checkpoint-ul{a9c4e4} marcat in cladire si ia banii.");
							SetPlayerCheckpoint(playerid, 2306.3003,-7.3777,26.7422, 2);
							CP[playerid] = 792;
							lvrobbinghour = 0;
							return 1;
						}
						else
						{
						    SendClientMessage(playerid, COLOR_LIGHTRED, "{DC0C0C}Rob: {FFFFFF}Adminul a inchis temporar sistemul de jafuri.");
						    return 1;
						}
					}
					else { SendClientMessage(playerid, COLOR_LIGHTRED, "Cineva a jefuit deja banca!"); return 1; }
				}
				else
				{
					SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa fii la banca.");
					return 1;
				}
			}
			else return SendClientMessage(playerid, COLOR_LIGHTRED, "Nu ai nivelul 5.");
		}
	}
	if(strcmp(cmd, "/allowrob", true) == 0 || strcmp(cmd, "/ar", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] >= 5)
	        {
	            if(allowedrob == 0) { robbinghour = 72; lvrobbinghour = 72; allowedrob = 1; SendClientMessage(playerid, COLOR_LIGHTBLUE, "{DC0C0C}Ai permis jucatorilor sa jefuiasca banca!"); return 1; }
	            if(allowedrob == 1) { allowedrob = 0; SendClientMessage(playerid, COLOR_LIGHTBLUE, "{DC0C0C}Ai interzis jucatorilor sa jefuiasca banca!"); return 1; }
	        }
	    }
	}
Thanks in advice !
I`m a begginer, else I wouldn't ask you for this, so please don't be mean :P
PS: This rob system is spreaded all over my gamemode, if I missed something please tell me.
Reply
#2

under OnGameModeInit for example:

SetTimer("robagain", 3600000, true); //only this under ongamemodeinit

pawn Код:
//this code you can place "everywhere"
forward robagain();
public robagain()
{
    //set there variables or whatever
}
Reply
#3

What should I write instead of that line between {} ?
My knowledge about this is close to zero :P
Reply
#4

Well if i see well then you set
pawn Код:
lvrobbinghour = 0;
right after robbery so timer should set this variable on
pawn Код:
lvrobbinghour = 1;
after an hour no?
Reply
#5

My pawno crashes after I write this.
Reply
#6

Replace that with this:

Код:
if(strcmp(cmd,"/rob",true)==0)
	{
		if(IsPlayerConnected(playerid))
		{
			if(PlayerInfo[playerid][pLevel] >= 3)
			{
				if(PlayerToPoint(10.0, playerid, 2311.8804,-10.4994,26.7422) && GetPlayerVirtualWorld(playerid) == 41)
				{
					if(robbinghour>=1)
					{
					    if(allowedrob == 1)
					    {
							PlayerInfo[playerid][pRobbingBank] = 1;
							SendClientMessage(playerid, COLOR_LIGHTRED, "{a9c4e4}Du-te la {ee5555}checkpoint-ul{a9c4e4} marcat in cladire si ia banii.");
							SetPlayerCheckpoint(playerid, 2306.3003,-7.3777,26.7422, 2);
							CP[playerid] = 792;
							robbinghour = 0;
                                                        SetTimer("robtime", 3600000, true);
							return 1;
    	 }
						else
						{
						    SendClientMessage(playerid, COLOR_LIGHTRED, "{DC0C0C}Rob: {FFFFFF}Adminul a inchis temporar sistemul de jafuri.");
						    return 1;
						}
					}
					else { SendClientMessage(playerid, COLOR_LIGHTRED, "Cineva deja a jefuit banca!"); return 1; }
				}
    			if(PlayerToPoint(10.0, playerid, 2311.8804,-10.4994,26.7422) && GetPlayerVirtualWorld(playerid) == 42)
				{
					if(lvrobbinghour>=72)
					{
					    if(allowedrob == 1)
					    {
							PlayerInfo[playerid][pRobbingBank] = 1;
							SendClientMessage(playerid, COLOR_LIGHTRED, "{a9c4e4}Du-te la {ee5555}checkpoint-ul{a9c4e4} marcat in cladire si ia banii.");
							SetPlayerCheckpoint(playerid, 2306.3003,-7.3777,26.7422, 2);
							CP[playerid] = 792;
							lvrobbinghour = 0;
                                             
							return 1;
						}
						else
						{
						    SendClientMessage(playerid, COLOR_LIGHTRED, "{DC0C0C}Rob: {FFFFFF}Adminul a inchis temporar sistemul de jafuri.");
						    return 1;
						}
					}
					else { SendClientMessage(playerid, COLOR_LIGHTRED, "Cineva a jefuit deja banca!"); return 1; }
				}
				else
				{
					SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa fii la banca.");
					return 1;
				}
			}
			else return SendClientMessage(playerid, COLOR_LIGHTRED, "Nu ai nivelul 5.");
		}
	}
Add this somewhere on top of the code:
Код:
forward robtime();
public robtime()
{
    robbinghour = 1;
}
Reply
#7

No more errors, but I still can rob again right after I robbed it.
Reply
#8

did you add the last part?
Reply
#9

Yes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)