:: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
iPLEOMAX -  18.08.2011
iAchieve
* Dynamic Achievement System *
Image
 
Hello Guys, This is another include release by me which is (i think) quite better than my other ones. ^^
What I've made here is an achievement system which automatically 
notifies a player on achievement and gives rewards as you wish...
How does this work?
Suppose you wan't a player to achieve "Sam Fisher" for having 20 fists kills in the night.
You simply do:
pawn Code:
//On top of script:
new Ach_SamFisher;
//In GameModeInit:
Ach_SamFisher = CreateAchievement("Sam Fisher","Nice Combat Skill!~n~You killed 20 people at night using only your fists!~n~+50 score and +50000$!", 20);
//Why '20' at last? Because that's how many kills you'll need someone to make.
 
Now, You add this: 
pawn Code:
GivePlayerAchievement(killerid, Ach_SamFisher, 1);// in OnPlayerDeath when someone punches a player at night.
//Now, whenever the player will do a fist kill at night, achievement will go up++. And When he does 20 fist kills, it pops up! YAY!
 
So, how to give prize?
pawn Code:
//There is this callback:
public OnPlayerAchieve( playerid, achid )
{
    if(achid == Ach_SamFisher)
    {
        GivePlayerMoney(playerid, 50000); SetPlayerScore(playerid, GetPlayerScore(playerid)+50);
        SendClientMessageToAll(0xFF0000FF, "Someone just achieved Sam Fisher achievement!");
    }
}
//You gave the prizes! cool!
 
Easy, isn't it? 
 Other functions/callbacks:
Other functions/callbacks:
pawn Code:
native CreateAchievement(title[], info[], unlockvalue); //Creates a new achievement.
native LoadPlayerAchievements(playerid); //Use this OnPlayerLogin or somewhere you like to load all achs.
native SetPlayerAchievement(playerid, achid, value); //Direct setting a value of an achievement.
native GivePlayerAchievement(playerid, achid, value); //adding/removing the value of an achievement.
native GetPlayerAchievement(playerid, achid); //Check how many times player did something for the ach.
native bool:DidPlayerAchieve(playerid, achid); //Did the player Achieve this Achievement?
 
Another Example:
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 520)
    {
        if(!DidPlayerAchieve(playerid, Ach_SamFisher))
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, 0xFF0000FF, "You need to achieve 'Sam Fisher' Achievement in order to use this!");
        }
    }
    return true;
}
 
NOTE: The default Max Achievements are '20' to increase it, 
add this at the top:
pawn Code:
#undef MAX_ACHIEVEMENTS
#define MAX_ACHIEVEMENTS 100 //to have 100 achievements.
 
Credits/Requirements:
****** :: 
YSI Includes - 
Download here
foreach - 
Download here
Deskoft ::
- His Ach System inspired me..
Me :: 
- for the work.
Save Location/Folder Path:
/scriptfiles/achievements/user/
/scriptfiles/achievements/main/
Note: If you don't have this path the system won't work.
Download: (Last Update: 25-Aug-11)
1) Fixed a minor 'unlock' bug.
2) Fixed SetPlayerAchievement Bug.
3) Fixed Crash on Loop bug
4) Made some corrections.
Pastebin - Patched version
Pastebin - Old
btw, edit the include as you wish, I don't have time for it and I can't release a newer version soon.
Thanks for visiting! 
 Bugs:
Bugs:
2 Bugs Found and Solved. Thanks to the reporters/reasons.
- If you find one, report here please.
 
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
GameStar. -  18.08.2011
Nice work.
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
Zh3r0 -  18.08.2011
Nice piece of script. Looks nice, and easy to use!
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
oFLu -  18.08.2011
Very Nice Thanks 
 
AW: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
Forbidden -  18.08.2011
Seen this on Cops and robbers servers ,
Good job!
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
iPLEOMAX -  19.08.2011
Quote:
| 
					Originally Posted by GameStar.  Nice work. | 
 
Quote:
| 
					Originally Posted by Zh3r0  Nice piece of script. Looks nice, and easy to use! | 
 
Quote:
| 
					Originally Posted by oFLu  Very Nice Thanks   | 
 
Quote:
| 
					Originally Posted by Forbidden  Seen this on Cops and robbers servers ,Good job!
 | 
 Thanks for the quick and positive comments! ^_^
Re : :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
Naruto_Emilio -  19.08.2011
PIECE OF CAKE, good job
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - Deskoft -  19.08.2011
Great job, iPLEO.
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
Kaperstone -  19.08.2011
nice and thanks 

will use..
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
doreto -  19.08.2011
nice i will use thanks
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
Lorenc_ -  19.08.2011
I would perfer the use of databases, can be quite more handy. 
Nice job. Better than those worthless ones with 1 simple function, I was going to make one as well. Kind of pointless now lol ( Since I haven't started. )
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
rbN. -  19.08.2011
That TD just looks sexy 
 
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
iMonk3y -  19.08.2011
Haha, love the humour. Good job mate 
 
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
gamer931215 -  19.08.2011
Awesome script, epic use of textdraws as well 

Going to give it a try on my server.
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
iPLEOMAX -  19.08.2011
Thanks again everyone. =)
I noticed a simple bug which is fixed. (Unlocked var wasn't getting reset on disconnect, fixed now)
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
gamer931215 -  19.08.2011
Question, what does the unlockvalue do?
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
iPLEOMAX -  19.08.2011
Quote:
| 
					Originally Posted by gamer931215  Question, what does the unlockvalue do? | 
 It checks if he crossed the required value to unlock the achievement.
To be more precise:
- Achievement: Pro Killer: 5000 Kills Required.
> new Ach_ProKiller;
> Ach_ProKiller = CreateAchievement("Pro Killer", "You killed 5000 times", 
5000); <- 5000 is the unlock value
> OnPlayerDeath : GivePlayerAchievement(killerid, Ach_ProKiller, 1); <- You increase the players kill ach by "1".
Thats all..
Now when player kills 5000 times, he gets the achievement.
 
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
KoczkaHUN -  19.08.2011
lol ez kurva jу lett. its f**kin' nice! ++rep.
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
TheArcher -  24.08.2011
Amazing!
Re: :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading) - 
Michael@Belgium -  24.08.2011
Awesome Work ! But i don't see the textdraw lol ... or maybe im doing something wrong ? This is what i have:
pawn Код:
new points;
//OnGameModeInit:
points = CreateAchievement("50 Points","Congratz with 50 points !! ~n~ Now you can use the Vehicle Missiles ! (/addmissiles)",50);
SetTimer("CheckAchievements",5000,true);
//somewhere else:
forward CheckAchievements(playerid);
public CheckAchievements(playerid)
{
    if(GetPlayerScore(playerid) >= 50) GivePlayerAchievement(playerid,points,1);
}
public OnPlayerAchieve( playerid, achid )
{
    if(achid == points) SendClientMessage(playerid,COLOR_GREEN, "Congratz ! You just got an achievement");
}