• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Bank Robbery System [HELP!]
#1
PHP Code:
// Bank Robbery

new robbing[MAX_PLAYERS];

new 
alreadyrobbed[MAX_PLAYERS];

new 
robbingTimer[MAX_PLAYERS];

forward bankrob(playerid);

forward robbedoff(playerid);



public 
bankrob(playerid)

{

? ?new 
robcash random(25000)  35000;

? ?
SendClientMessage(playeridCOLOR_WHITE" Your finished robbing the bank, Run now");

? ?
GiveMoney(playeridrobcash);

? ?
//SendClientMessage(playerid, COLOR_WHITE, "You've been rob {33CC33}%s{FFFFFF}Dollars from the bank vault.", FormatNumber(robcash));

? ?alreadyrobbed[playerid] = 1;

? ?
robbing[playerid] = 0;

? ?
robbingTimer[playerid] = SetTimerEx("robbedoff"3600000false"i"playerid);

? ?
SendClientMessageToAll(COLOR_ORANGE"||----------Latest News----------||");

? ?
SendClientMessageToAll(COLOR_WHITE" It looks like the bankrobber got the cash.");

? ?
SendClientMessageToAll(COLOR_WHITE" The cops is currently waiting outside.");

? ?
SendClientMessageToAll(COLOR_ORANGE"||----------Latest News----------||");

? ?return 
1;

}

public 
robbedoff(playerid)

{

? ?
alreadyrobbed[playerid] = 0;

? ?
SendClientMessage(playeridCOLOR_WHITE" You can now rob the bank again [/report to ask an admin to approve.]");

? ?return 
1;





PHP Code:
public OnPlayerDeath(playeridkilleridreason)

{

? ?
// Bank Robbey

? ?KillTimer(robbingTimer[playerid]);

? ?
robbing[playerid] = 0;

? ?
SendClientMessageToAll(COLOR_ORANGE"||----------Latest News----------||");

? ?
SendClientMessageToAll(COLOR_WHITE" Los Santos Police have been caught the suspect. ");

? ?
SendClientMessageToAll(COLOR_ORANGE"||----------Latest News----------||");

return 
1;





PHP Code:
public OnPlayerDisconnect(playeridreason)

{

? ?
/*// Bank Robbey

? ?KillTimer(robbingTimer[playerid]);

? ?robbing[playerid] = 0;

? ?SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");

? ?SendClientMessageToAll(COLOR_WHITE, " Los Santos Police have been caught the suspect. ");

? ?SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");*/ 



PHP Code:
CMD:robbank(playeridparams[])

{

if(
robbing[playerid] == 1)

? ? ? return 
SendErrorMessage(playerid" You are already robbing the bank, please slow down");



? ?if(
alreadyrobbed[playerid] == 1)

? ? ? return 
SendErrorMessage(playerid"You already robbed the bank! Wait 1 hour.");

? ? ? ? ? ? ? 

? if (!
Inventory_HasItem(playerid"C4"))

? ? ? return 
SendErrorMessage(playerid"You don't have a C4.");

? ? ? ? ? ?

? ?if(!
IsPlayerInRangeOfPoint(playerid5.01435.3354,-981.6418,983.6462)) return SendErrorMessage(playerid"You are not at the bank !");



? ?
SendClientMessage(playeridCOLOR_WHITE" You started to rob the bank, This will take 10 minutes");

? ?
SetTimerEx("bankrob"600000false"i"playerid);

? ?
robbing[playerid] = 1;

? ?
Inventory_Remove(playerid"C4");

? ?
SendClientMessageToAll(COLOR_ORANGE"||----------Latest News----------||");

? ?
SendClientMessageToAll(COLOR_WHITE" The bank is currently getting robbed.");

? ?
SendClientMessageToAll(COLOR_WHITE" Los Santos Police units are on the way.");

? ?
SendClientMessageToAll(COLOR_WHITE" We will report more when we get more information");

? ?
SendClientMessageToAll(COLOR_ORANGE"||----------Latest News----------||");

? ?return 
1;





when player die/quit its gives the msg of the suspect is down but if he stays online for 10min he still get the cash and also if he's relog after quiting he still get the cash after 10 minutes.

Also sometimes the?" Los Santos Police have been caught the suspect. " message showing for no reason

Have any idea how to fix it?
  Reply
#2
Main problem timer dont stop, when he
Quote:robbedoff

I fix your code, and fix some other issues.



Download link | Solidfiles.com





Put this code at top of your codes and use function, dont need forward and public same time



Code:
#define function%0(%1) forward%0(%1); public%0(%1)



Variables





Code:
new bankrobberid;

new alreadyrobbed;

new bankreadytorobTimer;



new robbing[MAX_PLAYERS];

new robbingTimer[MAX_PLAYERS];



Command





Code:
CMD:robbank(playerid, params[])

{

if(robbing[playerid] == 1)return SendErrorMessage(playerid, " You are already robbing the bank, please slow down");

if(alreadyrobbed == 1)return SendErrorMessage(playerid, "Someone already robbed the bank! Wait 1 hour.");

if (!Inventory_HasItem(playerid, "C4"))return SendErrorMessage(playerid, "You don't have a C4.");

if(!IsPlayerInRangeOfPoint(playerid, 5.0, 1435.3354,-981.6418,983.6462))return SendErrorMessage(playerid, "You are not at the bank !");



SendClientMessage(playerid, COLOR_WHITE, " You started to rob the bank, This will take 10 minutes");

robbingTimer[playerid] = SetTimerEx("bankrobend", 600000, false, "i", playerid);

robbing[playerid] = 1;

Inventory_Remove(playerid, "C4");

SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");

SendClientMessageToAll(COLOR_WHITE, " The bank is currently getting robbed.");

SendClientMessageToAll(COLOR_WHITE, " Los Santos Police units are on the way.");

SendClientMessageToAll(COLOR_WHITE, " We will report more when we get more information");

SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");

return 1;

}



OnPlayerDeath



Code:
public OnPlayerDeath(playerid, killerid, reason)

{

if(robbing[playerid] == 1)

{

// Bank Robbey

KillTimer(robbingTimer[playerid]);

robbing[playerid] = 0;

SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");

SendClientMessageToAll(COLOR_WHITE, " Los Santos Police have been caught the suspect. ");

SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");

}

return 1;

}



OnPlayerDisconnect





Code:
public OnPlayerDisconnect(playerid, reason)

{

if(robbing[playerid] == 1)

{

// Bank Robbey

KillTimer(robbingTimer[playerid]);

robbing[playerid] = 0;

SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");

SendClientMessageToAll(COLOR_WHITE, " Los Santos Police have been caught the suspect. ");

SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");

}

return 1;

}



Other?Functions



Code:
function bankrobend(playerid)

{

new S[128];

new robcash = random(25000)  35000;

SendClientMessage(playerid, COLOR_WHITE, " Your finished robbing the bank, Run now");

GiveMoney(playerid, robcash);

format(S, sizeof(S), "You've been rob {33CC33}%d{FFFFFF} Dollars from the bank vault.", robcash)

SendClientMessage(playerid, COLOR_WHITE, S);

alreadyrobbed = 1;

robbing[playerid] = 0;

bankrobberid = playerid;

KillTimer(robbingTimer[playerid]);

bankreadytorobTimer = SetTimer("readytorob", 18000000, true);

SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");

SendClientMessageToAll(COLOR_WHITE, " It looks like the bankrobber got the cash.");

SendClientMessageToAll(COLOR_WHITE, " The cops is currently waiting outside.");

SendClientMessageToAll(COLOR_ORANGE, "||----------Latest News----------||");

return 1;

}



function readytorob()

{

alreadyrobbed = 0;

KillTimer(bankreadytorobTimer);

SendClientMessage(bankrobberid, COLOR_WHITE, " You can now rob the bank again [/report to ask an admin to approve.]");

bankrobberid = -1;

return 1;

}
  Reply


Forum Jump: