Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Awesome, another gani related question! (https://forums.graalonline.com/forums/showthread.php?t=72222)

xXziroXx 02-16-2007 11:43 AM

Awesome, another gani related question!
 
So like, Ive been having this problem for quite some time now.. its the same problems Stan recently posted about, but I didnt want to hijack his thread with my own question.

I checked that thread, didnt come up with a solution. Perhaps Im just tired? Hmm.. so anyways, the problem:


PHP Code:

  player.attr[20] = "ml_hud.gani";
  
player.attr[21] = { "test""xd"}; 

PHP Code:

SCRIPT
function onPlayerEnters() setTimer(.05);

function 
onTimeOut()
{
  if (
player.attr[21] != NULL) {
    
this.pos = { player.1.5player.2player.};
    
showtext(201this.pos[0], this.pos[1] - 2"Verdana""b""TEST [" player.attr[21][1] @ "]");
  }
  
setTimer(.05);
}
SCRIPTEND 

This is displaying the text "TEST [xd]" over MY player, but I just see "TEST []" over the other players in the level. Same thing goes for everyone else, they only see the text "TEST [xd]" over themself and no one else.

My question is, how do I fix this?

ToNy_W 02-16-2007 03:03 PM

Hmm, arrays in player attributes never worked for me, what i do is convert my array to a string before sending it to the attributes, and it works fine...

this.array {"test", "array"};
player.attr[10] = (@this.array);
this.array = player.attr[10];

I remember readign on the forums about the same problem a couple of months ago but don't remember how it ended, so there might be a better solution but this oen works for me :P

Chompy 02-16-2007 04:10 PM

try
PHP Code:

player.attr[21] = "test, xd"

I've used that before..

xXziroXx 02-16-2007 04:30 PM

Quote:

Originally Posted by ToNy_W (Post 1278197)
Hmm, arrays in player attributes never worked for me, what i do is convert my array to a string before sending it to the attributes, and it works fine...

this.array {"test", "array"};
player.attr[10] = (@this.array);
this.array = player.attr[10];

I remember readign on the forums about the same problem a couple of months ago but don't remember how it ended, so there might be a better solution but this oen works for me :P

That would be me that posted it a few months ago, never got a working answer. And the array works, obviously, since it can be read. So I doubt thats the issue here.

Chompy 02-16-2007 04:37 PM

Wait, this is the same problem I had with my floating text >_>

I just have something to change/show the text when a other attr is changed while the attr[ 21] is changed, like

PHP Code:

player.attr19] = !player.attr19];
player.attr20] = "ml_hud.gani";
player.attr21] = { "test""xd"}; 

then show the text when player.attr[ 19] is changed.. :O
Just a thought tho

xXziroXx 02-16-2007 04:46 PM

Quote:

Originally Posted by Chompy (Post 1278226)
Wait, this is the same problem I had with my floating text >_>

I just have something to change/show the text when a other attr is changed while the attr[ 21] is changed, like

PHP Code:

player.attr19] = !player.attr19];
player.attr20] = "ml_hud.gani";
player.attr21] = { "test""xd"}; 

then show the text when player.attr[ 19] is changed.. :O
Just a thought tho

That just sounds ridiculous, and I sincerely hope that wont work. Sorry, but, I think I'll wait for someone to tell me WHY its not working.

Chompy 02-16-2007 04:46 PM

Quote:

Originally Posted by xXziroXx (Post 1278229)
That just sounds ridiculous, and I sincerely hope that wont work. Sorry, but, I think I'll wait for someone to tell me WHY its not working.

Read the other thread I made, Kristi explained it pretty well..

http://forums.graalonline.com/forums...ad.php?t=72108 @ post 16

Chandler 02-16-2007 08:04 PM

In the gani, don't make it display the actual player attribute. Do something like
HTML Code:

function onCreated()
{
  this.doEffect(params[0]);
}
function doEffect(curText)
{
  showtext(301, player.x, player.y, "Arial", "bc", temp.curText);
  changeimgvis(301, 3);
  changeimgzoom(301, 0.8);
  setTimer(5);
}
function onTimeout()
{
  hideimg(301);
}

Then just make a loop of player attributes and then assign those attributes to the gani. If you don't understand this, I'll go futher more into details.

Admins 02-16-2007 08:16 PM

The problem is that attr[] are basicly strings (even if they look like normal variables). So it is better to do something like:
temp.var = player.attr[21];
echo("test: " @ temp.var[1]);

Kristi 02-16-2007 08:18 PM

Quote:

Originally Posted by xXziroXx (Post 1278223)
That would be me that posted it a few months ago, never got a working answer. And the array works, obviously, since it can be read. So I doubt thats the issue here.

I have a hunch, but I am at work so I cannot confirm or deny this right now, but checkit.

The array obviously is not working, a truth which contridicts your statement. Why would you be posting? :)

I am not sure what part of your npc you are pulling your code from but bear with me. You are assigning that attribute clientsided, yes? Your clientside variable may very well be able to store that array, that attr variable on your clientside is nothing more then a variable. HOWEVER, when another player pulls it from you, they are only getting the first index, since attr cannot handle anything else between clients. If my memory serves me correctly, attributes have to be strings. If this be the case, the optimal solution you have available to you is converting it to a string before sending it, such as putting the @ in front as I had earlier seen in this thread.


All times are GMT +2. The time now is 06:04 PM.

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