Issue with public functions
#1

I have a very strange issue.

In my code, I have a public function. Below that public function, I have a normal function. Both these are at the end of my script. In another public callback (a SA-MP one) way higher, I call the non-public function I mentioned. It executes, but the return value doesn't get returned to the higher function.

If I remove the custom public function, however, it works. It also works if I swap the placement around, and put the function declaration before the public declaration.

What on earth could cause this? It is possible that there is a limit as to the number of public functions? Could y_hooks be causing the issue perhaps?

Any help appreciated. Thanks.

EDIT: Okay, I've found (sort of) the source of the problem. It's '#pragma dynamic'. If I remove it, everything works fine. My script uses a lot of memory though. What should I set pragma dynamic to? Should I look in to the 'amxlimit' and 'amxram' pragma directives also? If I just remove #pragma dynamic everything in my script breaks.

EDIT #2: Been playing around with the 'dynamic', 'amxlimit' and 'amxram' pragma directives with no luck. If I have pragma dynamic, the function return values get fucked up, and if I remove pragma dynamic, everying else in my script gets fucked (no pickups at places, textdraws not appearing etc.). What the hell do I do?!

EDIT #3: Attempt to clarify..

My code is like this:

pawn Код:
public OnPlayerSpawn(playerid)
{
    print("calling testfunc().."); // Gets called
    printf("ret: %i", testfunc()); // Doesn't get called
    // Nor does the rest of the callback - it hasn't returned here? has it returned to some other callback somehow?
    return 1;
}

public SomeTimerFunc()
{
    // Gets called fine on a timer
    return 1;
}

testfunc()
{
    print("testfunc()"); // prints fine
    return 1;
}
Reply
#2

That is a strange problem, i have my GM witch i made from 0 and has about 120k lines, and u just tested that works perfect so u fcked up something , can u give us list of includes?

I think there is a problem somewhere with return...

You can also try to forward that public function like:
Код:
public OnPlayerSpawn(playerid)
{
    print("calling testfunc().."); // Gets called
    printf("ret: %i", testfunc()); // Doesn't get called
    // Nor does the rest of the callback - it hasn't returned here? has it returned to some other callback somehow?
    return 1;
}

forward SomeTimerFunc();
public SomeTimerFunc()
{
    // Gets called fine on a timer
    return 1;
}

testfunc()
{
    print("testfunc()"); // prints fine
    return 1;
}
that to ur script use lot of memory should not be a problem there is a problem in some of includes...
and what is ur current number of pragma dynamic set to, and is pragma dynamic before all icnludes or afther all includes
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)