if(PRESSED(KEY_WALK)) {
if(Deep_Deer[playerid] == 1) {
if(IsPlayerInRangeOfPoint(playerid, 3.5, 2046.7698, -799.4532, 126.7188) && Deer[playerid] == 1) {
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
Deep_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
Shoot_Deer[playerid] = 0;
SetTimer("Done_Deer", 3500, false);
}else if(IsPlayerInRangeOfPoint(playerid, 3.5, 2021.1818, -494.0207, 76.1904) && Deer[playerid] == 2) {
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
Deep_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
Shoot_Deer[playerid] = 0;
SetTimer("Done_Deer", 3500, false);
}else if(IsPlayerInRangeOfPoint(playerid, 3.5, 1632.5769, -599.7444, 61.8233) && Deer[playerid] == 3) {
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
Deep_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
Shoot_Deer[playerid] = 0;
SetTimer("Done_Deer", 3500, false);
}else if(IsPlayerInRangeOfPoint(playerid, 3.5, 1741.4386, -979.5817, 36.6115) && Deer[playerid] == 4) {
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
Deep_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
Shoot_Deer[playerid] = 0;
SetTimer("Done_Deer", 3500, false);
}else if(IsPlayerInRangeOfPoint(playerid, 3.5, 2553.6780, -963.4338, 81.6685) && Deer[playerid] == 5) {
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
TogglePlayerControllable(playerid, 0);
Deep_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
Shoot_Deer[playerid] = 0;
SetTimer("Done_Deer", 3500, false);
}else if(IsPlayerInRangeOfPoint(playerid, 3.5, 2637.4963, -380.2195, 57.9261) && Deer[playerid] == 6) {
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
TogglePlayerControllable(playerid, 0);
Deep_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
Shoot_Deer[playerid] = 0;
SetTimer("Done_Deer", 3500, false);
}else if(IsPlayerInRangeOfPoint(playerid, 3.5, 2406.9773, -403.4681, 72.1762) && Deer[playerid] == 7) {
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
TogglePlayerControllable(playerid, 0);
Deep_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
Shoot_Deer[playerid] = 0;
SetTimer("Done_Deer", 3500, false);
}
}
}
if(Deep_Deer[playerid] == 1) {
if(IsPlayerInRangeOfPoint(playerid, 3.5, 2046.7698, -799.4532, 126.7188) && Deer[playerid] == 1 ||
IsPlayerInRangeOfPoint(playerid, 3.5, 2021.1818, -494.0207, 76.1904) && Deer[playerid] == 2 ||
IsPlayerInRangeOfPoint(playerid, 3.5, 1632.5769, -599.7444, 61.8233) && Deer[playerid] == 3 ||
IsPlayerInRangeOfPoint(playerid, 3.5, 1741.4386, -979.5817, 36.6115) && Deer[playerid] == 4 ||
IsPlayerInRangeOfPoint(playerid, 3.5, 2553.6780, -963.4338, 81.6685) && Deer[playerid] == 5 ||
IsPlayerInRangeOfPoint(playerid, 3.5, 2637.4963, -380.2195, 57.9261) && Deer[playerid] == 6 ||
IsPlayerInRangeOfPoint(playerid, 3.5, 2406.9773, -403.4681, 72.1762) && Deer[playerid] == 7){
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
Deep_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
Shoot_Deer[playerid] = 0;
SetTimer("Done_Deer", 3500, false);
}
}
again wtf is this shit?
why are you repeating useless code liks this? PHP Code:
PHP Code:
|
Every time I finish doing an FS, I look around the code and realize that I could very easily reduce the number of lines exactly as you did. Thank you for your referral, and next time I'm going to try not to throw any unnecessary code lines. See' ya!
|
// global variable
new Float:deerLocations[][] = {
{ 0.0, 0.0, 0.0 } // id 0 (invalid) (ps: always start your IDs from 0 and up, if you need one that's invalid, refer to use negative 1 (-1)
{ 2046.7698, -799.4532, 126.7188 } // deer 1
{ 2021.1818, -494.0207, 76.1904 } // deer 2
{1632.5769, -599.7444, 61.8233 } // deer 3
{ 1741.4386, -979.5817, 36.6115 } // deer 4
{ 2553.6780, -963.4338, 81.6685 } // deer 5
{ 2637.4963, -380.2195, 57.9261 } // deer 6
{ 2406.9773, -403.4681, 72.1762 } // deer 7
};
// local execution
if(Deep_Deer[playerid] != 1)
return false;
if(IsPlayerInRangeOfPoint(playerid, 3.5, deerLocations[Deer[playerid][0], deerLocations[Deer[playerid][1], deerLocations[Deer[playerid][2])) {
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
Deep_Deer[playerid] = 0;
Shoot_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
SetTimer("Done_Deer", 3500, false);
}
_________________
again wtf is this shit?
PHP Code:
|
if (player is in range of coord) and (variable deer is x) or (player is in range of coord) and (variable deer is x)that's to say, if player is in range of coord and variable deer isn't x but player also is in range of second coord, then do this. (this would ofc be looped several times) and in the end your math query won't make any sense (the if statement) so to make your code actually run properly (to be noticed, this kind of if statement is not recommended and is bad practice.)
if(Deep_Deer[playerid] == 1) {
if((IsPlayerInRangeOfPoint(playerid, 3.5, 2046.7698, -799.4532, 126.7188) && Deer[playerid] == 1) ||
(IsPlayerInRangeOfPoint(playerid, 3.5, 2021.1818, -494.0207, 76.1904) && Deer[playerid] == 2) ||
(IsPlayerInRangeOfPoint(playerid, 3.5, 1632.5769, -599.7444, 61.8233) && Deer[playerid] == 3) ||
(IsPlayerInRangeOfPoint(playerid, 3.5, 1741.4386, -979.5817, 36.6115) && Deer[playerid] == 4) ||
(IsPlayerInRangeOfPoint(playerid, 3.5, 2553.6780, -963.4338, 81.6685) && Deer[playerid] == 5) ||
(IsPlayerInRangeOfPoint(playerid, 3.5, 2637.4963, -380.2195, 57.9261) && Deer[playerid] == 6) ||
(IsPlayerInRangeOfPoint(playerid, 3.5, 2406.9773, -403.4681, 72.1762) && Deer[playerid] == 7)){
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 1, 1, 1, 1, 1, 0);
Deep_Deer[playerid] = 0;
KillTimer(Meeters_BTWDeer[playerid]);
Shoot_Deer[playerid] = 0;
SetTimer("Done_Deer", 3500, false);
}
}