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

Maths Genius


Post New Thread Reply   
 
Thread Tools Display Modes
Soulseker
Senior Member
Join Date: Sep 2005
Old 09-14-2006 , 15:36   Re: Maths Genius
Reply With Quote #11

1,02"105263157894736842" "period"

mhh why u dont add division ... and let every server admin
decide how hard the exercise should be :>
Soulseker is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 09-14-2006 , 16:00   Re: Maths Genius
Reply With Quote #12

I really like this idea. Nice!
__________________
Brad is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 09-14-2006 , 16:31   Re: Maths Genius
Reply With Quote #13

Add remainders.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Silencer123
Veteran Member
Join Date: Jul 2006
Old 09-14-2006 , 17:04   Re: Maths Genius
Reply With Quote #14

Quote:
Originally Posted by Soulseker View Post
1,02"105263157894736842" "period"

mhh why u dont add division ... and let every server admin
decide how hard the exercise should be :>
because then everyone sits in front of the computer with
a pocket calculator or does ALT + TAB to switch do Windows Calculator. ^^
And what do you mean with remainders?
like rounding the solution?
9.888 > 10
9.111 > 9
?
__________________
EAT YOUR VEGGIES
Silencer123 is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 09-14-2006 , 22:31   Re: Maths Genius
Reply With Quote #15

% = remainder symbol;

10%9 = 1

Which is really:

10/9 = 1
10-9 = 1 (Remainder after deviding)


so 100%30 would equal 10.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 09-15-2006 , 10:21   Re: Maths Genius
Reply With Quote #16

Sweaty, it's actually this:

Code:
public static int operator %(int param1, int param2) {     while(true)     {         if(param1 < param2)             break;         param1 -= param2;     }     return param1; }
__________________
Released six formerly private plugins. Not active here since ages.

Last edited by MaximusBrood; 09-15-2006 at 10:27.
MaximusBrood is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 09-15-2006 , 11:30   Re: Maths Genius
Reply With Quote #17

Nice plugin idea, I'm certainly going to use it, but it's badly optimized. I changed very much in your code.


My code compiles perfectly, but I haven't tried it ingame yet, so there might be some difficulties,
especially with stringbuilding, I probably overlooked something.

Here is the code:
(changelog is under plugin_init() )

Code:
#include <amxmodx> #include <amxmisc> #include <fun> new bool:solved = false; new solution = 0; new maxtries[33]; public plugin_init() {     //From 2.0 to 1.0? Yes! This plugin really wasn't finished when I started optimizing     register_plugin("Maths Genius", "1.0", "Silencer");         register_concmd("say", "checkSolution", 0, "Solution - Correct Answer is awarded with HP and AP");         register_cvar("amx_mg_level","2");     register_cvar("amx_mg_tries","2");     register_cvar("amx_mg_frequency","60.0");     register_cvar("amx_mg_award_hp","35");     register_cvar("amx_mg_award_ap","10");         set_task(get_cvar_float("amx_mg_frequency"), "buildQuestion"); } /** ** ** ** ** ** ** ** ** ** ** ** ** **/ /** Optimizations made by MaximusBrood: **/ /** ** ** ** ** ** ** ** ** ** ** ** ** **/ //Inverted unsolved to solved and made a bool out of it //Removed the FCVAR_ARCHIVE cvar flag //Caches HP and AP //Doesn't show 2 messages to the player who answered the question correctly anymore //Caches amx_mg_level //Totally reworked buildQuestion (exam). It's 40% of it's original size //   - Builds question in a for loop (no more endless if clauses) //   - Checks min- AND maxlevel with an inequality //   - Caches difficulty level //   - Resets maxtries on the blind and caches the cvar //Changed all function names and some variabled names for the better //NOTE: I could have converted all cvars to pointer ones, but I didn't. Too lazy :P public checkSolution(id) {     if(!solved)     {         new strAnswer[32];         read_argv(1, strAnswer, 31);                 new intAnswer = str_to_num(strAnswer);                 if(is_user_alive(id))         {             if(maxtries[id] > 0)             {                 if( intAnswer == solution)                 {                     //Prevent other users from answering quiz                     solved = true;                                         new awardHP = get_cvar_num("amx_mg_award_hp");                     new awardAP = get_cvar_num("amx_mg_award_ap");                                         //Give reward                     set_user_health(id, get_user_health(id) + awardHP );                     set_user_armor(id, get_user_armor(id) + awardAP);                                         //Pass message to winning player                     client_print(id, print_chat, "[MG] Your answer (%i) was correct - You won %i HP and %i AP", intAnswer, awardHP, awardAP);                                         //Don't message the already message winner                     new players[32], playersnum, currPlayer;                     get_players(players, playersnum, "c");                                         new winningUserName[32];                     get_user_name(id, winningUserName, 31);                                         for(new a = 0; a < playersnum; a++)                     {                         currPlayer = players[a];                                                 if(currPlayer == id)                             continue;                                                 client_print(currPlayer, print_chat,"[MG] %s's answer (%i) was correct - He won %i HP and %i AP", winningUserName, solution, awardHP, awardAP);                     }                 }                 else                 {                     maxtries[id]--;                     client_print(id, print_chat, "[MG] Your answer (%i) was incorrect - Remaining Tries: %i", intAnswer, maxtries[id]);                 }             }             else             {                 client_print(id, print_chat, "[MG] You have no more Tries left for this Round");             }         }         else         {             client_print(id, print_chat, "[MG] You can't answer now because you are dead");         }     }         return; } public questionTimeout() {     if(!solved)         client_print(0, print_chat, "[MG] You all were too slow - Learn more Math - The Solution was %i", solution);             solved = true;         set_task(get_cvar_float("amx_mg_frequency") / 2.0, "buildQuestion"); } public buildQuestion() {     new difficultyLevel = get_cvar_num("amx_mg_level");         //Inequality     if(0 < difficultyLevel <= 9)         return;             //Reset solution     solution = 0;         new strQuestion[64], pos = 0, currNumber;             //Build question     for(new a = 0; a <= difficultyLevel; a++)     {         currNumber = random_num(1, 99);         solution += currNumber;                 if( a == 0 )             pos += formatex(strQuestion[pos], 63 - pos, "%d", currNumber);         else             pos += formatex(strQuestion[pos], 63 - pos, " + %d", currNumber);     }         //Print it     client_print(0, print_chat, "[MG] Solve:  %s", strQuestion);             //Erm, huge optimization. Why check if he is connected? Why not caching the cvar?           //Resetting of tries     new tries = get_cvar_num("amx_mg_tries");         for(new a = 0; a < 33; a++)         maxtries[a] = tries;             solved = false;         //Set timeout     set_task(get_cvar_float("amx_mg_frequency") / 2.0, "questionTimeout"); }
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-15-2006 , 15:16   Re: Maths Genius
Reply With Quote #18

MaximusBrood: you failed at optimizing it.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
pope
Junior Member
Join Date: Nov 2005
Location: New York
Old 09-15-2006 , 15:27   Re: Maths Genius
Reply With Quote #19

Quote:
Originally Posted by Silencer123 View Post
the problem is if we got something like 97/95 or so. u cant do that with ur brain now can u?
Depends, I can, maybe some people can't, the plugin is called Math Genius though, not 'kinda ok at math'
__________________
pope is offline
Send a message via AIM to pope Send a message via MSN to pope Send a message via Yahoo to pope
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 09-15-2006 , 16:24   Re: Maths Genius
Reply With Quote #20

1 and 2/95...That isnt hard at all.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Reply



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 00:04.


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