Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   showpoly inside class (https://forums.graalonline.com/forums/showthread.php?t=134263705)

Linkishback 06-30-2011 06:28 PM

showpoly inside class
 
Hi, I'm making a class to draw basic shapes but it won't draw!

CLASS: player-drawing
NPC Code:

//#CLIENTSIDE
public function showRect(id, x, y, width, height) {
showpoly(id, {x, y, x+width, y, x+width, y+height, x, y+height});
player.chat = "Nice rectangle!";
}



I call it by joining the class to the player and calling:

WEAPON: Gui
NPC Code:
player.showRect(201, 0,0,200,200);



Am I doing something wrong, or is it not posible to do this with a class?

Thanks!

xXziroXx 06-30-2011 06:30 PM

Are you joining the class to the player on clientside or serverside?

Linkishback 06-30-2011 06:32 PM

clientside

xXziroXx 06-30-2011 06:44 PM

Quote:

Originally Posted by Linkishback (Post 1656816)
clientside

Try removing the //#CLIENTSIDE part from the class.

cbk1994 06-30-2011 06:44 PM

Do you see anything in the Scripts tab in the F2 console? Also, try totally quitting your client and restarting it. Player-joined classes on clientside are very touchy.


Quote:

Originally Posted by xXziroXx (Post 1656817)
Try removing the //#CLIENTSIDE part from the class.

Definitely not going to fix the problem if he's trying to draw it clientside.

Linkishback 06-30-2011 07:18 PM

Yes, it says:
NPC Code:
GraalScript: Function showpoly not found in script of Player Linkishback


Linkishback 06-30-2011 07:23 PM

And I call it like this:

WEAPON: -System/Main
NPC Code:

//#CLIENTSIDE

function onPlayerEnters() {
player.join("player-drawing");
}

function onPlayerchats() {
tokens = player.chat.tokenize();
switch (tokens[0]) {
case "showclasses":
player.chat = "Joined classes:" SPC player.joinedclasses;
break;
case "rect":
player.showRect(10,10,100,100);
break;
}
}


ffcmike 06-30-2011 11:17 PM

I didn't think displays worked within the player object?
I think you need to have the drawing done within a weapon.

It's also not necessary to join the class onPlayerEnters.

fowlplay4 06-30-2011 11:27 PM

I don't see any real reason why you would want the 'player' object to draw it anyway. I would do something like this:

Weapon: -GUI

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
player.gui this;
}

public function 
showRect(idxywidthheight) {
  
showpoly(id, {xyx+widthyx+widthy+heightxy+height});
  
player.chat "Nice rectangle!";


In other scripts you should be able to do:

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
player.gui.showRect(2000064 64);


Honestly though I would just make the function public in the GUI and call the GUI directly instead of using a player function. I.e:

(@"-GUI").showRect(...);

Linkishback 06-30-2011 11:43 PM

I didn't know I could link weapons to the player like that! Thanks for the tip! :D

ffcmike 06-30-2011 11:48 PM

Quote:

Originally Posted by Linkishback (Post 1656857)
I didn't know I could link weapons to the player like that! Thanks for the tip! :D

It doesn't necessarily have to be to the player, you can do a global var "SystemGUI = this;" in the same way, I'm not sure if there's an advantage to putting it on the player object.


All times are GMT +2. The time now is 03:39 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.