Raised This Month: $ Target: $400
 0% 

Pawn function argmunent help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
c2d22
Junior Member
Join Date: Feb 2013
Location: Albania
Old 05-22-2014 , 15:52   Pawn function argmunent help
Reply With Quote #1

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
c2d22 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-22-2014 , 16:12   Re: Pawn function argmunent help
Reply With Quote #2

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.
__________________

Last edited by Black Rose; 05-22-2014 at 16:15.
Black Rose is offline
c2d22
Junior Member
Join Date: Feb 2013
Location: Albania
Old 05-22-2014 , 17:40   Re: Pawn function argmunent help
Reply With Quote #3

#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

Last edited by c2d22; 05-22-2014 at 17:46. Reason: added 2
c2d22 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-23-2014 , 14:45   Re: Pawn function argmunent help
Reply With Quote #4

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); }
__________________

Last edited by Black Rose; 05-23-2014 at 14:53.
Black Rose is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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