Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-22-2009, 02:33 AM
Deathborn123 Deathborn123 is offline
Owner of Dev Deathborn123
Deathborn123's Avatar
Join Date: Aug 2008
Location: Germany
Posts: 21
Deathborn123 is on a distinguished road
client. format

Hey There!

I just tried to call a public function with a client.var but probably wont work.
I guess its because the client.var got the wrong format.

What doesn't work ( calling the public function via the client.var)

PHP Code:
//#CLIENTSIDE

function onCreated()
{
client.test "test" //test would be the name of the Weapon where the public function is in. 
client.test.test2(); //test2 would be the public function. 

What would work ( calling the public function via the normal WeaponName)

PHP Code:
//#CLIENTSIDE

function onCreated()
{
"test".test2(); //test2 would be the public function. 

Support please
__________________
You cannot Prevent and Prepare for War at the same Time.

Last edited by Deathborn123; 09-22-2009 at 02:49 AM..
Reply With Quote
  #2  
Old 09-22-2009, 02:42 AM
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
I think I know what you're trying to do.

If you have a weapon called "myWeapon", you can just call it like this:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
myWeapon.testFunc();

if the weapon name has any weird characters/spaces, etc in it, you can do

PHP Code:
(@ "-System/My Weapon").testFunc(); 
for example.
__________________
Reply With Quote
  #3  
Old 09-22-2009, 02:45 AM
Deathborn123 Deathborn123 is offline
Owner of Dev Deathborn123
Deathborn123's Avatar
Join Date: Aug 2008
Location: Germany
Posts: 21
Deathborn123 is on a distinguished road
Not quite exactly, but it worked thanks
__________________
You cannot Prevent and Prepare for War at the same Time.
Reply With Quote
  #4  
Old 09-22-2009, 02:27 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
If you still want to use client.vars, do the following:
PHP Code:
( @ client.var).func(); 
Reply With Quote
  #5  
Old 09-22-2009, 02:50 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 Crow View Post
If you still want to use client.vars, do the following:
PHP Code:
( @ client.var).func(); 
Wrong.

PHP Code:
client.(@var @ "_propersyntax").(@subvar "_isawesome").(@etc
To call a function from a string, this would be best:

PHP Code:
temp.weapon_name "myWeapon";
temp.function_name "myFunction";

// Weapon based on string
(@temp.weapon_name).myFunction(param1param2etc);
// Function based on string
myWeapon.(@temp.functon_name)(param1param2etc);
// Weapon AND function based on string
(@temp.weapon_name).(@temp.function_name)(param1param2etc); 
Threw in some extra examples.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 09-22-2009, 03:00 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by xXziroXx View Post
Wrong.
Not at all. Let's assume that client.var holds the string "-System", the name of the weapon npc (let's also assume that weapon npc exists). You could then either do:
PHP Code:
( @ "-System").func(); 
or:
PHP Code:
( @ client.var).func(); 
Reply With Quote
  #7  
Old 09-22-2009, 03:33 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
It's probably not a good idea to leave it open-ended (client.var) like that though, and it's a waste of a client variable.
__________________
Quote:
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 12:04 AM.


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