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";
x = 300;
y = 200;
new GuiTextEditCtrl("input")
{
profile = GuiBlueTextEditProfile;
x = 5;
y = 5;
width = 155;
height = 30;
text = "";
}
new GuiButtonCtrl("Clear")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "Clear";
width = 35;
x = 5;
y = 45;
}
new GuiButtonCtrl("plusmin")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "+/-";
width = 35;
x = 45;
y = 45;
}
new GuiButtonCtrl("divide")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "%";
width = 35;
x = 85;
y = 45;
}
new GuiButtonCtrl("multiply")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "X";
width = 35;
x = 125;
y = 45;
}
new GuiButtonCtrl("seven")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "7";
width = 35;
x = 5;
y = 75;
}
new GuiButtonCtrl("eight")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "8";
width = 35;
x = 45;
y = 75;
}
new GuiButtonCtrl("nine")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "9";
width = 35;
x = 85;
y = 75;
}
new GuiButtonCtrl("subtract")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "-";
width = 35;
x = 125;
y = 75;
}
new GuiButtonCtrl("four")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "4";
width = 35;
x = 5;
y = 105;
}
new GuiButtonCtrl("five")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "5";
width = 35;
x = 45;
y = 105;
}
new GuiButtonCtrl("six")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "6";
width = 35;
x = 85;
y = 105;
}
new GuiButtonCtrl("add")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "+";
width = 35;
x = 125;
y = 105;
}
new GuiButtonCtrl("one")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "1";
width = 35;
x = 5;
y = 135;
}
new GuiButtonCtrl("two")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "2";
width = 35;
x = 45;
y = 135;
}
new GuiButtonCtrl("three")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "3";
width = 35;
x = 85;
y = 135;
}
new GuiButtonCtrl("equals")
{
profile = GuiBlueButtonProfile;
height = 55;
text = "=";
width = 35;
x = 125;
y = 135;
}
new GuiButtonCtrl("zero")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "0";
width = 75;
x = 5;
y = 165;
}
new GuiButtonCtrl("dot")
{
profile = GuiBlueButtonProfile;
height = 25;
text = ",";
width = 35;
x = 85;
y = 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?