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

[ES] Calculator


  
 
 
Thread Tools Display Modes
Author Message
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-21-2010 , 21:19   [ES] Calculator
#1

Aburrido, se me ocurrio hacer esto:

Code:
/*  *   AMX Mod X Script *   ================ *       *       PLUGIN: Calculator *       AUTHOR: Alucard^ *       VERSION: 0.0.1          * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *         *                   This program is free software; you can redistribute it and/or modify it *                   under the terms of the GNU General Public License as published by the *                   Free Software Foundation; either version 2 of the License, or (at *                   your option) any later version. * *                   This program is distributed in the hope that it will be useful, but *                   WITHOUT ANY WARRANTY; without even the implied warranty of *                   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *                   General Public License for more details. * *                   You should have received a copy of the GNU General Public License *                   along with this program; if not, write to the Free Software Foundation, *                   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include <amxmodx> #include <amxmisc> #define PLUGIN  "Calculator" #define AUTHOR  "Alucard" #define VERSION "0.0.1" #define MAX_CHAR 32 new bool:g_CalActive[33]; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);         register_clcmd("say", "HookSayPlr");     register_clcmd("say_team", "HookSayPlr");         register_clcmd("say /calculator", "HookCmdCalculator"); } public client_connect(id)     g_CalActive[id] = false; public HookCmdCalculator(id) {     g_CalActive[id] = !g_CalActive[id];         client_print(id, print_chat, "La calculadora esta %sactivada", g_CalActive[id] ? "" : "des"); } public HookSayPlr(id) {     if(!g_CalActive[id])         return PLUGIN_CONTINUE;         new szSay[192];     read_args(szSay, 191);     remove_quotes(szSay); trim(szSay);         if(szSay[0] == ' ' || !isdigit(szSay[0]) || strfind(szSay, ".") )         return PLUGIN_CONTINUE;         static const HexOperators[5] =     {         0x2A, 0x2B, 0x2C, 0x2F, 0x5E     };         new bool:CanCalculate;     static hexChar;         for(new i = 0; i < sizeof(HexOperators); i++)     {         if(contain(szSay, HexOperators[i]) != -1)         {             CanCalculate = true;             hexChar = HexOperators[i];             break;         }     }         if(!CanCalculate)         return PLUGIN_CONTINUE;         new iLeft[MAX_CHAR], iRight[MAX_CHAR], iLeftValue, iRightValue;     strtok(szSay, iLeft, charsmax(iLeft), iRight, charsmax(iRight), hexChar, 1);         iLeftValue = str_to_num(iLeft); iRightValue = str_to_num(iRight);         switch(hexChar)     {         case 0x2A: iLeftValue *= iRightValue;         case 0x2B: iLeftValue += iRightValue;         case 0x2C: iLeftValue -= iRightValue;         case 0x2F: iLeftValue /= iRightValue;         case 0x5E: iLeftValue ^= iRightValue; // si no funca seria: power(iLeftValue, iRightValue);     }         client_print(id, print_chat, "Resultado %d", iLeftValue);         return PLUGIN_HANDLED_MAIN; }

Igualmente falta agregarle muchas otras cosas mas, mas operadores matematicos, que trabaje con floats, quizas con parentesis, etc... etc... y pulirlo mas. Pero esto seria la base.

Cabe aclarar que no lo testie asi que no se si funca. Si ven algun error, me avisan.

Y si alguien sabe si se puede resumir el switch( ) estaria bueno que me diga como =p (si es que se puede). Digamos algo como esto:

PHP Code:
iLeftValue hexCharRightValue
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...

Last edited by Alucard^; 06-21-2010 at 21:23.
Alucard^ is offline
Send a message via Skype™ to Alucard^
Zapdos1
BANNED
Join Date: Jul 2009
Location: Chile - La Serena
Old 06-21-2010 , 21:53   Re: [ES] Calculator
#2

que buena alucard, se ve buena la idea y útil en ciertos momentos dentro del juego.
el code aún no lo veo, pero por la pasada rápida que le dí, se ve bien.
Zapdos1 is offline
apuu
BANNED
Join Date: Oct 2009
Location: Argentina
Old 06-21-2010 , 22:10   Re: [ES] Calculator
#3

jajajaj xD una calculadora dentro del cs xD podrias hacerlo con messagemode y un menu
apuu is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-21-2010 , 22:17   Re: [ES] Calculator
#4

Quote:
Originally Posted by apuu View Post
jajajaj xD una calculadora dentro del cs xD podrias hacerlo con messagemode y un menu
Al principio se me ocurrio asi pero, despues pense... para que un menu? teniendo el chat. Es mucho mas sencillo el uso de parte del que quiere usar la calculadora... simplemente activa la calculadora y despues en el chat hace la operacion que quiere =p, despues quizas pongo para que sea /calculate num + num para que sea aun mas comodo y no se tenga que activar o desactivar la calculadora.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
apuu
BANNED
Join Date: Oct 2009
Location: Argentina
Old 06-21-2010 , 22:18   Re: [ES] Calculator
#5

no claro pero decia para poder hacer ejercicios combinados no estaria mal
apuu is offline
 



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 10:56.


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