Problem with callback not being called
#1

OK, I have this code:
pawn Code:
forward CheckPlayerKeys(playerid);
public CheckPlayerKeys(playerid)
{
    print("test");
    if(BrowsingSkin{playerid} == 1)
    {
        print("#0");
        new skin_id = GetPlayerSkin(playerid), keys, ud, lr;
        GetPlayerKeys(playerid, keys, ud, lr);
        switch(lr)
        {
            case 128:
            {
                print("#1");
                skin_id -= 1;
                if(skin_id < 0)
                {
                    skin_id = 299;
                }
                if(!IsValidSkin(skin_id))
                {
                    for(new s = skin_id; s > 1; s--)
                    {
                        if(IsValidSkin(s))
                        {
                            skin_id = s;
                            break;
                        }
                    }
                }
                SetPlayerSkin(playerid, skin_id);
                return 1;
            }
            case -128:
            {
                print("#2");
                skin_id += 1;
                if(skin_id > 299)
                {
                    skin_id = 0;
                }
                if(!IsValidSkin(skin_id))
                {
                    for(new s = skin_id; s > 0; s++)
                    {
                        if(IsValidSkin(s))
                        {
                            skin_id = s;
                            break;
                        }
                    }
                }
                SetPlayerSkin(playerid, skin_id);
                return 1;
            }
        }
    }
    else
    {
        if(KeyCheckTimer[playerid] != -1)
        {
            KillTimer(KeyCheckTimer[playerid]), KeyCheckTimer[playerid] = -1;
        }
    }
    return 1;
}
And this is how I call the callback:

pawn Code:
case 13: // Browse
            {
                if(BrowsingSkin{playerid} != 0) return SendClientMessage(playerid, COLOUR_SYSTEM, "Error! {FFFFFF}You are already in skin browsing mode. Press ENTER/Space to end it.");
                new Float:Pos[3];
                print("OPDS: #1");
                GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
                OriginalSkinID[playerid] = GetPlayerSkin(playerid), BrowsingSkin{playerid} = 1;
                ShowPlayerDialog(playerid, (SKINMENU - 1), DIALOG_STYLE_MSGBOX, DIALOG_HEADER, "Press {009900}AIM {ADC7E7}(aim weapon) to view the {009900}previous {ADC7E7}skin.\nPress {009900}FIRE {ADC7E7}(shoot weapon) to view the {009900}next {ADC7E7}skin.\nPress {009900}ENTER {ADC7E7}(enter/exit vehicle key) to {009900}select {ADC7E7}the skin.\nPress {009900}SPACE {ADC7E7}(Jump Key) to {009900}go back{ADC7E7}.", "Close", "");
                TogglePlayerControllable(playerid, false);
                print("OPDS: #2");
                KeyCheckTimer[playerid] = SetTimerEx("CheckPlayerKeys", 150, 1, "i", playerid);
                printf("KeyCheck: %d", KeyCheckTimer[playerid]);
                print("OPDS: #3");
// secret
                print("OPDS: #4");
                return 1;
            }
All the prints in the dialog code shows, but not in the callback (not even TEST). The timer ID returns a correct value.

Anyone got any idea at all? I tried having this code in OnPlayerUpdate but it wouldn't call there either :/

Thanks,
Garsino.
Reply
#2

Saw that already yesterday in irc but the code looks still fine

Went fast in game and tested it had no problem selecting a new skin :/
Reply
#3

I also tried calling it directly using

pawn Code:
CheckPlayerKeys(playerid);
But then I end up with the following error:
Code:
error 017: undefined symbol "CheckPlayerKeys"
Reply
#4

I've had a strange problem a little like this before; and to resolve it I had to forward it BEFORE I called it. Are you doing that? Or forwarding it just infront of the 'public' delcaration?
Reply
#5

Quote:
Originally Posted by funky1234
View Post
I've had a strange problem a little like this before; and to resolve it I had to forward it BEFORE I called it. Are you doing that? Or forwarding it just infront of the 'public' delcaration.
I'm forwarding it infront of the public decleration (which lies above OnDialogResponse). I don't really get what you mean though, care to show an example?
Reply
#6

I'm on my phone at the moment otherwise i'd show you where and what was (or seemed to be) wrong with mine. I can easily give a short example though.

pawn Code:
#include <a_samp>

public OnFilterScriptInit()
{
     MyCallback();
}

forward MyCallback();
public MyCallback()
{
     print("worked");
}
Would never compile (and return the error you had).

Changing it to a timer (SetTimer AND SetTimerEx) would actually crash the server; I'jm guessing due to the callback apparently 'not existing'.

I moved the forward declaration to under the '#include' line. After which, I could call it directly and used a timer, whichh worked, and gave the desired result.

If this isn't resolved by the time I get in, i'll also show you the actual code that gave the errors.

Edit: Sorry my description was poor above. I don't know what's up with me today.

Anyway, I mean it seems the callback needs forwarding before I can actually be used.

pawn Code:
#include <a_samp>

public OnFilterScriptInit()
{
     MyCallback();
}

forward MyCallback();
public MyCallback()
{
     print("worked");
}
This, seemed not to work.

However, this does:

pawn Code:
#include <a_samp>

forward MyCallback();

public OnFilterScriptInit()
{
     MyCallback();
}

public MyCallback()
{
     print("worked");
}
I honestly don't get why, and this only happens on very rare occasions. (It's actually only happened to me once)
Reply
#7

I tried doing that. Same error as above :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)