Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-30-2011, 06:28 PM
Linkishback Linkishback is offline
Banned
Linkishback's Avatar
Join Date: Jan 2005
Location: The Netherlands
Posts: 34
Linkishback is on a distinguished road
Send a message via AIM to Linkishback Send a message via MSN to Linkishback
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!
Reply With Quote
  #2  
Old 06-30-2011, 06:30 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Are you joining the class to the player on clientside or serverside?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 06-30-2011, 06:32 PM
Linkishback Linkishback is offline
Banned
Linkishback's Avatar
Join Date: Jan 2005
Location: The Netherlands
Posts: 34
Linkishback is on a distinguished road
Send a message via AIM to Linkishback Send a message via MSN to Linkishback
clientside
Reply With Quote
  #4  
Old 06-30-2011, 06:44 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Linkishback View Post
clientside
Try removing the //#CLIENTSIDE part from the class.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #5  
Old 06-30-2011, 06:44 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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 View Post
Try removing the //#CLIENTSIDE part from the class.
Definitely not going to fix the problem if he's trying to draw it clientside.
__________________
Reply With Quote
  #6  
Old 06-30-2011, 07:18 PM
Linkishback Linkishback is offline
Banned
Linkishback's Avatar
Join Date: Jan 2005
Location: The Netherlands
Posts: 34
Linkishback is on a distinguished road
Send a message via AIM to Linkishback Send a message via MSN to Linkishback
Yes, it says:
NPC Code:
GraalScript: Function showpoly not found in script of Player Linkishback

Reply With Quote
  #7  
Old 06-30-2011, 07:23 PM
Linkishback Linkishback is offline
Banned
Linkishback's Avatar
Join Date: Jan 2005
Location: The Netherlands
Posts: 34
Linkishback is on a distinguished road
Send a message via AIM to Linkishback Send a message via MSN to Linkishback
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;
}
}

Reply With Quote
  #8  
Old 06-30-2011, 11:17 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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.
Reply With Quote
  #9  
Old 06-30-2011, 11:27 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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(...);
__________________
Quote:
Reply With Quote
  #10  
Old 06-30-2011, 11:43 PM
Linkishback Linkishback is offline
Banned
Linkishback's Avatar
Join Date: Jan 2005
Location: The Netherlands
Posts: 34
Linkishback is on a distinguished road
Send a message via AIM to Linkishback Send a message via MSN to Linkishback
I didn't know I could link weapons to the player like that! Thanks for the tip!
Reply With Quote
  #11  
Old 06-30-2011, 11:48 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Linkishback View Post
I didn't know I could link weapons to the player like that! Thanks for the tip!
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:42 PM.


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