Raised This Month: $32 Target: $400
 8% 

CS Store + API


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   General Purpose       
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-25-2013 , 21:45   CS Store + API
Reply With Quote #1


v1.0.3
by Blizzard_87

ThreadStart
CS Store is like the default buy menu, but with a difference.
your currency is Credits which is earned by killing enemies,
the prices of guns/items should always be high as once you purchase
them they are stored into your inventory permanetly, and can be equiped
every round ( but only once ), items/guns can also be refunded or gifted.
To use the API function you need to include the file thats attached cs-store.inc
into the plugin you want it to work in. then use these natives
get_user_credits( id ); will return the players current credits
give_user_credits( id, 100 ); will return giving the player 100 more credits
save_user_credits( id ); will return saving the users current credit count
Example Of Using API
say /store - opens up the CS Store Main Menu to select a catagory to buy from.
say /shop - opens up the CS Store Main Menu to select a catagory to buy from.
say /inv - opens up the CS Store Inventory Menu to select either Equip, Refund, Gift ( to player ).
say /inventory - opens up the CS Store Inventory Menu to select either Equip, Refund, Gift ( to player ).
say /credits - enables or disables showing the HUD Message of how many credits you have.
say /help - opens up a MOTD window showing the plugin commands and what they do.
Spoiler

ConnorMcleod
- enum optimize and nVault save/load optimize.
- suggesting putting stocks in sma instead of inc file.
hornet - help with API
You must compile this plugin locally with provided include file. - now you can compile from Get Plugin Link

You must place csstore.cfg file in your addons\amxmodx\configs\ directory.

I've Added The CS Store Logo image incase my hosting of the image is ever disrupted.
Change Log


File Download Count
85 + Current

ThreadStart
.
Attached Files
File Type: cfg csstore.cfg (1.5 KB, 416 views)
File Type: sma Get Plugin or Get Source (CS-Store-API-Example.sma - 1063 views - 700 Bytes)
File Type: inc cs-store.inc (278 Bytes, 404 views)
File Type: sma Get Plugin or Get Source (CS-Store1.0.3.sma - 1179 views - 48.3 KB)
__________________

Last edited by Blizzard_87; 04-29-2015 at 08:19.
Blizzard_87 is offline
Closer456
Member
Join Date: May 2013
Old 05-25-2013 , 23:21   Re: CS Store
Reply With Quote #2

Wow.. really nice!
Can you add custom weapons too?

Last edited by Closer456; 05-25-2013 at 23:24.
Closer456 is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-25-2013 , 23:29   Re: CS Store
Reply With Quote #3

Quote:
Originally Posted by Closer456 View Post
Wow.. really nice!
Can you add custom weapons too?
thanks..

and not yet will see how it goes first.
__________________
Blizzard_87 is offline
WhyThis
Senior Member
Join Date: May 2013
Old 05-26-2013 , 01:06   Re: CS Store
Reply With Quote #4

Good job man . I'm waiting for last man standing ....
WhyThis is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-26-2013 , 02:31   AW: CS Store
Reply With Quote #5

Add natives so you can give credits using other plugins.
Anyway, great Job.
__________________
Kia is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-26-2013 , 03:30   Re: AW: CS Store
Reply With Quote #6

Quote:
Originally Posted by Kia View Post
Add natives so you can give credits using other plugins.
Anyway, great Job.
Thanks. I wanted to add that feature. But need to read more about how to do natives first before attempting to add them.
__________________
Blizzard_87 is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-26-2013 , 03:35   Re: CS Store
Reply With Quote #7

Sure, it's not hard.

First we need to register our library where our functions are inside.
PHP Code:
public plugin_natives() {
register_library("csstore"
Now, to add a function which can be used by others we use the "register_native"-function.
PHP Code:
register_native("get_user_credits","_func_get_credits"
Here a simple example for such a function

PHP Code:
public _func_get_points(id)
{
    return 
iSkillPoints[get_param(1)]

Or for setting points

PHP Code:
public _func_set_points(idvalue)
{
    new 
plr get_param(1);
    
iSkillPoints[plr] = max(0get_param(2));
    
Save_MySql(plr);
    return 
iSkillPoints[plr];

That's about the functions, now we need to make our include file.

At first we look what AMXX Version is used and use the correct one to register our library.

PHP Code:
#if defined _skill_included
    #endinput
#endif

#define _skill_included

#if AMXX_VERSION_NUM >= 175
    #pragma reqlib skillpoints
    #if !defined AMXMODX_NOAUTOLOAD
        #pragma loadlib skillpoints
    #endif
#else
    #pragma library skillpoints
#endif 
Then we add our natives like this

PHP Code:
native get_user_skill(id
__________________
Kia is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-26-2013 , 03:57   Re: CS Store
Reply With Quote #8

Thanks. I'll try adding it to update when I understand it.
__________________
Blizzard_87 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-26-2013 , 04:20   Re: CS Store
Reply With Quote #9

.inc is useless and prevent people from compiling plugin from site, so from using your plugin, put functions directly in sma could be better ;)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
indradullanov
Member
Join Date: Sep 2012
Location: Indonesian
Old 05-26-2013 , 04:22   Re: CS Store
Reply With Quote #10

Add Weapon CSO please
indradullanov is offline
Send a message via Yahoo to indradullanov
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode