problem with score timer achivement help please
#1

hello every so i been working on a timer and it works let me explain how it work, when player hits score 25 they will get message and armour exetras but the thing is i set timer to not repeat but its repeat here part of my codes

i put that on gameini idint work i put it on on OnPlayerKeyStateChange or i need make 2 timers ? idk
PHP код:
SetTimer("ACH"10000); 
PHP код:
forward ACH(); 
PHP код:
public ACH()
{
    for(new 
0i<MAX_PLAYERSi++)
    if(
GetPlayerScore(i) >= 25 && GetPlayerScore(i) <26)
    {
        
GivePlayerMoney(i1500);
        
SetPlayerArmour(i100);
        
GivePlayerWeapon(i26500);
        
SetPlayerSkillLevel(iWEAPONSKILL_SAWNOFF_SHOTGUN1);
        
SendClientMessage(i,COLOR_YELLOW,"Congratulations You Scored 25!");// if the player have the score give them something!
        
SendClientMessage(i,COLOR_YELLOW,"You got full armour and 1500$$ and unlocked the Sawnoff Shotgun!");
         
SendClientMessage(i,COLOR_YELLOW,"You can have 2 on your hands when you reach Score 50 ^_^");
        return 
1;
    }
    else
    {
        
//nothing
    
}
    for(new 
0i<MAX_PLAYERSi++)
     if(
GetPlayerScore(i) >= 25 && GetPlayerScore(i) <26)
    {
        
GivePlayerMoney(i2000);
        
SetPlayerArmour(i100);
        
GivePlayerWeapon(i31500);
        
SetPlayerSkillLevel(iWEAPONSKILL_SAWNOFF_SHOTGUN0);
        
SendClientMessage(i,COLOR_YELLOW,"Congratulations You Scored 50!");// if the player have the score give them something!
        
SendClientMessage(i,COLOR_YELLOW,"You unlocked The M4 Congrats!");
        return 
1;
    }
    else
    {
        
//nothing
    
}
    return 
1;

anyone know how fix this.
Reply
#2

Quote:
Originally Posted by UserName31
Посмотреть сообщение
hello every so i been working on a timer and it works let me explain how it work, when player hits score 25 they will get message and armour exetras but the thing is i set timer to not repeat but its repeat here part of my codes

i put that on gameini idint work i put it on on OnPlayerKeyStateChange or i need make 2 timers ? idk
PHP код:
SetTimer("ACH"10000); 
PHP код:
forward ACH(); 
PHP код:
public ACH()
{
    for(new 
0i<MAX_PLAYERSi++)
    if(
GetPlayerScore(i) >= 25 && GetPlayerScore(i) <26)
    {
        
GivePlayerMoney(i1500);
        
SetPlayerArmour(i100);
        
GivePlayerWeapon(i26500);
        
SetPlayerSkillLevel(iWEAPONSKILL_SAWNOFF_SHOTGUN1);
        
SendClientMessage(i,COLOR_YELLOW,"Congratulations You Scored 25!");// if the player have the score give them something!
        
SendClientMessage(i,COLOR_YELLOW,"You got full armour and 1500$$ and unlocked the Sawnoff Shotgun!");
         
SendClientMessage(i,COLOR_YELLOW,"You can have 2 on your hands when you reach Score 50 ^_^");
        return 
1;
    }
    else
    {
        
//nothing
    
}
    for(new 
0i<MAX_PLAYERSi++)
     if(
GetPlayerScore(i) >= 25 && GetPlayerScore(i) <26)
    {
        
GivePlayerMoney(i2000);
        
SetPlayerArmour(i100);
        
GivePlayerWeapon(i31500);
        
SetPlayerSkillLevel(iWEAPONSKILL_SAWNOFF_SHOTGUN0);
        
SendClientMessage(i,COLOR_YELLOW,"Congratulations You Scored 50!");// if the player have the score give them something!
        
SendClientMessage(i,COLOR_YELLOW,"You unlocked The M4 Congrats!");
        return 
1;
    }
    else
    {
        
//nothing
    
}
    return 
1;

anyone know how fix this.
First of all, this kind of check

X >= 1 && X < 2 is the same thing as doing == 1 (exclusively on integers, of course, because [1,2) would be positive for 1.1, 1.2, 1.(infinite), however since this is an integer and the are no decimals, just entires, [1,2) will always return positive for 1.)

Secondly, loop is not properly idented and/or braced;

And third, you should make the score checks after you set the score; or instead a variable that would make the players not receive the reward again.

If, for example, you set a player's score to +1, you have to check after that if the score is 25 or 50 and give the appropiate rewards, doing this on a timer to check if the player score is 25 or 50 will reward the players every time the timer is run, unless you add variables that forbid this from happening.
Reply
#3

Quote:
Originally Posted by CuervO
Посмотреть сообщение
First of all, this kind of check

X >= 1 && X < 2 is the same thing as doing == 1 (exclusively on integers, of course, because [1,2) would be positive for 1.1, 1.2, 1.(infinite), however since this is an integer and the are no decimals, just entires, [1,2) will always return positive for 1.)

Secondly, loop is not properly idented and/or braced;

And third, you should make the score checks after you set the score; or instead a variable that would make the players not receive the reward again.

If, for example, you set a player's score to +1, you have to check after that if the score is 25 or 50 and give the appropiate rewards, doing this on a timer to check if the player score is 25 or 50 will reward the players every time the timer is run, unless you add variables that forbid this from happening.
oooh wow i see thanks alot bro +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)