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

[AMXX] Calculator v1.2.0


Post New Thread Reply   
 
Thread Tools Display Modes
Larcyn
Senior Member
Join Date: Oct 2010
Old 11-21-2011 , 10:13   Re: [AMXX] Calculator
Reply With Quote #11

Quote:
Originally Posted by FOUTA View Post
I play my cs in a window, so when i launch RUN, it doesnt get out of cs simple
Skip this discussion please.

Quote:
Originally Posted by Napoleon_be View Post
nice plugin larcyn;
Thank you.
__________________

Taking private requests, PM me for information.
Selling HideNSeek & Jailbreak plugins.

Selling Achievement API System (PHP &
MySQL / nVault)

Last edited by Larcyn; 11-21-2011 at 10:19.
Larcyn is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 11-21-2011 , 12:41   Re: [AMXX] Calculator
Reply With Quote #12

How much is 9*14? Fuck ill just launch cs!!
__________________
I am out of order!
grimvh2 is offline
Larcyn
Senior Member
Join Date: Oct 2010
Old 11-21-2011 , 14:06   Re: [AMXX] Calculator
Reply With Quote #13

Quote:
Originally Posted by grimvh2 View Post
How much is 9*14? Fuck ill just launch cs!!
haha, you got me laugh, anyway please try to keep those comments away.
__________________

Taking private requests, PM me for information.
Selling HideNSeek & Jailbreak plugins.

Selling Achievement API System (PHP &
MySQL / nVault)
Larcyn is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 11-22-2011 , 09:01   Re: [AMXX] Calculator
Reply With Quote #14

Use a stack for the calculations. You can then make operations such as : "3 + 4 - 1 * 7". More difficult but more useful
__________________
micapat is offline
MaHu
Member
Join Date: Jun 2011
Location: Belarus
Old 11-28-2011 , 09:25   Re: [AMXX] Calculator
Reply With Quote #15

nice plugin)
good job
MaHu is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 12-13-2011 , 14:39   Re: [AMXX] Calculator
Reply With Quote #16

This plugin would actually be good for JailBreak mod as sometimes admin ask a math question to choose who to be CT.

And
Quote:
Originally Posted by ConnorMcLeod
Add chat support would be cool.

Like someone writes :

Calc : 3 * 5 + 3

Print 18

Calc : 3 * ( 5 + 3 )

Print 24
I agree with you Connor .
It would actually be easier to use in chats .

Anyways, nice plugin .
pokemonmaster is offline
Old 12-14-2011, 06:09
echo_cs
This message has been deleted by ConnorMcLeod. Reason: bullshit
Larcyn
Senior Member
Join Date: Oct 2010
Old 12-20-2011 , 11:37   Re: [AMXX] Calculator
Reply With Quote #17

Version 1.1.0

Added chat support!

How to use:

First, you need to inform the plugin that we're going to calculate something, start by typing a " ! "

Then you need 2 values & a operator.

Example: What's the result of 3 + 5?

! 3 + 5
Output: 8



Edit:

Version 1.1.1

Optimized calculator through chat
__________________

Taking private requests, PM me for information.
Selling HideNSeek & Jailbreak plugins.

Selling Achievement API System (PHP &
MySQL / nVault)

Last edited by Larcyn; 12-20-2011 at 12:19. Reason: V1.1.1
Larcyn is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 12-20-2011 , 14:01   Re: [AMXX] Calculator
Reply With Quote #18

You should check this: http://forums.alliedmods.net/showthr...55#post1612755
It can solve any valid equation and you don't need to put spaces between operators and values.

Also in my opinion you should remove required ! (just check if what player said is valid equation) and instead of blocking say you could edit it and add at the end in green color " = <result>".
__________________
Impossible is Nothing
Sylwester is offline
enjoi.
Veteran Member
Join Date: Mar 2011
Old 12-21-2011 , 16:11   Re: [AMXX] Calculator
Reply With Quote #19

what about exponents? really dont know thorwing out ideas
__________________
Block Maker v6.0 []
Point Slay v3.0 []
Contact [ PM ]
enjoi. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-21-2011 , 16:54   Re: [AMXX] Calculator
Reply With Quote #20

Quote:
Originally Posted by Sylwester View Post
You should check this: http://forums.alliedmods.net/showthr...55#post1612755
It can solve any valid equation and you don't need to put spaces between operators and values.

Also in my opinion you should remove required ! (just check if what player said is valid equation) and instead of blocking say you could edit it and add at the end in green color " = <result>".
PHP Code:
#include <amxmodx>
#include <regex>

new Regex:pPattern
new szPattern[] = "[^^0-9\+\-\*\/\s]"

public plugin_init()
{
    
register_plugin("Chat Math""0.1""Fysiks")
    
register_clcmd("say""cmdSay")
    new 
errcodeerror[32]
    
pPattern regex_compile(szPatternerrcodeerrorcharsmax(error))
}

public 
cmdSay(id)
{
    static 
szArg[63], err
    read_args
(szArgcharsmax(szArg))
    
remove_quotes(szArg)
    
    if( 
regex_match_c(szArgpPatternerr) == )
    {
        
format(szArgcharsmax(szArg), "%s = %d"szArgmathEvaluateEquation(szArg))
        
engclient_cmd(id"say"szArg)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

// This algorithm by Sylwester
// http://forums.alliedmods.net/showpost.php?p=1612755&postcount=2
public mathEvaluateEquation(question[])
{
    static 
stack[6], toplen
    len 
strlen(question)
    for(new 
ii<leni++){
        switch(
question[i]){
            case 
'0'..'9'stack[top] = stack[top]*10+question[i]-'0'
            
case '+','-','/','*','x':{
                while(
top && (stack[top-1] == '*' || stack[top-1] == 'x' || stack[top-1] == '/' || question[i] == '+' || question[i] == '-')){
                    switch(
stack[top-1]){
                        case 
'+'stack[top-2] += stack[top]
                        case 
'-'stack[top-2] -= stack[top]
                        case 
'/'stack[top-2] /= stack[top]
                        case 
'*','x'stack[top-2] *= stack[top]
                    }
                    
top -= 2                    
                
}                
                
stack[++top] = question[i]            
                
stack[++top] = 0                
            
}
        }
    }
    while(
top>0){
        switch(
stack[top-1]){
            case 
'+'stack[top-2] += stack[top]
            case 
'-'stack[top-2] -= stack[top]
            case 
'/'stack[top-2] /= stack[top]
            case 
'*','x'stack[top-2] *= stack[top]
        }
        
top -= 2
    
}       
    return 
stack[top]

It only does integer math though.
__________________

Last edited by fysiks; 12-21-2011 at 16:58.
fysiks 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 13:02.


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