Echoes Posted March 7, 2016 Posted March 7, 2016 Hello c: Well, my doubt is, is there a way to call a variable (#Player_Variable) using an array (.@Array$[0]), and then set it to desired number? I'm doing something like this, but doesn't work: - script FromArrayToVariable -1,{ setarray @array_of_variables$[0],#Player_Variable01,#Player_Variable02; for(.@i=0; .@i<getarraysize(@array_of_variables$); .@i++) if(getd("@array_of_variables$["+(.@i)+"]") != 1) setd "@array_of_variables$["+(.@i)+"]",1; end; } (example script) Also, getting this error with the script: [Error]: script:op_2: invalid data for operator C_NE [Debug]: Data: string value="0" [Debug]: Data: number value=1 I'm trying this script to avoid writing like 200+ lines :C Help please Quote
0 Secrets Posted March 7, 2016 Posted March 7, 2016 if(getd("@array_of_variables$["+(.@i)+"]") != 1) You are comparing a string variable to an integer. I think the fix below should work. if(atoi(getd("@array_of_variables$["+(.@i)+"]")) != 1) Quote
0 Ninja Posted March 7, 2016 Posted March 7, 2016 If you are storing it to an array which only contains numerical data types, remove the $ at the end of the variable name. For a more detailed explanation on variable and array types https://rathena.org/wiki/Custom_Items Quote
0 Capuche Posted March 8, 2016 Posted March 8, 2016 If you want to list the variables in an array, what about - script FromArrayToVariable -1,{ setarray .@array_of_variables$[0], "#Player_Variable01", "#Player_Variable02"; .@size_array = getarraysize(.@array_of_variables$); for ( .@i = 0; .@i < .@size_array; .@i++ ) if ( getd( ".@array_of_variables$[" + .@i + "]") != 1 ) setd ".@array_of_variables$[" + .@i + "]", 1; end; } but if you want to alter the variable of a player online you may use set <variable>,<expression>{,<char_id>}; and getvar <variable>,<char_id>; to retrieve the the variable Quote
0 Echoes Posted March 8, 2016 Author Posted March 8, 2016 (edited) Hello, thank you all for responding. @secretdataz It did not retreive the variable value :C @Ninja Why custom item o.0 At least, didn't found any string usage information. @Capuche Well, adding those " " to the variables will make the script to retreive the entire variable name, no it's value :C Well, was testing further and I found that this will call the numeric value of the variables: setarray @Var_Array$[0], #Player_Variable01, #Player_Variable02, #Player_Variable03; for(.@i=0; .@i<getarraysize(@Var_Array$); .@i++){ mes @Var_Array$[.@i]; set @Var_Array$[.@i],1; } Now I need to set them to the desired number x_x (the set in that for doesn't work, or at least when talking to the NPC again it won't show a different variable value) Edited March 8, 2016 by Echoes Quote
0 Capuche Posted March 8, 2016 Posted March 8, 2016 Alright I don't understand what you want to do.. xD But maybe with a sample of your script.. Quote
0 Echoes Posted March 8, 2016 Author Posted March 8, 2016 Alright I don't understand what you want to do.. xD But maybe with a sample of your script.. Thank you for your efforts to help C: Now, my whole script is posted above, and now that I have the first part of the script done, I want to set those variables to numeric value 1, now they are 0 but I can't set them through script to 1 :C Quote
0 Capuche Posted March 9, 2016 Posted March 9, 2016 Now, my whole script is posted above Sorry. Where ? It's the variables of the player attached to the script ? Quote
0 Enthr Posted March 9, 2016 Posted March 9, 2016 i think that he want to use the variables as a pointer in C, inside an array, so he can ask the value of the "original" variable and change it also, if im not wrong. Quote
0 Emistry Posted March 10, 2016 Posted March 10, 2016 you didnt attach the script to an online players. the best way to deal with variable value would be shut down server run SQL script ( UPDATE `table` SET `value` = 1 WHERE `variable` LIKE '#variable' ) done. Quote
0 Echoes Posted March 10, 2016 Author Posted March 10, 2016 Well, Sorry for the late responses on this, I have been working hard on my script and luckly I got everything working now, sadly without the array I was requesting help with :C Will follow the suggestions you guys gave me so far and I will continue testing calling and editing #vars through arrays, thank you. Aaaaand, I found this: Resume of the allowed variable and array scopes ----------------------------------------------- +==========+======+=======+ |VarType | Norm | Array | +==========+======+=======+ |#Int | OK! | FAIL! | +----------+------+-------+ Maybe this has something to do with the success of calling and editing those #vars with an array e_e Again, thank you guys for your help Quote
0 Enthr Posted March 11, 2016 Posted March 11, 2016 Ah and i recommend you to use setd and getd, maybe thats what are you looking for, you will have to adapt your script a little but it worth it. Quote
Question
Echoes
Hello c:
Well, my doubt is, is there a way to call a variable (#Player_Variable) using an array (.@Array$[0]), and then set it to desired number?
I'm doing something like this, but doesn't work:
(example script)
Also, getting this error with the script:
I'm trying this script to avoid writing like 200+ lines :C
Help please
11 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.