AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Store (https://forums.alliedmods.net/forumdisplay.php?f=157)
-   -   Release Math Credits (https://forums.alliedmods.net/showthread.php?t=264848)

Arkarr 06-22-2015 08:40

Math Credits
 
19 Attachment(s)
Description :
This plugin display math question and the first player who answer correctly earn a random ammount of credits !
Based on this request.

Code:

[QUIZ]100 + 64 = ?? >>5 Credits<<
*DEAD* Spancer : 164
[QUIZ]Spancer is the winner he got 5 credits.

Screenshots & Videos :
None. Feel free to give me some nice shots ;) !

Cvar & Commands

Cvar :

sm_MathCredits_minimum_number 1 What should be the minimum number for questions ?
sm_MathCredits_maximum_number 100 What should be the maximum number for questions ?
sm_MathCredits_maximum_credits 50 What should be the maximum number of credits earned for a correct answers ?
sm_MathCredits_minimum_credits 5 What should be the minimum number of credits earned for a correct answers ?
sm_MathCredits_time_between_questions 50 Time in seconds between each questions.
sm_MathCredits_time_answer_questions 10 Time in seconds to give a answer to a question.
sm_MathCredits_store_select DEFAULT DEFAULT=Sourcemod store/ZEPHYRUS=use zephyrus store"

A config file is created on the first run of the plugin in cfg/sourcemod folder called MathCredits.cfg !

Commands :

None

Installation


1) Download the smx file
2) Put it into your plugins folder
3) Install Simple Chat Processor Redux
4) reload plugins folder by restarting server OR changing map OR typing sm reload plugins

Bugs :


Any ! Yay everything is fully working !

Request :

  • Nothing :¬|

Logs :
------
0.1 : First public release.
-------

Proz 06-22-2015 11:00

Re: Math Credits
 
Nice one.

Any plans on making a quiz based on questions that you can add in a config file along with the answer itself?

Arkarr 06-22-2015 11:11

Re: Math Credits
 
Quote:

Originally Posted by Proz (Post 2310655)
Nice one.

Any plans on making a quiz based on questions that you can add in a config file along with the answer itself?

Well, I guess, it's possible, but I don't see how I can implemant that, should I create a new plugin ?

Arrow768 06-22-2015 11:32

Re: Math Credits
 
Quote:

Originally Posted by Arkarr (Post 2310660)
Well, I guess, it's possible, but I don't see how I can implemant that, should I create a new plugin ?

I think a new module would be the way to go.

Maybe make it configurable via (dummy)-items in the webpanel.
So there is a item for each question.
The Question and the Results are defined via the json attrs.

Not sure if you can implement it this way, but I think it would be useful to do it that way.


About the Math Module:
I think it might be useful if you add the option to only ask questions if a certain number of players are dead.

Btw. I added the module to the overview

Arkarr 06-22-2015 12:42

Re: Math Credits
 
Quote:

Originally Posted by Arrow768 (Post 2310664)
Maybe make it configurable via (dummy)-items in the webpanel.

Like, how ? Question aren't things you can buy, can you ?
Quote:

Originally Posted by Arrow768 (Post 2310664)
So there is a item for each question.
The Question and the Results are defined via the json attrs.

I do not understand that. Something like that ? (I know it's not formatted like json should be)
PHP Code:

//
//NBR1 - Get a random number between CVAR_MAX and CVAR_MIN
//NBR2 - Get a random number between CVAR_MAX and CVAR_MIN
//
"1"
{
      
"Question"     "How much does NBR1 + NBR2 ?"
      "Answer"       "NBR1 + NBR2"
      "Reward"       "10"
      "Time"           "3"
}
"2"
{
      
"Question"     "How is the server callled ?"
      "Answer"       "Test server #1"
      "Reward"       "20"
      "Time"           "20"


Quote:

Originally Posted by Arrow768 (Post 2310664)
Not sure if you can implement it this way, but I think it would be useful to do it that way.

understandable.

Quote:

Originally Posted by Arrow768 (Post 2310664)
About the Math Module:
I think it might be useful if you add the option to only ask questions if a certain number of players are dead.

I will add that.

Quote:

Originally Posted by Arrow768 (Post 2310664)
Btw. I added the module to the overview

What does that mean ?

PS:
By the way, you have done a pretty nice job with the webpanel :3 !

Drixevel 06-22-2015 13:03

Re: Math Credits
 
Looks fine to me, only issue I see is the lack of registration. When you have a chance, have a look at the native in the backend module to register your plugin to the store database.

Code:

/**
 * Registers the plugin module for the webpanel to handle.
 * It's recommended that all modules register & refresh each plugin load. This is required in order for the webpanel to manage modules properly.
 *
 * @param sName                            Name of the plugin, this is just for reference.
 * @param sDescription                Description of the plugin, this is just for reference as well.
 * @param sVersion_ConVar        Name of the version ConVar the plugin uses.
 * @param sVersion                        Current version number of the plugin.
 * @noreturn
 */
native Store_RegisterPluginModule(const String:sName[], const String:sDescription[], const String:sVersion_ConVar[], const String:sVersion[]);


Arrow768 06-22-2015 13:08

Re: Math Credits
 
Quote:

Originally Posted by Arkarr (Post 2310685)
Like, how ? Question aren't things you can buy, can you ?

Currently we do not have a way to distribute configuration files across multiple servers.
So my idea is to use the json_attrs to distribute the data.
Basically the user adds 1 item for each question that contains the below mentioned attrs.
These items will be flagged as unbuyable (so its not listed in the store menu)

Once your module loads, it should be possible to get all the items that belong to that category.
Once you got the items, you can look at the attrs from each item to get the questions.
(Maybe you can use the item price as the reward thats given to the user)

Quote:

Originally Posted by Arkarr (Post 2310685)
I do not understand that. Something like that ? (I know it's not formatted like json should be)
PHP Code:

//
//NBR1 - Get a random number between CVAR_MAX and CVAR_MIN
//NBR2 - Get a random number between CVAR_MAX and CVAR_MIN
//
"1"
{
      
"Question"     "How much does NBR1 + NBR2 ?"
      "Answer"       "NBR1 + NBR2"
      "Reward"       "10"
      "Time"           "3"
}
"2"
{
      
"Question"     "How is the server callled ?"
      "Answer"       "Test server #1"
      "Reward"       "20"
      "Time"           "20"



Yes like that, but it should be json, so the webpanel can mass check all attrs if they are a valid json object. (Its a common error that people mess up the json syntax, so theres a json checker in the webpanel)
Oh, and multiple answers would be awesome


As I said, this are just some ideas.


Quote:

Originally Posted by Arkarr (Post 2310685)
What does that mean ?

Its listed here
https://forums.alliedmods.net/showthread.php?t=208774


Quote:

Originally Posted by Arkarr (Post 2310685)
PS:
By the way, you have done a pretty nice job with the webpanel :3 !

Thanks, but if you like the v1 panel, then you should take a look at the v2 panel

Arkarr 06-22-2015 13:11

Re: Math Credits
 
@r3dw3r3w0lf
Right, in fact, I scripted this without knowing anything about Store (wich was not that clever, I understand.) but, what ?
It's recommended that all modules register & refresh each plugin load.
What does that part mean ? Like I have to do ServerCommand("sm plugins reload [PLUGIN_NAME]"); after Store_RegisterPluginModule() ?

Drixevel 06-22-2015 13:14

Re: Math Credits
 
Quote:

Originally Posted by Arkarr (Post 2310703)
@r3dw3r3w0lf
Right, in fact, I scripted this without knowing anything about Store (wich was not that clever, I understand.) but, what ?
It's recommended that all modules register & refresh each plugin load.
What does that part mean ? Like I have to do ServerCommand("sm plugins reload [PLUGIN_NAME]"); after Store_RegisterPluginModule() ?

I'll re-type it but basically, it means it will register the module every time you input the function and update the settings in the web panel. This must be refreshed so the web panel can track which versions are running on which servers and tell you otherwise if they're outdated.

I'm making a post about it now since It's needed now but basically, this is how you should code it.

(Taken from the core module)
Code:

public Store_OnDatabaseInitialized()
{
        Store_RegisterPluginModule(PLUGIN_NAME, PLUGIN_DESCRIPTION, PLUGIN_VERSION_CONVAR, STORE_VERSION);
}

Everytime the database initializes, It'll register the plugin to the database for the web panel to use. If the version is the same, It'll just refresh stuff like the name, description, etc.

Arkarr 06-22-2015 13:18

Re: Math Credits
 
Quote:

Originally Posted by r3dw3r3w0lf (Post 2310704)
[...]

Oh... pretty easy-to-use in fact. Thanks adding that now.

EDIT:
Woups
Did I forgot a #include ? Currently I only have the <store> one.


All times are GMT -4. The time now is 17:28.

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