13.06.2015, 22:02
Guyz, I'm using this. I want to add if player get arrested or get killed while robbing so robbery should be canceled. I tried but didn't get something cool. Can you help me? Thanks!
Onleavecheckpoint
PHP код:
CMD:robbank(playerid,params[])
{
if(gTeam[playerid] == CIVILIANS)
{
if(IsPlayerInDynamicCP(playerid, BankRobbery)) // Checking if player is in the checkpoint
{
if(bankrobbedrecently1 == 0) //checking if tatoo shop has been robbed recently
{
new chances = random(500);
if(chances >= 0 && chances <= 400)
{
new string[250];
ROBBING_BANK1[playerid] = 30; // setting the robbery timer
bankrobbedrecently1 =200; // Time the players needs to wait for starting an another robbery in the same place
SetPlayerWantedLevel(playerid,4);
format(string, sizeof(string), "Committed A Crime: Bank Robbery - Wanted Level 4 - Arrestable");
SendClientMessage(playerid, ROJO, string);
return true;
}
else if(chances >= 401 && chances <= 500)
{
new copmsg[250], name;
SendClientMessage(playerid, COLOR_RED, "You failed to rob store.");
SetPlayerWantedLevel(playerid,4);
format(copmsg, sizeof(copmsg), "Suspected: %s attemped to rob National Bank in Downtown San Fierro (SF).", name);
SendRadioMessageToCops(copmsg);
return true;
}
}
else if(bankrobbedrecently1 > 0) return SendClientMessage(playerid, ROJO, "Please wait before robbing this store again.");
}
PHP код:
if(ROBBING_BANK1[i] == 1) // IF the timer reached 1
{
new string[256], pName[MAX_PLAYER_NAME];// getting player name
GetPlayerName(i,pName,MAX_PLAYER_NAME);
ROBBING_BANK1[i] =0; // RESET timer
new earning =random(95000);
format(string,sizeof(string),"%s (%d) has stolen $%d from National Bank in Downtown San Fierro (SF)!",pName,i,earning);
SendClientMessageToAll(COLOR_CYAN,string);
format(string,sizeof(string),"ROBBERY COMPLETED");
GameTextForPlayer(i,string, 1000, 3);
format(string,sizeof(string),"Gread Job! You completed the robbery, profit: $%d", earning); //sending message to the player that robbery was complete
SendClientMessage(i,GREEN,string);
GivePlayerCashEx(i, earning);
SetPlayerWantedLevel(i, GetPlayerWantedLevel(i) + 1); //giving player 1 wanted level
GivePlayerScore(i,1);
pInfo[i][pStoreRobbed] ++;
pInfo[i][pStoreRobbedMoney] = pInfo[i][pStoreRobbedMoney] +earning;
}
if(ROBBING_BANK2[i] > 1 // Checking if robbery time is above 1
{
ROBBING_BANK2[i] --; // Decreasing time
new time[256]; //adding time variable
format(time,sizeof(time),"~y~Robbery Time: %d~n~~r~DO NOT MOVE UNTIL THE~n~ROBBERY IS COMPLETED",ROBBING_BANK2[i]);
GameTextForPlayer(i,time,3000,3); //shows gametext showing the time remaining for the robbery
}
if(ROBBING_BANK2[i] == 1) // IF the timer reached 1
{
new string[256], pName[MAX_PLAYER_NAME];// getting player name
GetPlayerName(i,pName,MAX_PLAYER_NAME);
ROBBING_BANK2[i] =0; // RESET timer
new earning =random(95000);
format(string,sizeof(string),"%s (%d) has stolen $%d from National Bank in EL Quebrados (BC)!",pName,i,earning);
SendClientMessageToAll(COLOR_CYAN,string);
format(string,sizeof(string),"ROBBERY COMPLETED");
GameTextForPlayer(i,string, 1000, 3);
format(string,sizeof(string),"Gread Job! You completed the robbery, profit: $%d", earning); //sending message to the player that robbery was complete
SendClientMessage(i,GREEN,string);
GivePlayerCashEx(i, earning);
SetPlayerWantedLevel(i, GetPlayerWantedLevel(i) + 1); //giving player 1 wanted level
GivePlayerScore(i,1);
pInfo[i][pStoreRobbed] ++;
pInfo[i][pStoreRobbedMoney] = pInfo[i][pStoreRobbedMoney] +earning;
}
PHP код:
if(checkpointid == BankRobbery)
{
TextDrawHideForPlayer(playerid, banktd);
TextDrawHideForPlayer(playerid, banktdbox);
if(ROBBING_BANK1[playerid] >= 1) //checking if the person was robbing and his robbery timer was above 1
{
SendClientMessage(playerid, ROJO, "You have left checkpoint. Robbery Failed"); //Error message that he failed
GameTextForPlayer(playerid,"~r~Robbery Failed", 3000, 5);
ROBBING_BANK1[playerid] =0; // Setting Robbing_tatoo to 0. to stop the counter
HasDied{playerid} = true;
return 1;
}
}
if(checkpointid == BankRobbery2)
{
TextDrawHideForPlayer(playerid, banktd);
TextDrawHideForPlayer(playerid, banktdbox);
if(ROBBING_BANK2[playerid] >= 1) //checking if the person was robbing and his robbery timer was above 1
{
SendClientMessage(playerid, ROJO, "You have left checkpoint. Robbery Failed");
GameTextForPlayer(playerid,"~r~Robbery Failed", 3000, 5); //Error message that he failed
ROBBING_BANK2[playerid] =0; // Setting Robbing_tatoo to 0. to stop the counter
HasDied{playerid} = true;
return 1;
}
}