![]() |
Question about "autodetecting" variables.
okay, so i'm trying to set up my system to read a variable and use that variable to create the name of another variable to read from. say if i wanted a weapon to calculate damage from an unusual stat such as say, accuracy. i could just put something like damagebase=accuracy in the weapon file to make things easier.
in this example, we're just going to manually set the kind of damage the weapon would be using in client.weapon_damagebase. with this line, i can get it to put together an existing variable name: PHP Code:
now the actual problem is that although i've managed to make it put that together, i cant figure out how to tell it to read from that variable since my attempts have always made this.damagebase return "client.stats_accuracy". i think my problem is that it's treating what's stored, as a string, and not actually a variable. what would i use to tell it to read from the actual client.stats_accuracy variable in this manner? |
To create dynamic variables you have two options.
First (best): PHP Code:
PHP Code:
PHP Code:
|
I cant seem to get it to work. your way didnt seem to make this.damagebase equal anything but null no matter which way i tried it. so perhaps im doing it wrong. i also tried doing both:
PHP Code:
PHP Code:
Also, why is your first example preferred over the second? Is it more versatile, or is it just outdated (i.e. gs1)? |
Quote:
PHP Code:
|
Quote:
|
Quote:
Personally I used makevar at first but eventually migrated to the object.("var") way, it was a lot easier to work with after I got use to it. |
Quote:
|
Quote:
|
Quote:
also, in my attributes, client.stats_strength currently equals 190 my script, of course contains PHP Code:
edit: hold on, it seems that someone broke my server and now nothing's updating >:0 |
try
PHP Code:
|
Quote:
|
clientr.vars can be read by both the client and server, but can only be altered on the serverside
|
so if i needed to send a variable over to serverside to be calculated for a clientr.var, would i send a temp.var or a this.var? or something else?
|
Quote:
temp.variables are only accessible in the function where they are defined. For example, PHP Code:
this.variables on the other hand are assigned to the object in which they are defined (hence "this") and are accessible throughout the object for example, PHP Code:
PHP Code:
triggerServer() is called from the clientside and will invoke the event "onActionServerSide()" on the serverside. Alternatively, triggerClient() will invoke "onActionClientSide()" on the clientside. Both require two parameters, and also allow an arbitrary (i think?) number of extra parameters.
for example, I want to call a function in a weapon NPC on the serverside from the clientside of the same weapon: PHP Code:
So to answer your question, you can send any type of variable you want as a parameter via triggerServer(). You can then assign the parameter on the serverside to a clientr.var, this.var, or pass it to another function...whatever you want. If this is confusing just ignore everything I said and wait for someone else to help you :p |
I believe im fairly familiar with using the serverside <=> clientside stuff. didnt know the difference between temp.var and this.var though =3
so if i want to create an important clientr.var, i should do something like this?: example: PHP Code:
now, I'm wondering though, are people able to hack and edit this.num1 and this.num2 to change the outcome of clientr.num? or is it just harder to hack compared to client.vars? |
All times are GMT +2. The time now is 10:03 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.