[Include] :: iAchieve :: Dynamic Achievement System - (Notify-on-achieve) (Stylish Textdraws) (uses Y_INI for saving/loading)
#1

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:
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:
2 Bugs Found and Solved. Thanks to the reporters/reasons.
- If you find one, report here please.

Reply
#2

Nice work.
Reply
#3

Nice piece of script. Looks nice, and easy to use!
Reply
#4

Very Nice Thanks
Reply
#5

Seen this on Cops and robbers servers ,
Good job!
Reply
#6

Quote:
Originally Posted by GameStar.
View Post
Nice work.
Quote:
Originally Posted by Zh3r0
View Post
Nice piece of script. Looks nice, and easy to use!
Quote:
Originally Posted by oFLu
View Post
Very Nice Thanks
Quote:
Originally Posted by Forbidden
View Post
Seen this on Cops and robbers servers ,
Good job!
Thanks for the quick and positive comments! ^_^
Reply
#7

PIECE OF CAKE, good job
Reply
#8

Great job, iPLEO.
Reply
#9

nice and thanks
will use..
Reply
#10

nice i will use thanks
Reply
#11

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. )
Reply
#12

That TD just looks sexy
Reply
#13

Haha, love the humour. Good job mate
Reply
#14

Awesome script, epic use of textdraws as well
Going to give it a try on my server.
Reply
#15

Thanks again everyone. =)

I noticed a simple bug which is fixed. (Unlocked var wasn't getting reset on disconnect, fixed now)
Reply
#16

Question, what does the unlockvalue do?
Reply
#17

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.

Reply
#18

lol ez kurva jу lett. its f**kin' nice! ++rep.
Reply
#19

Amazing!
Reply
#20

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");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)