Raised This Month: $12 Target: $400
 3% 

Release Math Credits


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-22-2015 , 08:40   Math Credits
Reply With Quote #1

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.
-------
Attached Files
File Type: smx MathCredits.smx (8.2 KB, 1009 views)
File Type: sp Get Plugin or Get Source (MathCredits.sp - 871 views - 5.5 KB)
File Type: inc scp.inc (7.7 KB, 784 views)
File Type: inc store-core.inc (48.6 KB, 833 views)
File Type: inc zephyrus_store.inc (2.6 KB, 775 views)
__________________

Last edited by Arkarr; 03-18-2019 at 13:01.
Arkarr is offline
Proz
AlliedModders Donor
Join Date: Apr 2005
Old 06-22-2015 , 11:00   Re: Math Credits
Reply With Quote #2

Nice one.

Any plans on making a quiz based on questions that you can add in a config file along with the answer itself?
Proz is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-22-2015 , 11:11   Re: Math Credits
Reply With Quote #3

Quote:
Originally Posted by Proz View Post
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 ?
__________________
Arkarr is offline
Arrow768
Veteran Member
Join Date: Nov 2011
Location: Austria
Old 06-22-2015 , 11:32   Re: Math Credits
Reply With Quote #4

Quote:
Originally Posted by Arkarr View Post
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
__________________

Last edited by Arrow768; 06-22-2015 at 11:32.
Arrow768 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-22-2015 , 12:42   Re: Math Credits
Reply With Quote #5

Quote:
Originally Posted by Arrow768 View Post
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 View Post
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 View Post
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 View Post
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 View Post
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 !
__________________

Last edited by Arkarr; 06-22-2015 at 12:45.
Arkarr is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 06-22-2015 , 13:03   Re: Math Credits
Reply With Quote #6

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[]);
Drixevel is offline
Arrow768
Veteran Member
Join Date: Nov 2011
Location: Austria
Old 06-22-2015 , 13:08   Re: Math Credits
Reply With Quote #7

Quote:
Originally Posted by Arkarr View Post
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 View Post
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 View Post
What does that mean ?
Its listed here
https://forums.alliedmods.net/showthread.php?t=208774


Quote:
Originally Posted by Arkarr View Post
PS:
By the way, you have done a pretty nice job with the webpanel !
Thanks, but if you like the v1 panel, then you should take a look at the v2 panel
__________________
Arrow768 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-22-2015 , 13:11   Re: Math Credits
Reply With Quote #8

@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() ?
__________________
Arkarr is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 06-22-2015 , 13:14   Re: Math Credits
Reply With Quote #9

Quote:
Originally Posted by Arkarr View Post
@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.

Last edited by Drixevel; 06-22-2015 at 13:14.
Drixevel is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-22-2015 , 13:18   Re: Math Credits
Reply With Quote #10

Quote:
Originally Posted by r3dw3r3w0lf View Post
[...]
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.
__________________

Last edited by Arkarr; 06-22-2015 at 13:26.
Arkarr is offline
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 06:00.


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