![]() |
Classes with guis
Ok, so, I am trying to make a sale system. Its just a basic gui that displays the item name, image, and a buy or cancel button.
The only thing is, I cant get it to display data. >< My npc in the level: HTML Code:
this.join("shops"); HTML Code:
//#CLIENTSIDE |
text = this.itemname;
? |
Well, why do you have the onCreated event in there man you don't need that. :) Just use mouse down as well instead of on action mouse. Give me a few moments to fix that up for you.
PHP Code:
|
Your problem is simply that the class needs to be joined clientside:
NPC Code: |
Ok, killer, all you did was change the mouse down part, and it didnt work.(the gui wouldnt even show. -.-)
Jk, your meathod didnt work either. =/ |
I see a few typos:
Quote:
|
When you do just this.itemname, without @ it appears as 0.
And it doesnt matter is height = 1 or 60, it still doesnt show. |
It doesn't matter the outcome, there's no need for the @.
|
So, why wont it show then? ><
I have tried everything. >_< It has to do with the gui, cause in the class, if you put say2(this.itemname); or message(this.itemname); it shows the correct data. But when you try in a gui, it just doesnt work. |
Use thiso.itemname for GUI Controls
|
Quote:
|
Omg!
It was that simple!? Now I feel like a complete idiot. -.- |
Yeah, when you are editing variables inside a control its pretty much like 'this.variable = value;'
To go outside of the current control you must use the thiso. prefix |
I was reading this thread from the top going, "oh come on!" ^^. Whenever you are using with (obj) { or new obj {, you are no longer accessing the original object so using this. won't find your original values. thiso. uses the original object you were working from.
|
One last thing. ><
I cant get the weapon to add to the player. =/ I have tried everything....whats wrong with this? HTML Code:
//#CLIENTSIDE HTML Code:
function onActionServerside(){ |
Quote:
PHP Code:
You never actually set anywhere in any of your script what this.item is. but if you did trying PHP Code:
PHP Code:
Edit: It also seems to me like you almost by Habit use @ at the start of variables for example PHP Code:
PHP Code:
|
It is a habit to write @ before variables. ><
I dont know why. >_< But, anyway, this.item is set in the level script as this.item = "Guns/Tommy Gun"; And it still doesnt work, even after your fixes. -.- |
Quote:
|
Quote:
|
Ok, heres the npc in the level:
HTML Code:
this.join("shops"); The shops class: HTML Code:
//#CLIENTSIDE The -shop npc: HTML Code:
function onActionServerside(){ |
Quote:
I just "modified" some of the script and added another way to add the weapon to the player (public functions in wnpcs) level npc PHP Code:
PHP Code:
PHP Code:
instead of using triggeractions to get to an other wnpc, use triggeraction to get serverside in the class, then trigger to the wnpc using the magic of object-oriented and public functions |
Still wont work. =/
Its the triggeraction that isnt working...cause, if you replace ShopFunctions.addShopItem(params[1]); with player.chat = "Test"; Nothing happens, so there is a problem in the triggeraciotn. -.- |
It would be params[0] wouldn't it? either do addWeapon(params[0]) or addWeapon(temp.item)
|
most of the corrections made are right but not put into the script correctly
|
Quote:
|
Quote:
first: I changed the styling and some vars from the original (your script), but didn't see this: PHP Code:
PHP Code:
second: change addWeapon(params[1]); to addWeapon(item); in ShopFunctions, I was using params[1] because I was thinking of the class (params[1] was the item there) class "shops": PHP Code:
PHP Code:
Quote:
should be addWeapon(item); in ShopFunctions Quote:
|
w00t go Chompy
|
Quote:
PHP Code:
|
I've used it both ways it really depends on what the scripts are for (GUIs and chests for example)
|
All times are GMT +2. The time now is 07:57 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.