Raised This Month: $ Target: $400
 0% 

Help with callfunc


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-03-2007 , 15:36   Help with callfunc
#1

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.

Last edited by Bad_Bud; 01-03-2007 at 18:58.
Bad_Bud is offline
allenwr
Veteran Member
Join Date: Jan 2006
Location: The place where the karm
Old 01-03-2007 , 17:00   Re: Help with callfunc
#2

put debug next to plugin and put there error here
__________________
Don't ever place an order with Vee Servers. This is why.
allenwr is offline
Send a message via ICQ to allenwr Send a message via Yahoo to allenwr
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-03-2007 , 18:55   Re: Help with callfunc
#3

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.
Bad_Bud is offline
cybermind
Senior Member
Join Date: Oct 2004
Old 01-03-2007 , 21:05   Re: Help with callfunc
#4

callfunc_begin may not have completed successfully. Are you using it correctly?
cybermind is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-03-2007 , 22:23   Re: Help with callfunc
#5

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.
Bad_Bud is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 01-03-2007 , 23:00   Re: Help with callfunc
#6

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.
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd

Last edited by Orangutanz; 01-03-2007 at 23:14.
Orangutanz is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-04-2007 , 01:50   Re: Help with callfunc
#7

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.
Bad_Bud is offline
souvikdas95
Senior Member
Join Date: Mar 2012
Old 03-28-2014 , 06:07   Re: Help with callfunc
#8

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

Last edited by souvikdas95; 03-28-2014 at 06:09.
souvikdas95 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 03-28-2014 , 06:24   Re: Help with callfunc
#9

Quote:
Originally Posted by souvikdas95 View Post
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.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Closed Thread



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 22:30.


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