18.08.2011, 23:46
(
Last edited by iPLEOMAX; 26/04/2012 at 07:23 PM.
)
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:
Now, You add this:
So, how to give prize?
Easy, isn't it? 
Other functions/callbacks:
Another Example:
NOTE: The default Max Achievements are '20' to increase it,
add this at the top:
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:
2 Bugs Found and Solved. Thanks to the reporters/reasons.
- If you find one, report here please.
* 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.
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!
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!

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?
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;
}
add this at the top:
pawn Code:
#undef MAX_ACHIEVEMENTS
#define MAX_ACHIEVEMENTS 100 //to have 100 achievements.
****** ::
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:
2 Bugs Found and Solved. Thanks to the reporters/reasons.
- If you find one, report here please.