[FilterScript] Deer Hunter Job
#5

Quote:
Originally Posted by Kristall
View Post
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!
erm, that code is just even more terrible


PHP Code:
// global variable
new Float:deerLocations[][] = {
    { 
0.00.00.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.4532126.7188 // deer 1
    
2021.1818, -494.020776.1904 // deer 2
    
{1632.5769, -599.744461.8233 // deer 3
    
1741.4386, -979.581736.6115 // deer 4
    
2553.6780, -963.433881.6685 // deer 5
    
2637.4963, -380.219557.9261 // deer 6
    
2406.9773, -403.468172.1762 // deer 7
};
// local execution
    
if(Deep_Deer[playerid] != 1)
        return 
false;
    
    if(
IsPlayerInRangeOfPoint(playerid3.5deerLocations[Deer[playerid][0], deerLocations[Deer[playerid][1], deerLocations[Deer[playerid][2])) { 
        
TogglePlayerControllable(playerid0); 
        
ApplyAnimation(playerid"BOMBER""BOM_Plant"4.1111110); 
        
Deep_Deer[playerid] = 0
        
Shoot_Deer[playerid] = 0
        
KillTimer(Meeters_BTWDeer[playerid]); 
        
SetTimer("Done_Deer"3500false); 
    } 
also for hte love of god, use line breaks.




for future releases, don't release anything unless the code has been optimized for best performance. i haven't checked the code at all, but just seeing this was tearing my eyes. gl.


_________________
Quote:
Originally Posted by CodeStyle175
View Post
again wtf is this shit?
PHP Code:
if(Deep_Deer[playerid] == 1) {
        if(
IsPlayerInRangeOfPoint(playerid3.52046.7698, -799.4532126.7188) && Deer[playerid] == || 
        
IsPlayerInRangeOfPoint(playerid3.52021.1818, -494.020776.1904) && Deer[playerid] == ||
        
IsPlayerInRangeOfPoint(playerid3.51632.5769, -599.744461.8233) && Deer[playerid] == ||
        
IsPlayerInRangeOfPoint(playerid3.51741.4386, -979.581736.6115) && Deer[playerid] == ||
        
IsPlayerInRangeOfPoint(playerid3.52553.6780, -963.433881.6685) && Deer[playerid] == ||
        
IsPlayerInRangeOfPoint(playerid3.52637.4963, -380.219557.9261) && Deer[playerid] == ||
        
IsPlayerInRangeOfPoint(playerid3.52406.9773, -403.468172.1762) && Deer[playerid] == 7){
            
TogglePlayerControllable(playerid0);
            
ApplyAnimation(playerid"BOMBER""BOM_Plant"4.1111110);
            
Deep_Deer[playerid] = 0;
            
KillTimer(Meeters_BTWDeer[playerid]);
            
Shoot_Deer[playerid] = 0;
            
SetTimer("Done_Deer"3500false);
        }
    } 
no, that's not how math queries work, you're asking the server:
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.)
PHP Code:
if(Deep_Deer[playerid] == 1) {
        if((
IsPlayerInRangeOfPoint(playerid3.52046.7698, -799.4532126.7188) && Deer[playerid] == 1) || 
        (
IsPlayerInRangeOfPoint(playerid3.52021.1818, -494.020776.1904) && Deer[playerid] == 2) ||
        (
IsPlayerInRangeOfPoint(playerid3.51632.5769, -599.744461.8233) && Deer[playerid] == 3) ||
        (
IsPlayerInRangeOfPoint(playerid3.51741.4386, -979.581736.6115) && Deer[playerid] == 4) ||
        (
IsPlayerInRangeOfPoint(playerid3.52553.6780, -963.433881.6685) && Deer[playerid] == 5) ||
        (
IsPlayerInRangeOfPoint(playerid3.52637.4963, -380.219557.9261) && Deer[playerid] == 6) ||
        (
IsPlayerInRangeOfPoint(playerid3.52406.9773, -403.468172.1762) && Deer[playerid] == 7)){
        
TogglePlayerControllable(playerid0);
        
ApplyAnimation(playerid"BOMBER""BOM_Plant"4.1111110);
        
Deep_Deer[playerid] = 0;
        
KillTimer(Meeters_BTWDeer[playerid]);
        
Shoot_Deer[playerid] = 0;
        
SetTimer("Done_Deer"3500false);
    }

Reply


Messages In This Thread
Deer Hunter Job - by Kristall - 09.07.2018, 10:05
Re: Deer Hunter Job - by CodeStyle175 - 10.07.2018, 16:25
Re: Deer Hunter Job - by iNkyz - 11.07.2018, 16:23
Re: Deer Hunter Job - by Kristall - 20.07.2018, 14:55
Re: Deer Hunter Job - by DBZdabIt3Bro7 - 21.07.2018, 12:52

Forum Jump:


Users browsing this thread: 2 Guest(s)