Can somebody provide me with a GUI example, please? I can’t seem to learn how to make buttons… :ohdear:
There are a few threads on GUIs already. Find them.
I found out how to make GUI’s, I just can’t get the clicking fields right!
You need to be more specific. A lot of people end up using mousex and mousey instead of mousescreenx and mousescreeny.
if (mousescreenx in |300,315| && etc
You’re probably best off creating an array to store all the clicking fields values.
I never really did any click GUI’s so i’m just guessing here.
I’m 100% sure that I’m using mousescreenx and mousescreeny, although I just can’t seem to get the clicking fields right.
showimg 503,kondies_signcancel.gif,screenwidth/2-240,screenheight/2+24;
changeimgvis 503,4;
That’s that sign button that is on a picture GUI I want the selecting field to be at, and it is a 66x33 image.
if (leftmousebutton&&mousescreenx in |screenwidth/2-240,screenwidth/2-50| && mousescreeny in |screenheight/2+80,screenheight/2+50|) {
close()
}
This is the function I want it to work with, but obviously I have no idea how to make the clickfield.
This original sign image.
The button being placed on the sign.
showimg 500,kondies_sign.gif,screenwidth/2-271,screenheight/2-147;
changeimgvis 500,4;
This is the script for the placement of kondies_sign.gif
showimg 505,@TEMPSITC.TTF@bold@Price : Free,screenwidth/2-200,screenheight/2-100;
changeimgvis 505,4;
How can I change the font color of the script line above? (Just a question because it turns out white on the sign.)
if (created){
timeout = .05;
}
if (timeout){
showimg 503,block.png,screenwidth/2-240,screenheight/2+24;
changeimgvis 503,4;
if (mousescreenx in |screenwidth/2-240,screenwidth/2-240 + 32| && mousescreeny in |screenheight/2+24,screenheight/2+24+32|) {
if (leftmousebutton){
say2 fuck;
}
}
timeout = .05;
}
Change the + 32 to the width and height of your image. I would have made this more efficient and readable by using arrays, but I forget how to do them in Graal. It’s been to long.
Your screen positions were off so you were clicking in the wrong spot and also leftmousebutton was in the wrong spot.
if (mousescreenx in |screenwidth/2-240,screenwidth/2-240 + 66-33| && mousescreeny in |screenheight/2+24,screenheight/2+24+66-33|) {
close()
}
My image is 66x33, and this didn’t work, I have a very very good feeling that I’m doing it wrong… xD
here you go kondie, I made the script quickly and broke it up into easy to understand chunks
//Made by Tricxta
if (playerenters || timeout){
//timereverywhere added so the timout doesnt work for anyone but the leader
timereverywhere;
//placing the main image
showimg 500,kondies_sign.gif,screenwidth/2-(imgwidth(kondies_sign.gif)/2),screenheight/2-(imgheight(kondies_sign.gif)/2);
//change the image layer to the gui layers which are 4 and greater to read in pixels other wise the image will be placed in tile measurements also note for future reference that 1 tile is 16 pixels
changeimgvis 500,4;
//placing the close button image
showimg 501,kondies_signcancel.gif,screenwidth/2-140,screenheight/2+25;
changeimgvis 501,5;
//leftmousebutton is a passive flag and therefore a timeout is required for the leftmousebutton to register
if (leftmousebutton){
//add your button definitions here
//the numbers come from 140 which is where the image was placed since you start from the top left and work down right so -140+66 and 25+33 gives you the numbers for the script to check
if (mousescreenx in |screenwidth/2-140,screenwidth/2-74| && mousescreeny in |screenheight/2+25,screenheight/2+58|)close();
}
timeout=0.05;
}
function close(){
//hides images from the index 500 to 501
hideimgs 500,501;
//breaks the timeout loop
break;
}
oh and soz as i was writing the script you guys got all the essentials in
Thanks, it works, but can you explain to me how to make my own clickfields so I can make seperate GUI’s?
say you placed a image at screenwidth/2 on x and screenheight/2 on y and the image was 30x30 then you would simply type
if (leftmousebutton && mousescreenx in |screenwidth/2,screenwidth/2+30| && mousescreeny in |screenheight/2,screenheight/2+30|)
easy
[QUOTE=Kondie;51251]
showimg 505,@TEMPSITC.TTF@bold@Price : Free,screenwidth/2-200,screenheight/2-100;
changeimgvis 505,4;
How can I change the font color of the script line above? (Just a question because it turns out white on the sign.)
[/QUOTE]
changeimgcolors 505,1,1,1,.99;
Ohhh I get it, screenwidth = x screenheight = y
Thanks Tricxta for scripting help and thanks LoakeyRonso for font help!
screenwidth is equal to the width of your screen in pixels and screenheight is equal to the height, its preferable to use these rather then definied integers since they are more adaptable to everyones screen resolutions, I suggest if you have more trouble that you go over commands.rtf but everything has been covered here so not really any need for that lol
Yeah, I understand it now. Lol, it took me 4 hours to make a working GUI.
___Merged doublepost__________________
//Made by Tricxta
if (leftmousebutton || timeout){
//timereverywhere added so the timout doesnt work for anyone but the leader
timereverywhere;
//placing the main image
showimg 500,kondies_sign.gif,screenwidth/2-(imgwidth(kondies_sign.gif)/2),screenheight/2-(imgheight(kondies_sign.gif)/2);
changeimgvis 500,4;
//placing the close button image
showimg 501,kondies_signcancel.gif,screenwidth/2-140,screenheight/2+25;
changeimgvis 501,5;
showimg 502,kondies_signconfirm.gif,screenwidth/2+80,screenheight/2+25;
changeimgvis 502,5;
if (leftmousebutton){
//add your button definitions here
if (mousescreenx in |screenwidth/2-140,screenwidth/2-74| && mousescreeny in |screenheight/2+25,screenheight/2+58|)close();
if (mousescreenx in |screenwidth/2+80,screenwidth/2-74| && mousescreeny in |screenheight/2+25,screenheight/2+58|)buy();
}
timeout=0.05;
}
function close(){
hideimgs 500,502;
break;
}
function buy(){
hideimgs 500,502;
toweapons shittytest;
break;
}
I thought I understood
Can somebody fix this script please? The confirm button doesn’t work.
No one fucking listens or thanks me. You’re on your own bud.
Also wtf tricxta… I think you need to read commands.rtf timereverywhere…
AHAHAHAHA even if i did fking listen to you i wouldnt have gotten this far, no need to be a dick to me xP
I wasn’t being a dick at all.
If you want to simplify your script don’t use screenwidth and screenheight. Just use say
if (mousescreenx in |300,300 + imgwidth(block.png)| &&
just use the screenwidth shit when you understand the coords better.
then just do some shit like this.buttonx = 50 / 100 * screenwidth;
makes the shit look easier to understand.
Alright, I’m sorry for callin’ you a dick. Thanks for tryin to help man, I just don’t get your method. I’ve learned like everything I know from Tricxta, so he explains it to me in a really meaningful way to where I understand it.
Tad drunk, but here. It’s shitty, but oh well. Updated, but for some reason the fucking timeout ain’t dieing. I’m probably doing something stupid.
// NPC made by Sir Chicken of Awesometon
if (created) {
this.scrW = 50 / 100 * screenwidth;
this.scrY = 30 / 100 * screenheight;
timeout = 0.5;
}
if (timeout){
setplayerprop #c,asdsd;
if (leftmousebutton){
if (mousescreenx in |this.scrW - 350, this.scrW - 350 + imgwidth(kondies_signconfirm.gif)| &&
mousescreeny in |this.scrY + 130, this.scrY + 130 + imgheight(kondies_signconfirm.gif)|){
confirm();
}
if (mousescreenx in |this.scrW - 150,this.scrW - 150 + imgwidth(kondies_signcancel.gif)| &&
mousescreeny in |this.scrY + 130, this.scrY + 130 + imgheight(kondies_signcancel.gif)|){
cancel();
}
}
doImages();
timeout = .05;
}
function doImages(){
showimg 500,kondies_sign.gif,this.scrW - imgwidth(kondies_sign.gif),this.scrY;
changeimgvis 500,5;
showimg 501,kondies_signconfirm.gif,this.scrW - 350,this.scrY + 130;
changeimgvis 501,6;
showimg 502,kondies_signcancel.gif,this.scrW - 150,this.scrY + 130;
changeimgvis 502,6;
}
function confirm(){
timeout = 0;
killImage();
say2 Do your confirmed shit here. Okzz....;
}
function cancel(){
timeout = 0;
killImage();
say2 cancelled;
}
function killImage(){
for (i = 0; i < 2; i++){
hideimg 500 + i;
}
}
Thanks, I think I can fix it up from here