Files

> > CS2D > Lua Scripts > Achievements v1.0
Files overviewCS2D overviewLua Scripts overview

English Achievements v1.0 >

8 comments4 kb, 442 Downloads

old Achievements v1.0

MikuAuahDark
User Off Offline

Achievements script by user MikuAuahDark

∗ Table of Contents ∗
1. Table of Contents
2. Description
3. Features
4. How to Install
5. Reserved Global Variables
6. Configuration
7. Limitations
8. Information
9. Addtional Information
10. Bit Code
11. More Achievements
12. Functions
13. Notes
14. Rules
15. Another MikuAuahDark Scripts

∗ Description ∗
This LUA allows you to add a mission-like script. So it's similar of this file cs2d Mission system V.0.1 lua, but this LUA is better. Because you can simply add new achievements

∗ Features ∗
• Can trigger on 32 events/hooks
• Stand-alone functions
• file cs2d table.uneval
• Events/Hooks are bit encoded
• Can save/load achievements progress
• Just the functions, you need to integrate it to your scripts
• Easy to add new achievements

∗ How to Install ∗
° It's different than another scripts °
1. Extract only achievements.txt to desired folder
2. Edit your code(NOT the achievements.txt) so it integrated to the script. Check achievements_int.txt for more information to link it
3. Make sure that the integrated code is loaded on server start. Add it to dofile list at server.lua
4. Run the script

∗ Reserved Global Variables ∗
• Achievements
• HOOK_*
• SaveDir
• DefaultSuccessMessage
• Unsigned_4
• BitEnc_4
• DiscoverActualName(*)
• OR
• AND
(*) - This function is used internally for achievement script. Don't use it for your another scripts

∗ Configuration ∗
Configuration variable is located at achievements.txt
> SaveDir - Save directory, where the player achievements status should be saved. Default is sys/lua/achievements
> DefaultSuccessMessage - Default success message that shown when specific achievements is complete. Default is Achievement '%s' complete!

∗ Limitations ∗
• You can't know if the specific achievements is complete without hardcoding the complete limit

∗ Information ∗
> Hooks: depending on achievements list(max 32)
> Size(achievements.txt): 7574 bytes

∗ Addtional Information ∗
This LUA Uses a bitwise system for the hook system. See Bit Code below
You can add more achievements by just using table.insert. See More Achievements below

∗ Bit Code ∗
This LUA uses a bitwise system to do some work, specially for the hook system. It only create new hook and function if the hook is not added.
List of Bit Code of Hooks >


∗ More Achievements ∗
Here is the format of the achievements
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
table.insert(Achievements.List,{	-- Simply use table.insert to Achievements.List table
	Name="Achievement Name",
	Desc="Achievement Description",
	Success="Message that shown when achievement is done",
	Variable="Table_name_to_use",
	CounterVariable="Variable_name_to_used_on_Variable",
	DefaultValue="Default value of CounterVariable",
	Used_Hooks=HOOK_BIT_VALUE, -- To use hook join, leave, and kill, then the value is "HOOK_KILL+HOOK_JOIN+HOOK_LEAVE"(without quotes)
	Hooks={
		-- This is list of function to executed when specific event/hooks is triggered
		-- For example, we are using "HOOK_ATTACK and HOOK_DIE" on this achievements
		-- NOTE that the function doesn't handle return values.
		[HOOK_ATTACK]=function(aid,id)	-- The first parameter is always the achievement ID itself, to used on "Achievements.Functions.Done(aid,id)" function. The rest of the parameter is hook-specific
			-- Do something
		end,
		[HOOK_KILL]=function(aid,id,pl,wpn,x,y)	-- Remember, the first parameter always the achievement id itself.
			-- Do something
		end,
	}
}
More example can you found on achievements.txt and achievements_int.txt

∗ Functions ∗
> Achievements.Functions.Init()
> • Info: It initialize all achievement system, also this function is returned by calling dofile to this lua
> ∗ Returns: none
> Achievements.Functions.List(id{number})
> • Info: Returns list of message about the current player achievements.
> • Parameters:
> • id - The player ID that you want to see the achievement status
> ∗ Returns: List of message that have this index: [1]=Achievement name, [2]=Achievement Description{table}
> Achievements.Functions.Save(id{number})
> • Info: Save player achievements status
> • Note: Anything is handled by the function so just call it without any USGN>0 checks
> • Parameters:
> • id - The player ID that you want to save
> ∗ Returns: none
> Achievements.Functions.Load(id{number})
> • Info: Load player achievement status
> • Note: Anything is handled by the function so just call it without any USGN>0 checks
> • Parameters:
> • id - Player id that gonna load the achievement status
> ∗ Returns: none
> Achievements.Functions.Done(aid{number},id{number})
> • Info: Show the complete message and save
> • Note: Calling this function always calling Achievements.Functions.Save function
> • Parameters:
> • aid - The achievement ID. It's always the first parameter on event functions.
> • id - The player ID who complete the achievement
> ∗ Returns: none

∗ Notes ∗
1. You should know it. The first place is always about feedbacks, bugs, post at comments.
2. It may need to set specific variable to allows it able to detecting if specific achievement is complete.
3. achievements_int.txt contains two example achievements. That file just used for testing only.

∗ Rules ∗
√ You can use it for your server
√ You can edit it. Edit with your own risk
√ You can upload at another website, say user MikuAuahDark made it
× You can't say this is yours
× You can't upload on another website without put me on credits

∗ Version History ∗
> V1.0
> >
ADDED
Initial Release

∗ Another MikuAuahDark Scripts
> file cs2d Timer Extra function(timerEx) v4.0
> file cs2d [UNUSED] Get Player Rank v1.4
> file cs2d Weapon Hudtxt v1.0
> file cs2d Animated Image v2.0
Approved by Seekay

Download Download

4 kb, 442 Downloads

Comments

8 comments
To the start Previous 1 Next To the start

Log in!

You need to log in to be able to write comments!Log in

old

-RZ-
User Off Offline

Ok, take my like. õ/ √
I like it!

old Yes

Ace Howl
User Off Offline

This is the script I want.
I like it!

old

71
COMMUNITY BANNED Off Offline

You have most biggest description for every file I have ever seen
Well, that's not the main point, good job!
I like it!

old #swag-description

Avo
User Off Offline

Seriously, use more-tags, please.

Btw, reminds me file cs2d Quest System v2.0 . Anyway, good piece of code, and what's very important - it's easy to add custom achievments.
I like it!

old

Joni And Friends
User Off Offline

hahaha... lol
I like it!
edited 1×, last 13.11.13 01:13:12 pm

old

hacked
User Off Offline

Mother of description.
I like it!
To the start Previous 1 Next To the start