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 10-14-2014, 07:38 PM
Struggler Struggler is offline
Zone Repulser =D
Struggler's Avatar
Join Date: May 2006
Posts: 54
Struggler is an unknown quantity at this point
Adding clientr variables via weapons

Hello, I was just wondering if maybe someone could help me, I seem to be having a lot of trouble adding a clientr variable to a player via the weapon he holds. Is there any way to accomplish this? So far I've tried clientr.[variablenamehere].add(0) but it thinks its an array so it automatically adds a comma after the number. I've also tried just clientr.[variablename] = 0 but it doesnt add the variable because it doesn't exist yet. Any help would be greatly appreciated

Note: Also tried clientr.[variablenamehere].add(0) and then using clientr.[variablenamehere] = 0 in the same script but it refuses to add it because clientr.[variablenamehere] = 0 seems to be faulty in some way.
Reply With Quote
  #2  
Old 10-14-2014, 07:49 PM
Struggler Struggler is offline
Zone Repulser =D
Struggler's Avatar
Join Date: May 2006
Posts: 54
Struggler is an unknown quantity at this point
An example of the current script I'm referring to (weapon script)
Quote:
function onActionServerside(){
if (params[0] == "updatevars"){
clientr.treescut = 0;
}
}
//#CLIENTSIDE
function onCreated(){
if (!clientr.treescut){
triggerserver("gui",this.name,"updatevars");
}
}
Reply With Quote
  #3  
Old 10-14-2014, 07:56 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Hopefully you're doing this on serverside.

When you do player.clientr.whatever = null; it shouldn't appear in your players attributes unless the value is anything other than null. So if you were to add the following within any serverside function: player.clientr.whatever = "supercoolvar"; echo(player.clientr.whatever); I'd expect to see supercoolvar output on RC. The reason you're able to see an output for player.clientr.whatever.add(0); is because you're creating an array which adds another null value every time the function is called.

Actually scrach that, are you trying to verify a tree has been cut down before you can chop it?
__________________
Reply With Quote
  #4  
Old 10-14-2014, 07:59 PM
Struggler Struggler is offline
Zone Repulser =D
Struggler's Avatar
Join Date: May 2006
Posts: 54
Struggler is an unknown quantity at this point
Ah so question: If I add a clientr variable they wont always appear in a player's script flags under attributes?

Because I tried echo, it echo'd the value correctly but its not displayed under script flags.

As of now I'm just trying to figure out how to get the clientr variables to work correctly so I can keep track of how many trees have been cut down.
Reply With Quote
  #5  
Old 10-14-2014, 08:06 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 Struggler View Post
Ah so question: If I add a clientr variable they wont always appear in a player's script flags under attributes?

Because I tried echo, it echo'd the value correctly but its not displayed under script flags.
like tim said, it wont display if it equals NULL or when it's blank. Try it with another number or string, like 1 or "hello".
Also make sure to use player.clientr.flag, not just clientr.flag
__________________
MEEP!
Reply With Quote
  #6  
Old 10-14-2014, 08:08 PM
Struggler Struggler is offline
Zone Repulser =D
Struggler's Avatar
Join Date: May 2006
Posts: 54
Struggler is an unknown quantity at this point
Ah, now it shows up when I changed it to 1. So how would I set a clientr variable to the number 0 then? Or should I just get it to detect that there's none and have a default conditional to go to if that's the case?

As clarification I'm trying to get it to actively read the clientr variable so that the player can keep track of how many trees he's cut down. But when the clientr variable is set to 0, it can't effectively keep track of it. Are clientr variables 0 by default? Is 0 the equivelant of null?
Reply With Quote
  #7  
Old 10-14-2014, 08:13 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 Struggler View Post
Ah, now it shows up when I changed it to 1. So how would I set a clientr variable to the number 0 then? Or should I just get it to detect that there's none and have a default conditional to go to if that's the case?
You can always set it to 0, in the end when you want to display it, it will show 0 anyway. 0 is equal to NULL, you can also try echo(player.clientr.randomlettershere) without creating that flag in the first place, it will also return 0
__________________
MEEP!
Reply With Quote
  #8  
Old 10-14-2014, 08:14 PM
Struggler Struggler is offline
Zone Repulser =D
Struggler's Avatar
Join Date: May 2006
Posts: 54
Struggler is an unknown quantity at this point
But I'm trying to get this script to display the clientr value in a say2, but when it's set to 0, it's blank.
Reply With Quote
  #9  
Old 10-14-2014, 08:16 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Quote:
Originally Posted by Struggler View Post
Ah, now it shows up when I changed it to 1. So how would I set a clientr variable to the number 0 then? Or should I just get it to detect that there's none and have a default conditional to go to if that's the case?
Depends, I'm still trying to figure out what your script is supposed to accomplish.

PHP Code:
function onActionServerside(){
  if (
params[0] == "updatevars"){
    
player.clientr.treescut true;
    echo(
player.clientr.treescut);
  }
}

//#CLIENTSIDE
function onCreated(){
  if (
player.clientr.treescut == false) { //Your variable will have to be false to trigger serverside again
    
triggerserver("gui"this.name"updatevars");
  }

__________________
Reply With Quote
  #10  
Old 10-14-2014, 08:22 PM
Struggler Struggler is offline
Zone Repulser =D
Struggler's Avatar
Join Date: May 2006
Posts: 54
Struggler is an unknown quantity at this point
Okay with the collection of yougize's help I have in fact solved the problem. The problem wasnt that the value wasnt being assigned, it's that I was assigned the variable a null value so it just wasnt being displayed. I have now added an if conditional to detect if the treescut variable is 0 and if so perform accordingly. Thank you both for your assistance
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 03:20 PM.


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