View Single Post
  #1  
Old 01-07-2010, 07:06 PM
Liberated Liberated is offline
not doing alot
Liberated's Avatar
Join Date: Feb 2008
Posts: 1,366
Liberated has a spectacular aura about
Calculator script

I'm working on this calculator script, it's far from done, but i've already come across a problem.
this is my script.
PHP Code:
//#CLIENTSIDE
function onWeaponFired()
{
  new 
GuiWindowCtrl("Calculator")
  {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "165, 200";
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide true;
    
text "Calculator";
    
300;
    
200;
    
    new 
GuiTextEditCtrl("input")
    {
      
profile GuiBlueTextEditProfile;
      
5;
      
5;
      
width 155;
      
height 30;
      
text "";
    }
    new 
GuiButtonCtrl("Clear")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "Clear";
      
width 35;
      
5;
      
45;
    }
    new 
GuiButtonCtrl("plusmin")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "+/-";
      
width 35;
      
45;
      
45;
    }
    new 
GuiButtonCtrl("divide")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "%";
      
width 35;
      
85;
      
45;
    }
    new 
GuiButtonCtrl("multiply")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "X";
      
width 35;
      
125;
      
45;
    }
        new 
GuiButtonCtrl("seven")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "7";
      
width 35;
      
5;
      
75;
    }
    new 
GuiButtonCtrl("eight")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "8";
      
width 35;
      
45;
      
75;
    }
    new 
GuiButtonCtrl("nine")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "9";
      
width 35;
      
85;
      
75;
    }
    new 
GuiButtonCtrl("subtract")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "-";
      
width 35;
      
125;
      
75;
    }
        new 
GuiButtonCtrl("four")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "4";
      
width 35;
      
5;
      
105;
    }
    new 
GuiButtonCtrl("five")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "5";
      
width 35;
      
45;
      
105;
    }
    new 
GuiButtonCtrl("six")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "6";
      
width 35;
      
85;
      
105;
    }
    new 
GuiButtonCtrl("add")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "+";
      
width 35;
      
125;
      
105;
    }
        new 
GuiButtonCtrl("one")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "1";
      
width 35;
      
5;
      
135;
    }
    new 
GuiButtonCtrl("two")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "2";
      
width 35;
      
45;
      
135;
    }
    new 
GuiButtonCtrl("three")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "3";
      
width 35;
      
85;
      
135;
    }
    new 
GuiButtonCtrl("equals")
    {
      
profile GuiBlueButtonProfile;
      
height 55;
      
text "=";
      
width 35;
      
125;
      
135;
    }
    new 
GuiButtonCtrl("zero")
    {
      
profile GuiBlueButtonProfile;
      
height 25;
      
text "0";
      
width 75;
      
5;
      
165;
    }
    new 
GuiButtonCtrl("dot")
    {
    
profile GuiBlueButtonProfile;
      
height 25;
      
text ",";
      
width 35;
      
85;
      
165;
    }
    
  }
}
function 
one.onAction()
{
  
input.text += 1;
}
function 
two.onAction()
{
  
input.text += 2;
}
function 
three.onAction()
{
  
input.text += 3;
}
function 
four.onAction()
{
  
input.text += 4;
}
function 
five.onAction()
{
  
input.text += 5;
}
function 
six.onAction()
{
  
input.text += 6;
}
function 
seven.onAction()
{
  
input.text += 7;
}
function 
eight.onAction()
{
  
input.text += 8;
}
function 
nine.onAction()
{
  
input.text += 9;

but the problem lies with these things
PHP Code:
function one.onAction()
{
  
input.text += 1;

instead of going 1, 11, 111 it goes, 1, 2, 3, so i need a way to add it as a string, and not as a number. Is there something like a str() function? so it will see it as a string?
__________________
Quote:
Originally Posted by Tigairius View Post
I promise when I get rich I'll send you an iPhone. I'll send everyone an iPhone.
Reply With Quote