CallLocalFunction crash with empty string
#3

pawn Код:
#if defined _kcmd_included
    #endinput
#endif

#if !defined _samp_included
    #error "Fatal: a_samp needed - before kcmd"
#endif
public OnPlayerCommandText(playerid, cmdtext[])
{
    print("alive");
    new leng = strlen(cmdtext), spacepos = leng + 1, pos;
    printf("alive2, strlen %d, going to loop:", leng);
    while (pos < leng)
    {
        if (cmdtext[pos] == ' ')
        {
            printf("At %d. pos there is the space", pos);
            spacepos = pos;
            pos = leng+1;
        } else printf("At %d. pos there isn't a space (%s)", pos,

cmdtext[pos]);
        pos++;
    }
    print("alive_");
    new cmdname[128], params[128];
    if (spacepos != leng + 1)
    {
        strcat(cmdname, "kcmd_");
        new dest[64];
        strmid(dest, cmdtext[1], 0, spacepos-1);
        strcat(cmdname, dest);
        strcat(params, cmdtext[spacepos+1]);
    }
    else
    {
        strcat(cmdname, "kcmd_");
        strcat(cmdname, cmdtext[1]);
        strcat("", params);
    }
    printf("Searching for %s", cmdname);
    if (funcidx(cmdname) != -1)
    {
        printf("Gotcha %s, calling it ( CallRemoteFunction(cmdname, \"is\", %d,

\"%s\" )"
, cmdname, playerid, params);
        CallRemoteFunction(cmdname, "is", playerid, params);
        print("Crash? :(");
    }
    print("Debug: at_the_end");
    CallLocalFunction("hook_OnPlayerCommandText", "is", playerid, cmdtext);
    print("alive?");
    return 0;
}

forward hook_OnPlayerCommandText(playerid, cmdtext[]);
#define OnPlayerCommandText hook_OnPlayerCommandText
#define KCMD:%1(%2) forward kcmd_%1(%2); public kcmd_%1(%2)
pawn Код:
KCMD:tesztparancs(playerid, params[])
{
    print("ok");
    SendClientMessage(playerid, 0xffff00ff, "Beнrtad a /tesztparancs -ot! DIKKMБ!");
    print("ok2");
    if (strlen(params))
    {
        print("ok3");
        new str[92];
        print("ok4");
        format(str, sizeof str, "Dikk lol, azannyakцcsцgit, mйg azt is beнrtad hogy %s! Azanyбmat!", params);
        print("ok5");
        SendClientMessage(playerid, 0xffff00ff, str);
        print("o6");
    }
    print("ok7");
    return 1;
}
with /tesztparancs testing:
Quote:

[19:53:19] alive
[19:53:19] alive2, strlen 21, going to loop:
[19:53:19] At 0. pos there isn't a space (/tesztparancs testing)
[19:53:19] At 1. pos there isn't a space (tesztparancs testing)
[19:53:19] At 2. pos there isn't a space (esztparancs testing)
[19:53:19] At 3. pos there isn't a space (sztparancs testing)
[19:53:19] At 4. pos there isn't a space (ztparancs testing)
[19:53:19] At 5. pos there isn't a space (tparancs testing)
[19:53:19] At 6. pos there isn't a space (parancs testing)
[19:53:19] At 7. pos there isn't a space (arancs testing)
[19:53:19] At 8. pos there isn't a space (rancs testing)
[19:53:19] At 9. pos there isn't a space (ancs testing)
[19:53:19] At 10. pos there isn't a space (ncs testing)
[19:53:19] At 11. pos there isn't a space (cs testing)
[19:53:19] At 12. pos there isn't a space (s testing)
[19:53:19] At 13. pos there is the space
[19:53:19] alive_
[19:53:19] Searching for kcmd_tesztparancs
[19:53:19] Gotcha kcmd_tesztparancs, calling it ( CallRemoteFunction(cmdname, "is", 0, "testing" )
[19:53:19] ok
[19:53:19] ok2
[19:53:19] ok3
[19:53:19] ok4
[19:53:19] ok5
[19:53:19] o6
[19:53:19] ok7
[19:53:19] Crash?
[19:53:19] Debug: at_the_end
[19:53:19] alive?

with /tesztparancs (no space at the end, or with space; neither works):
Quote:

[19:53:21] alive
[19:53:21] alive2, strlen 13, going to loop:
[19:53:21] At 0. pos there isn't a space (/tesztparancs)
[19:53:21] At 1. pos there isn't a space (tesztparancs)
[19:53:21] At 2. pos there isn't a space (esztparancs)
[19:53:21] At 3. pos there isn't a space (sztparancs)
[19:53:21] At 4. pos there isn't a space (ztparancs)
[19:53:21] At 5. pos there isn't a space (tparancs)
[19:53:21] At 6. pos there isn't a space (parancs)
[19:53:21] At 7. pos there isn't a space (arancs)
[19:53:21] At 8. pos there isn't a space (rancs)
[19:53:21] At 9. pos there isn't a space (ancs)
[19:53:21] At 10. pos there isn't a space (ncs)
[19:53:21] At 11. pos there isn't a space (cs)
[19:53:21] At 12. pos there isn't a space (s)
[19:53:21] alive_
[19:53:21] Searching for kcmd_tesztparancs
[19:53:21] Gotcha kcmd_tesztparancs, calling it ( CallRemoteFunction(cmdname, "is", 0, "" )

Reply


Messages In This Thread
CallLocalFunction crash with empty string - by KoczkaHUN - 07.06.2011, 17:35
Re: CallLocalFunction crash with empty string - by KoczkaHUN - 07.06.2011, 17:48
Re: CallLocalFunction crash with empty string - by KoczkaHUN - 07.06.2011, 17:50

Forum Jump:


Users browsing this thread: 3 Guest(s)