AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Pawn function argmunent help (https://forums.alliedmods.net/showthread.php?t=240818)

c2d22 05-22-2014 15:52

Pawn function argmunent help
 
1- How to pass a two dimensional array to a stock or function
2- How to Make a stock or function with optional argument
Like , i have a stock or function ( or wat ever u called it as) , abc(type,amount) and here
amount should be optional , i mean ,i dont want to pass in few cases and vice versa
3- Can someone list all types of argument that can be made with a function / stock

Black Rose 05-22-2014 16:12

Re: Pawn function argmunent help
 
Code:
#include <amxmodx> public plugin_init() {     register_plugin("Test Plugin 8", "", "[ --{-@ ]");         new array[1][1];     test(array);     test(array, 2); } stock test(array2d[][], optionalvalue=0) {     server_print("%d", array2d[0][0]);     server_print("Optional: %d", optionalvalue); }
#1 & #2 shown in the example.
Not really sure what you mean by #3 but there are 3 types of data. Float, boolean and integers. Everything else is one of the previous with a custom tag to prevent misuse. In other words, you can pass anything.

c2d22 05-22-2014 17:40

Re: Pawn function argmunent help
 
#1 if i want to add a optional argument to my functions , and actually it should be a string , then how to do that?
#2 How to make optional argument which is multiple dimensional array for a function / stock

Black Rose 05-23-2014 14:45

Re: Pawn function argmunent help
 
There's probably an easier way to do the multi-dimensional array but I can't figure it out.
This only works with a multi-dimensional array that have a predetermined size at the top level and mid level. If you increase the array size on either of them it will fail on compilation.
Bug? No idea.

It may be easier to use a dynamic native. But either way you have to pass the size of the array to the subfunction.

Code:
#include <amxmodx> public plugin_init() {     register_plugin("Test Plugin 8", "", "[ --{-@ ]");         new array[1][1][1];     test();     test(array);     test(array, "what"); } stock test(array2d[][][]={{{0}}}, optionalvalue[]="") {     server_print("%d", array2d[0][0][0]);     server_print("Optional: %s", optionalvalue); }


All times are GMT -4. The time now is 09:45.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.