AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with callfunc (https://forums.alliedmods.net/showthread.php?t=49416)

Bad_Bud 01-03-2007 15:36

Help with callfunc
 
Here is my error log text:
Code:

L 01/03/2007 - 13:20:46: Start of error session.
L 01/03/2007 - 13:20:46: Info (map "ts_stuntpath") (logfile "error_010307.log")
L 01/03/2007 - 13:20:46: callfunc_push_xxx called without callfunc_begin
L 01/03/2007 - 13:20:46: [AMXX] Run time error 10 (plugin "RolePlay.amxx") (native "callfunc_push_int") - debug not enabled!
L 01/03/2007 - 13:20:46: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).

Here is the AMXX code:
PHP Code:

public ItemMenu2(id,Key)
{
 switch(
Key)
 {
  case 
0: {
   
callfunc_begin(ItemCommand[id][UserCurrentItem[id]],"RolePlay.amxx")
   
728. --->callfunc_push_int(id)<---
   
callfunc_end()
   }
  
//case 1: 
  //case 2: 
  //case 3: 
  
case 4client_print(id,print_chat,"%s: %s",ItemName[id][UserCurrentItem[id]],ItemDescription[id][UserCurrentItem[id]])
  case 
7ItemMenuSetup(id
  case 
9: {
    
client_print(id,print_chat,"**You have closed your inventory.")
    
UserMenuPage[id]=0
   
}
 } 
 return 
PLUGIN_HANDLED


If you have any questions as to what is going on in this function, please ask. Also, case 4, case 7, and case 9 work, so it isn't a switchcase problem...

Also, I had the call as: callfunc_begin(ItemCommand[id][UserCurrentItem[id]]), but when I found out it was having problems, I added "RolePlay.amxx" to the end, even though the function I'm calling is in the same plugin as the callfunc, so it shouldn't really make a difference (and didn't). I was just trying things out.

Sorry for posting in the wrong forum.

allenwr 01-03-2007 17:00

Re: Help with callfunc
 
put debug next to plugin and put there error here

Bad_Bud 01-03-2007 18:55

Re: Help with callfunc
 
Code:

L 01/03/2007 - 17:01:12: Start of error session.
L 01/03/2007 - 17:01:12: Info (map "ts_stuntpath") (logfile "error_010307.log")
L 01/03/2007 - 17:01:12: callfunc_push_xxx called without callfunc_begin
L 01/03/2007 - 17:01:12: [AMXX] Displaying debug trace (plugin "RolePlay.amxx")
L 01/03/2007 - 17:01:12: [AMXX] Run time error 10: native error (native "callfunc_push_int")
L 01/03/2007 - 17:01:12: [AMXX]    [0] RolePlay.sma::ItemMenu2 (line 728)

It keeps acting like I'm not doing callfunc_begin so that callfunc_push can't work...

I highlighted line 728 on my first post.

cybermind 01-03-2007 21:05

Re: Help with callfunc
 
callfunc_begin may not have completed successfully. Are you using it correctly?

Bad_Bud 01-03-2007 22:23

Re: Help with callfunc
 
As far as I know, yes...

I'll try manually putting in the information, instead of through the array, and I'll post any results.

Not sure when I'll have time to do that though, kinda busy.

Orangutanz 01-03-2007 23:00

Re: Help with callfunc
 
Code:
callfunc_begin(ItemCommand[id][UserCurrentItem[id]],"RolePlay.amxx") callfunc_push_int(id) callfunc_end()
What function is this: ItemCommand[id][UserCurrentItem[id]]?
Also you don't need "RolePlay.amxx" on the end if your calling within your own plugin.

Code:
callfunc_begin("some_function") callfunc_push_int(id) callfunc_end() public some_function(id) {    // your code here }
Note that the function your pointing to needs to be declared public.

There is a better method for performance which is...
Code:
new FuncYourFunction public plugin_init() {    FuncYourFunction = get_func_id("your_function") } public some_function() {    callfunc_begin_i(FuncYourFunction)    callfunc_push_int(id)    callfunc_end() } public your_function(id) {    // some code }
The reason this is better on performance if you are going to call this quite often is that integers are faster at parsing than strings.

Bad_Bud 01-04-2007 01:50

Re: Help with callfunc
 
CRAP! I had forgotten to make it public. Damn, thanks a lot. It's the simple errors that make everything explode.

Thanks for the integer tip, as well.

I might as well just store the command in an integer array like you suggest, because it currently is a string array.

If I could give you more than one karma point, I would.

souvikdas95 03-28-2014 06:07

Re: Help with callfunc
 
Suppose I have a function that returns a value ( integer ). How do I get the return value of the function based on the parameters I sent through callfunc_push_array?

EDIT - The plugin is remote... The function is not declared in the same plugin. For your perusal, think about "get_score" function in amxmodx/data/csstats.amxx

hornet 03-28-2014 06:24

Re: Help with callfunc
 
Quote:

Originally Posted by souvikdas95 (Post 2116808)
Suppose I have a function that returns a value ( integer ). How do I get the return value of the function based on the parameters I sent through callfunc_push_array?

EDIT - The plugin is remote... The function is not declared in the same plugin. For your perusal, think about "get_score" function in amxmodx/data/csstats.amxx

One question per thread - please start your own thread for this. And before you do, I recommend that you search for Dynamic Natives, since callfunc is not a good method.


All times are GMT -4. The time now is 22:30.

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