iFoxkun Posted November 27, 2011 Group: Members Topic Count: 24 Topics Per Day: 0.00 Content Count: 189 Reputation: 16 Joined: 11/20/11 Last Seen: January 4, 2014 Share Posted November 27, 2011 I don't understand the getarg command at all? Anyone o_o Quote Link to comment Share on other sites More sharing options...
0 Z3R0 Posted November 28, 2011 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 618 Reputation: 201 Joined: 11/09/11 Last Seen: June 14, 2024 Share Posted November 28, 2011 Agreed dont worry my tutorials will cover everything mentioned above Quote Link to comment Share on other sites More sharing options...
0 Z3R0 Posted November 28, 2011 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 618 Reputation: 201 Joined: 11/09/11 Last Seen: June 14, 2024 Share Posted November 28, 2011 I am on te road for another hour pm ur questions if u want Quote Link to comment Share on other sites More sharing options...
0 Truly Posted November 27, 2011 Group: Members Topic Count: 24 Topics Per Day: 0.00 Content Count: 201 Reputation: 48 Joined: 11/17/11 Last Seen: December 26, 2021 Share Posted November 27, 2011 (edited) Basically getarg Gets the Arguments of some type of calling action. For example: place,50,50,6%TAB%script%TAB%Man%TAB%115,{ mes "[Man]" mes "Gimme a number!"; next; input @number; if (callfunc("OddFunc",@number)) mes "It's Odd!"; close; } function%TAB%script%TAB%OddFunc%TAB%{ if (getarg(0)%2==0) return 0;// it's even return 1;// it's odd } This is the example from the script_commands.txt And basically it will allow you to send multiple sets of data through one line. With this Callfunc, it will call the function "OddFunc" and the first Argument is "@number" which was set 1 line before the callfunc. So the script then jumps to the function for "OddFunc" and uses the 1st Argument, as getarg(0). The 2nd argument would have been getarg(1) and so on and so forth (Same basic principle with arrays). The funtion then will do whatever you want, in this case it will check if its an Even number, if not it will return 1 to where the calling action is And in this case, if(1) is true, so it will mes "It's Odd!" Edited November 27, 2011 by Truly Quote Link to comment Share on other sites More sharing options...
0 iFoxkun Posted November 27, 2011 Group: Members Topic Count: 24 Topics Per Day: 0.00 Content Count: 189 Reputation: 16 Joined: 11/20/11 Last Seen: January 4, 2014 Author Share Posted November 27, 2011 Basically getarg Gets the Arguments of some type of calling action. For example: place,50,50,6%TAB%script%TAB%Man%TAB%115,{ mes "[Man]" mes "Gimme a number!"; next; input @number; if (callfunc("OddFunc",@number)) mes "It's Odd!"; close; } function%TAB%script%TAB%OddFunc%TAB%{ if (getarg(0)%2==0) return 0;// it's even return 1;// it's odd } This is the example from the script_commands.txt And basically it will allow you to send multiple sets of data through one line. With this Callfunc, it will call the function "OddFunc" and the first Argument is "@number" which was set 1 line before the callfunc. So the script then jumps to the function for "OddFunc" and uses the 1st Argument, as getarg(0). The 2nd argument would have been getarg(1) and so on and so forth (Same basic principle with arrays). The funtion then will do whatever you want, in this case it will check if its an Even number, if not it will return 1 to where the calling action is And in this case, if(1) is true, so it will mes "It's Odd!" I did not understand 1 bit xD. That one confuses me Quote Link to comment Share on other sites More sharing options...
0 Dinze Posted November 27, 2011 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 34 Reputation: 4 Joined: 11/09/11 Last Seen: August 4, 2016 Share Posted November 27, 2011 (edited) As you can see. input @number; if (callfunc("OddFunc",@number)) Now, calling the function "OddFunc" with the argument @number. and then, inside the function "Oddfunc" if (getarg(0)%2==0) for instance, if you input '4'. It will be if ( 4 % 2 == 0) note: % = Modulus operator >http://www.cprogramm...al/modulus.html If the argument(number) is even return 0 else return 1. Edited November 27, 2011 by Genuine Quote Link to comment Share on other sites More sharing options...
0 xMiland Posted November 27, 2011 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 95 Reputation: 26 Joined: 11/15/11 Last Seen: June 4, 2020 Share Posted November 27, 2011 getarg() is used to get the arguments that you passed during your function call. My example: prontera,50,50,4 script SampleNPCArg 50,{ mes "[Robert Dooke]"; mes "Okay I will pass my first name as the first argument"; mes "and my second name as the second argument."; next; callfunc "samplefunc","Robert","Dooke"; end; } function samplefunc { mes "OMG you have just passed the the man's name !"; mes "Firstname: "+getarg(0)+""; //getarg(0) is the 1st argument that has been passed which is "Robert". mes "Secondname: "+getarg(1)+""; //getarg(1) is the 2nd argument that has been passed which is "Dooke". close; } Quote Link to comment Share on other sites More sharing options...
0 Truly Posted November 27, 2011 Group: Members Topic Count: 24 Topics Per Day: 0.00 Content Count: 201 Reputation: 48 Joined: 11/17/11 Last Seen: December 26, 2021 Share Posted November 27, 2011 Haha well i honestly didnt understand it until a few weeks ago, and that was after learning the for loops, arrays, and some other nifty commands that arnt easy to just pick up. I would suggest to avoid this if you dont understand it, then later when you get better at scripting, take a look at it! Quote Link to comment Share on other sites More sharing options...
0 iFoxkun Posted November 28, 2011 Group: Members Topic Count: 24 Topics Per Day: 0.00 Content Count: 189 Reputation: 16 Joined: 11/20/11 Last Seen: January 4, 2014 Author Share Posted November 28, 2011 Agreed dont worry my tutorials will cover everything mentioned above Yeah, I really don't understand getarg(), on the other hand, I know what "set arrays" does, but how would be use it. Do you have to always get the size of the array? o_o How would I use it. Examples pl0x Quote Link to comment Share on other sites More sharing options...
0 iFoxkun Posted November 28, 2011 Group: Members Topic Count: 24 Topics Per Day: 0.00 Content Count: 189 Reputation: 16 Joined: 11/20/11 Last Seen: January 4, 2014 Author Share Posted November 28, 2011 I am on te road for another hour pm ur questions if u want It's fine, I won't bother you while you're on the road. But try to explain it please after Quote Link to comment Share on other sites More sharing options...
0 llchrisll Posted November 29, 2011 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 626 Reputation: 189 Joined: 11/19/11 Last Seen: March 25 Share Posted November 29, 2011 (edited) I know what "set arrays" does, but how would be use it. Do you have to always get the size of the array? o_o How would I use it. Examples pl0x setarray .@test[0],1; The [0] stats the index where the array should be start to be written. An Index can holds up to 128 information, but the last Index is 127 since an array always starts with the index 0. To gain the arraysize, there is the command *getarraysize() also you need to know where the index starts. Example: I have an array which starts with the index 1: setarray .@boxid[1],512,513,514; Now I wanna know the array size: mes getarraysize(.@boxid); // To display it, I'm gonna use "mes" The next would be, if I wanna choose one of the information I have to create an menu. set .@boxm$,""; for (set .@m,0; .@m < getarraysize(.@boxid); set .@m,.@m + 1) set .@boxm$,.@boxm$ + "- "+.@boxid[.@m]+ ( (.@boxid==0)?"":":"); Then we'll have to open the menu. set .@s,select(.@boxm$); Since *select creates an "@" variables called "@menu" which contains the position I chose from the menu. I also saved it into a extra variable in case I would need the an other menu later, so I don't lose the number. If the array would start with an [0] I would have to do add a "- 1" after "(.@boxm$)", so it would like this: set .@s,select(.@boxm$) - 1; Now to confirm it, what I choose: mes "You have chosen: "+.@boxid[.@s]; mes "Is that correct?"; if(select("- Yes:- No") == 2) close; Like you saw I used another select, so the @menu has changed it's content. Then the npc ask us what to do next. mes "What do you want to now?"; if(select("- Edit:- Noting) == 2) close; Now he wants to know the new value for the array. mes "Please type the new value it should have:"; input @new; After I have give him the new value, now he needs to insert it into the array: setarray .@boxid[.@s],@new; So that ends my example. I hope I could be of help, since I'm not good at teaching others D: Regards, Chris Edited November 29, 2011 by llchrisll 1 Quote Link to comment Share on other sites More sharing options...
Question
iFoxkun
I don't understand the getarg command at all? Anyone o_o
Link to comment
Share on other sites
10 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.