Stolao Posted July 10, 2015 Share Posted July 10, 2015 (edited) for([email protected] = 0; [email protected]<4; [email protected]++){ set [email protected],rand(1,.L[3]); set [email protected][[email protected]],getd(".M" [email protected])[[email protected]]; } ok my question is in the "set [email protected][[email protected]]" part of the script, where should the "[[email protected]]" fall in this code should it fall within the getd() or after? second question getarg(0)[[email protected]] if getarg(0) is a menu name eg .H$, how would i pull out of the .H$ array via getarg Edited July 10, 2015 by Stolao Quote Link to comment Share on other sites More sharing options...
Capuche Posted July 10, 2015 Share Posted July 10, 2015 second question getarg(0)[.@s] if getarg(0) is a menu name eg .H$, how would i pull out of the .H$ array via getarg getelementofarray( getarg(0),<index> ) should work 1 Quote Link to comment Share on other sites More sharing options...
Kurofly Posted July 10, 2015 Share Posted July 10, 2015 for([email protected] = 0; [email protected]<4; [email protected]++){ set [email protected],rand(1,.L[3]); set [email protected][[email protected]],getd(".M" [email protected]+"["[email protected]+"]"); } always inside For the other one you can't use the whole array as an argument. I think I heard somewhere that you can pass player array variables in functions but I never tried it So you have two choices: Either you use a @var[] array and then use it in your function Or you pass the name of the array to your function so that it can get the variables using getvariableofnpc() and getd() note that you'l have to give your array lenght to your function for example : - script YourNPCName -1,{ callfunc "YourFuncName",".myarrayname",getarraysize(.myarrayname); } function script YourFuncName { for ([email protected] = 0 ; [email protected] < getarg(1) ; [email protected]++) debugmes "val "+[email protected]+" : "+getvariableofnpc(getd(getarg(0)+"["[email protected]+"]"),"YourNPCName"); return; } 1 Quote Link to comment Share on other sites More sharing options...
nanakiwurtz Posted July 10, 2015 Share Posted July 10, 2015 I don't quite understand your questions for([email protected] = 0; [email protected]<4; [email protected]++){ set [email protected],rand(1,.L[3]); set [email protected][[email protected]],getd(".M" [email protected]+"["[email protected]+"]"); } 1 Quote Link to comment Share on other sites More sharing options...
Stolao Posted July 10, 2015 Author Share Posted July 10, 2015 I don't quite understand your questions for([email protected] = 0; [email protected]<4; [email protected]++){ set [email protected],rand(1,.L[3]); set [email protected][[email protected]],getd(".M" [email protected]+"["[email protected]+"]"); } let me add more detail then setarray .M1,1,2,3; setarray .M2,4,5,6; setarray .M3,7,8,9; for([email protected] = 0; [email protected]<4; [email protected]++){ set [email protected],rand(1,.L[3]); set [email protected][[email protected]],getd(".M" [email protected])[[email protected]]; } im trying to set [email protected] randomly from one of those 3 .M arrays, from a random point in one of those arrays basically i want getd() to be from an array so how do i set the array index Quote Link to comment Share on other sites More sharing options...
nanakiwurtz Posted July 10, 2015 Share Posted July 10, 2015 I don't know about your .L[3], and it looks like that Kurofly has answered your second question? setarray .M1,1,2,3; setarray .M2,4,5,6; setarray .M3,7,8,9; for ([email protected] = 0; [email protected]<4; [email protected]++) { set [email protected],rand(1,.L[3]); set [email protected][[email protected]],getd(".M"[email protected]+"["+rand(getarraysize(getd(".M"[email protected])))+"]"; } 1 Quote Link to comment Share on other sites More sharing options...
Stolao Posted July 11, 2015 Author Share Posted July 11, 2015 second question getarg(0)[.@s] if getarg(0) is a menu name eg .H$, how would i pull out of the .H$ array via getarg getelementofarray( getarg(0),<index> ) should work getd(getarg(0)+"["[email protected]+"]"); is what i ended up going with for the 2nd part, thanks guys Quote Link to comment Share on other sites More sharing options...
ok my question is in the "set [email protected][[email protected]]" part of the script, where should the "[[email protected]]" fall in this code should it fall within the getd() or after?
second question
if getarg(0) is a menu name eg .H$, how would i pull out of the .H$ array via getarg
Edited by StolaoLink to comment
Share on other sites