Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   client. format (https://forums.graalonline.com/forums/showthread.php?t=134256161)

Deathborn123 09-22-2009 02:33 AM

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 :)

cbk1994 09-22-2009 02:42 AM

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.

Deathborn123 09-22-2009 02:45 AM

Not quite exactly, but it worked thanks :)

Crow 09-22-2009 02:27 PM

If you still want to use client.vars, do the following:
PHP Code:

( @ client.var).func(); 


xXziroXx 09-22-2009 02:50 PM

Quote:

Originally Posted by Crow (Post 1524477)
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. :D

Crow 09-22-2009 03:00 PM

Quote:

Originally Posted by xXziroXx (Post 1524480)
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(); 


fowlplay4 09-22-2009 03:33 PM

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.


All times are GMT +2. The time now is 08:56 PM.

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