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 12-20-2011, 11:12 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
variables and tokenize

Hello, I have been tooling around with this for quite a while now, and I can't quite put my finger on how to do this correctly. I have a series of variables that look a little something like this:
PHP Code:
this.test_Yes 4;
this.test_Yea 4;
this.test_Lol 2;
this.test_Abc 3
I am trying to pull information out of the string. For instance; Lets say my account is labeled "Yes", and my buddies account is "Lol". I want to see if our accounts are existant in the variable strings, and set the number as a client flag in their attributes.

For example:
My account is Yes, so looking at the above script, I would get the number '4' added to my attributes.

How am I able to pull this information out of the variables?
I hope all of the above makes sence.

Thanks in advance,
Alpho.
Reply With Quote
  #2  
Old 12-20-2011, 11:13 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
Based on your example:

temp.value = this.("test_" @ player.account);
__________________
Quote:
Reply With Quote
  #3  
Old 12-20-2011, 11:22 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
What about from this example:
PHP Code:
  this.acc_Graal756204 4
How would I check if someones account is after this.acc_ and if true, set something in their attrs to 4?
Reply With Quote
  #4  
Old 12-20-2011, 11:34 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
Change temp.value to whatever clientr.flag_you_want_to_store_it_in
__________________
Quote:
Reply With Quote
  #5  
Old 12-20-2011, 11:36 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by Alpho View Post
What about from this example:4
PHP Code:
  this.acc_Graal756204 4
How would I check if someones account is after this.acc_ and if true, set something in their attrs to 4?
Not sure (currently Trial again) but something like this could help:
PHP Code:
function onCreated() {
  
this.acc_Graal756204 4;
  
temp.check this.acc_.getvarnames();
  for (
temp.i=0temp.i<temp.check.size(); temp.i++) {
    if (
player.account in temp.check) {
      
player.attr[4] = this.acc_(@player.account);
      echo(
player.attr[4];
    }
  }

__________________
MEEP!
Reply With Quote
  #6  
Old 12-20-2011, 11:36 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
Quote:
Originally Posted by fowlplay4 View Post
Change temp.value to whatever clientr.flag_you_want_to_store_it_in


Ok, I tried the following:
PHP Code:
  this.acc_Graal756204 4;
  
clientr.stafflevel this.("acc_" player.account); 
results in nothing. Any ideas?
Reply With Quote
  #7  
Old 12-20-2011, 11:40 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
Quote:
Originally Posted by Alpho View Post
Any ideas?
What function are you doing this in?
__________________
Quote:
Reply With Quote
  #8  
Old 12-20-2011, 11:41 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
Tried what you said calli, sorry didn't work, tried a similar approach at it, same result:
PHP Code:
this.acc_Graal756204 4;
  
temp.check this.acc_.getvarnames(); 
  for (
temp.i=0temp.i<temp.check.size(); temp.i++) {
    if (
player.account in temp.check) { 
      echo(
this.acc_(@player.account)); 
    }
  } 
Reply With Quote
  #9  
Old 12-20-2011, 11:41 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
Quote:
Originally Posted by fowlplay4 View Post
What function are you doing this in?
Serverside, onCreated
Reply With Quote
  #10  
Old 12-20-2011, 11:45 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
Quote:
Originally Posted by Alpho View Post
Serverside, onCreated
That's because there's no 'player' object in onCreated in a Weapon or DB-NPC.
__________________
Quote:
Reply With Quote
  #11  
Old 12-20-2011, 11:51 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
Oh thanks, I see that now. This works:

PHP Code:
function onCreated() {
  
this.acc_Graal756204 4;
  
  echo(
this.("acc_Graal756204"));

how do you suppose I can get the 'player' object, 'in sight' ?



Edit: Got it to work
PHP Code:

function Set(pl) {
  
this.acc_Graal756204 4;
  echo(
this.("acc_"@pl));
}

function 
onActionServerSide() {
  if (
params[0] == "test") {
    
Set(params[1]);
  }
}

//#CLIENTSIDE
function onCreated() {
  
triggerserver("gui"name"test"player.account);


Last edited by Alpho; 12-20-2011 at 11:57 PM.. Reason: Got it to work
Reply With Quote
  #12  
Old 12-20-2011, 11:58 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
Quote:
Originally Posted by Alpho View Post
Oh thanks, I see that now. This works:

how do you suppose I can get the 'player' object, 'in sight' ?
If you're trying to set the value when the player logins you can do so in the onActionPlayerOnline function in Control-NPC or onPlayerLogin in other scripts.

If you want to 'find' the player object you can do like this:

findplayer("Graal756204").clientr.flag = this.acc_Graal756204;

or you can use with a statement:

PHP Code:
function onCreated() {
  
this.acc_Graal756204 4;
  
with (findplayer("Graal756204")) {
    
// You have to use thiso instead of just this because the 
    // with statement changes the scope to the player object.
    
clientr.flag thiso.("acc_" player.account);
  }

__________________
Quote:
Reply With Quote
  #13  
Old 12-21-2011, 12:12 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by fowlplay4 View Post
PHP Code:
    // You have to use thiso instead of just this because the 
    // with statement changes the scope to the player object. 
Not in this case.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #14  
Old 12-21-2011, 01:51 AM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
I got it all to work! Thanks for everyone's help.
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 07:45 AM.


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