Echoes Posted March 7, 2016 Group: Members Topic Count: 34 Topics Per Day: 0.01 Content Count: 155 Reputation: 6 Joined: 03/30/13 Last Seen: March 26 Share 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 Link to comment Share on other sites More sharing options...
0 Secrets Posted March 7, 2016 Group: Developer Topic Count: 36 Topics Per Day: 0.01 Content Count: 587 Reputation: 431 Joined: 01/26/16 Last Seen: Saturday at 10:34 AM Share 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 Link to comment Share on other sites More sharing options...
0 Ninja Posted March 7, 2016 Group: Members Topic Count: 54 Topics Per Day: 0.01 Content Count: 513 Reputation: 83 Joined: 08/11/12 Last Seen: December 25, 2021 Share 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 Link to comment Share on other sites More sharing options...
0 Capuche Posted March 8, 2016 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 613 Joined: 07/05/12 Last Seen: April 15 Share 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 Link to comment Share on other sites More sharing options...
0 Echoes Posted March 8, 2016 Group: Members Topic Count: 34 Topics Per Day: 0.01 Content Count: 155 Reputation: 6 Joined: 03/30/13 Last Seen: March 26 Author Share 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 Link to comment Share on other sites More sharing options...
0 Capuche Posted March 8, 2016 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 613 Joined: 07/05/12 Last Seen: April 15 Share Posted March 8, 2016 Alright I don't understand what you want to do.. xD But maybe with a sample of your script.. Quote Link to comment Share on other sites More sharing options...
0 Echoes Posted March 8, 2016 Group: Members Topic Count: 34 Topics Per Day: 0.01 Content Count: 155 Reputation: 6 Joined: 03/30/13 Last Seen: March 26 Author Share 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 Link to comment Share on other sites More sharing options...
0 Capuche Posted March 9, 2016 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 613 Joined: 07/05/12 Last Seen: April 15 Share 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 Link to comment Share on other sites More sharing options...
0 Enthr Posted March 9, 2016 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 88 Reputation: 10 Joined: 01/15/16 Last Seen: January 14 Share 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 Link to comment Share on other sites More sharing options...
0 Emistry Posted March 10, 2016 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10015 Reputation: 2348 Joined: 10/28/11 Last Seen: 10 hours ago Share 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 Link to comment Share on other sites More sharing options...
0 Echoes Posted March 10, 2016 Group: Members Topic Count: 34 Topics Per Day: 0.01 Content Count: 155 Reputation: 6 Joined: 03/30/13 Last Seen: March 26 Author Share 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 Link to comment Share on other sites More sharing options...
0 Enthr Posted March 11, 2016 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 88 Reputation: 10 Joined: 01/15/16 Last Seen: January 14 Share 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 Link to comment Share on other sites More sharing options...
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
Link to comment
Share on other sites
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.