//Enumerator
enum ShopRobbedRecently
{
TatooRobbedRecently = 0,
GymRobbedRecently = 0,
WellStackPizzaRobbedRecently[2] = 0,
CluckinBellRobbedRecently[2] = 0
}
new RobbedRecently[ShopRobbedRecently];
//Loop || short code || inside a 1000 mileseconds timer
for(new s; ShopRobbedRecently:s < ShopRobbedRecently; s++)
{
if(RobbedRecently[ShopRobbedRecently:s] > 1)
{
RobbedRecently[ShopRobbedRecently:s] --;
}
}
//Function || inside /robstore command
RobbedRecently[TatooRobbedRecently] = 100;
if(RobbedRecently[TatooRobbedRecently] >= 1) //if the TatooRobbedRecently is more than 1
return SendClientMessage(playerid, COLOR_WHITE, "Error: This shop has been robbed recently, please try again later!");
// and so on..
enum ShopRobbedRecently
{
TatooRobbedRecently,
GymRobbedRecently,
WellStackPizzaRobbedRecently[2],
CluckinBellRobbedRecently[2]
}
enum ShopRobbedRecently
{
TatooRobbedRecently,
GymRobbedRecently,
WellStackPizzaRobbedRecently[2],
CluckinBellRobbedRecently[3]
}
new RobbedRecently[ShopRobbedRecently];
CMD:robstore(playerid, params[])
{
new
string[ 256 ],
current_zone = player_zone[playerid]
;
if(pTeam[playerid] == TPolice || pTeam[playerid] == TArmy && IsPlayerLEO[playerid] == true) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": You can not rob a store while you are in Law Enforcement!");
if(IsPlayerInDynamicCP(playerid, rCheckpoints[7]))
{
if(zones[current_zone][zone_name] >= zones[93][zone_name] && zones[current_zone][zone_name] <= zones[95][zone_name]) //Espelanade East Tatoo Shop
{
if(RobbedRecently[TatooRobbedRecently] >= 1) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": This shop/store has been robbed recently, please try again later!");
Robbing[playerid][RobbingTatoo] = 20;
RobbedRecently[TatooRobbedRecently] = 300;
format(string,sizeof(string),"[DISPATCH]"COL_GREY": There's a robbery in progress! Suspect: %s | Shop Name: Tatoo Shop | Shop Location: %s",PlayerName(playerid), playerid, GetZoneName(playerid));
SendLEOMessage(string);
TextDrawShowForPlayer(playerid, RobberyTD[playerid]);
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0.1, -0.2, 0, 0, 90, 0.5, 0.8, 0.8, 0.8);
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
}
}
if(IsPlayerInDynamicCP(playerid, rCheckpoints[9]))
{
if(zones[current_zone][zone_name] == zones[116][zone_name] || zones[current_zone][zone_name] == zones[117][zone_name]) // Garcia Gym
{
if(RobbedRecently[GymRobbedRecently] >= 1) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": This shop/store has been robbed recently, please try again later!");
Robbing[playerid][RobbingGym] = 20;
RobbedRecently[GymRobbedRecently] = 300;
format(string,sizeof(string),"[DISPATCH]"COL_GREY": There's a robbery in progress! Suspect: %s | Shop Name: Gym | Shop Location: %s",PlayerName(playerid), playerid, GetZoneName(playerid));
SendLEOMessage(string);
TextDrawShowForPlayer(playerid, RobberyTD[playerid]);
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0.1, -0.2, 0, 0, 90, 0.5, 0.8, 0.8, 0.8);
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
}
}
if(IsPlayerInDynamicCP(playerid, rCheckpoints[10]))
{
if(zones[current_zone][zone_name] >= zones[96][zone_name] && zones[current_zone][zone_name] <= zones[98][zone_name]) //Espelanade North Well Stack Pizza
{
if(RobbedRecently[ WellStackPizzaRobbedRecently ][ 0 ] >= 1) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": This shop/store has been robbed recently, please try again later!");
Robbing[playerid][ RobbingWellStackPizza ][ 0 ] = 20;
RobbedRecently[ WellStackPizzaRobbedRecently][ 0 ] = 300;
format(string,sizeof(string),"[DISPATCH]"COL_GREY": There's a robbery in progress! Suspect: %s | Shop Name: Well Stack Pizza | Shop Location: %s",PlayerName(playerid), playerid, GetZoneName(playerid));
SendLEOMessage(string);
TextDrawShowForPlayer(playerid, RobberyTD[playerid]);
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0.1, -0.2, 0, 0, 90, 0.5, 0.8, 0.8, 0.8);
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
}
if(zones[current_zone][zone_name] == zones[102][zone_name]) //Financial Well Stack Pizza
{
if(RobbedRecently[ WellStackPizzaRobbedRecently ][ 1 ] >= 1) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": This shop/store has been robbed recently, please try again later!");
Robbing[playerid][ RobbingWellStackPizza ][ 1 ]= 20;
RobbedRecently[WellStackPizzaRobbedRecently ][ 1 ] = 300;
format(string,sizeof(string),"[DISPATCH]"COL_GREY": There's a robbery in progress! Suspect: %s | Shop Name: Well Stack Pizza 1 | Shop Location: %s",PlayerName(playerid), playerid, GetZoneName(playerid));
SendLEOMessage(string);
TextDrawShowForPlayer(playerid, RobberyTD[playerid]);
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0.1, -0.2, 0, 0, 90, 0.5, 0.8, 0.8, 0.8);
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
}
}
if(IsPlayerInDynamicCP(playerid, rCheckpoints[1]))
{
if(zones[current_zone][zone_name] >= zones[49][zone_name] && zones[current_zone][zone_name] <= zones[54][zone_name]) //Downton Cluckin Bell
{
if(RobbedRecently[ CluckinBellRobbedRecently ][ 0 ] >= 1) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": This shop/store has been robbed recently, please try again later!");
Robbing[playerid][ CluckinBell ][ 0 ] = 20;
RobbedRecently[ CluckinBellRobbedRecently ][ 0 ] = 300;
format(string,sizeof(string),"[DISPATCH]"COL_GREY": There's a robbery in progress! Suspect: %s | Shop Name: Cluckin Bell | Shop Location: %s",PlayerName(playerid), playerid, GetZoneName(playerid));
SendLEOMessage(string);
TextDrawShowForPlayer(playerid, RobberyTD[playerid]);
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0.1, -0.2, 0, 0, 90, 0.5, 0.8, 0.8, 0.8);
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
}
if(zones[current_zone][zone_name] >= zones[233][zone_name] && zones[current_zone][zone_name] <= zones[236][zone_name]) //Ocean Flats Cluckin Bell
{
if(RobbedRecently[ CluckinBellRobbedRecently ][ 1 ] >= 1) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": This shop/store has been robbed recently, please try again later!");
Robbing[playerid][ CluckinBell ][ 1 ] = 20;
RobbedRecently[ CluckinBellRobbedRecently ][ 1 ] = 300;
format(string,sizeof(string),"[DISPATCH]"COL_GREY": There's a robbery in progress! Suspect: %s | Shop Name: Cluckin Bell 1 | Shop Location: %s",PlayerName(playerid), playerid, GetZoneName(playerid));
SendLEOMessage(string);
TextDrawShowForPlayer(playerid, RobberyTD[playerid]);
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0.1, -0.2, 0, 0, 90, 0.5, 0.8, 0.8, 0.8);
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
}
if(zones[current_zone][zone_name] >= zones[93][zone_name] && zones[current_zone][zone_name] <= zones[95][zone_name]) //Espelanade East Cluckin Bell
{
if(RobbedRecently[ CluckinBellRobbedRecently ][ 2 ] >= 1) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": This shop/store has been robbed recently, please try again later!");
Robbing[playerid][ CluckinBell ][ 2 ] = 20;
RobbedRecently[ CluckinBellRobbedRecently ][ 2 ] = 300;
format(string,sizeof(string),"[DISPATCH]"COL_GREY": There's a robbery in progress! Suspect: %s | Shop Name: Cluckin Bell 2 | Shop Location: %s",PlayerName(playerid), playerid, GetZoneName(playerid));
SendLEOMessage(string);
TextDrawShowForPlayer(playerid, RobberyTD[playerid]);
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0.1, -0.2, 0, 0, 90, 0.5, 0.8, 0.8, 0.8);
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
}
}
return 1;
}
Just read over it, looks fine, I just dont know why you compare "zone_name" like integers
The problem with the enum was that if you set an value in the enum it is the index, means that all constants of the enum pointed to the index 0, thus changing all Could you tell me what exactly isnt working with the command anymore? Do you get the Unknown command response, did you checked any case with the crash dedect plugin ? If no way works use prints till you find the line where the code stops |
if(IsPlayerInDynamicCP(playerid, rCheckpoints[7]))
{
if(zones[current_zone][zone_name] >= zones[93][zone_name] && zones[current_zone][zone_name] <= zones[95][zone_name]) //Espelanade East Tatoo Shop
{
if(RobbedRecently[TatooRobbedRecently] >= 1) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": This shop/store has been robbed recently, please try again later!");
Robbing[playerid][RobbingTatoo] = 20;
RobbedRecently[TatooRobbedRecently] = 300;
format(string,sizeof(string),"[DISPATCH]"COL_GREY": There's a robbery in progress! Suspect: %s | Shop Name: Tatoo Shop | Shop Location: %s",PlayerName(playerid), playerid, GetZoneName(playerid));
SendLEOMessage(string);
TextDrawShowForPlayer(playerid, RobberyTD[playerid]);
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0.1, -0.2, 0, 0, 90, 0.5, 0.8, 0.8, 0.8);
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
}
}
if(IsPlayerInDynamicCP(playerid, rCheckpoints[7]))
{
if(zones[current_zone][zone_name] == zones[93][zone_name] || zones[current_zone][zone_name] == zones[94][zone_name] ||
zones[current_zone][zone_name] == zones[95][zone_name]) //Espelanade East Tatoo Shop
{
if(RobbedRecently[TatooRobbedRecently] >= 1) return SendClientMessage(playerid, COLOR_RED, "Error"COL_WHITE": This shop/store has been robbed recently, please try again later!");
Robbing[playerid][RobbingTatoo] = 20;
RobbedRecently[TatooRobbedRecently] = 300;
format(string,sizeof(string),"[DISPATCH]"COL_GREY": There's a robbery in progress! Suspect: %s | Shop Name: Tatoo Shop | Shop Location: %s",PlayerName(playerid), playerid, GetZoneName(playerid));
SendLEOMessage(string);
TextDrawShowForPlayer(playerid, RobberyTD[playerid]);
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0.1, -0.2, 0, 0, 90, 0.5, 0.8, 0.8, 0.8);
ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 3.0, 0, 0, 0, 0, 0, 1);
}
}
if(93 <= current_zone <= 95)
new Float:zones[][zoneinfo] =
{
... //all the zones by Makabos
}
printf("%d %s - %s %s %s", current_zone, zones[current_zone][zone_name], zones[93][zone_name], zones[94][zone_name], zones[95][zone_name]);
Use the working code and print out the ids and the names of the zones where the command works (test all places)
Put something like that behind the if(zones... so we only get the working results pawn Код:
That must be a huge checkpoint which covers 3 zones? |