#1

Why do commands work but show as its a unknown command?

like these:

pawn Код:
if(strcmp(cmd, "/ajail", true) == 0)
{
    if(IsPlayerConnected(playerid)) {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason]");
            return 1;
        }
        new playa;
        new money;
        playa = ReturnUser(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason]");
            return 1;
        }
        money = strval(tmp);
        if (PlayerInfo[playerid][pAdmin] >= 1) {
            if(IsPlayerConnected(playa)) {
                if(playa != INVALID_PLAYER_ID) {
                    GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    GiveNameSpace(sendername);
                    GiveNameSpace(giveplayer);
                    if(PlayerInfo[playa][pAdmin]>0 && playa!=playerid) {
                        if(PlayerInfo[playerid][pAdmin] < 10) {
                            SendClientMessage(playerid, COLOR_GRAD2, "Your admin level is too low to jail other admins.");
                            return 1;
                        }
                    }
                    if(PlayerInfo[playerid][pHidden] == 1) { sendername = "Hidden Admin"; }
                    else if(PlayerInfo[playerid][pAdmin] == 11) { sendername = "Hidden Admin"; }
                    new length = strlen(cmdtext);
                    while ((idx < length) && (cmdtext[idx] <= ' ')) {
                        idx++;
                    }
                    new offset = idx;
                    new result[128];
                    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) {
                        result[idx - offset] = cmdtext[idx];
                        idx++;
                    }
                    result[idx - offset] = EOS;
                    if(!strlen(result)) {
                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason]");
                        return 1;
                    }
                    format(string, sizeof(string), "* You Jailed %s.", giveplayer);
                    SendClientMessage(playerid, COLOR_LIGHTRED, string);
                    format(string, sizeof(string), "* You were Jailed by Admin %s.", sendername);
                    SendClientMessage(playa, COLOR_LIGHTRED, string);
                    ResetPlayerWeaponsEx(playa);
                    PlayerInfo[playa][pJailed] = 2;
                    PlayerInfo[playa][pJailTime] = money*60;
                    Mute[playa] = 1;
                    PlayerInfo[playa][pAjailc]++;
                    SetPlayerInterior(playa, 0);
                    SetPlayerVirtualWorld(playa, playa);
                    PlayerInfo[playa][pInt] = 0;
                    DOO_SetPlayerPos(playa,3523.9175,-503.7138,270.5802);
                    format(string, sizeof(string), "You are jailed for %d minutes.", money);
                    SendClientMessage(playa, COLOR_WHITE, string);
                    format(string, 256, "AdmCmd: %s has been jailed by Admin %s for %i minutes [Reason: %s]", giveplayer, sendername,money,(result));
                    OOCOff(COLOR_LIGHTRED, string);
                    SavePlayerData(playa);
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, 256, "AdmCmd: %s has been jailed by Admin %s for %i minutes [Reason: %s]", giveplayer, sendername,money,(result));
                    JailLog(string);
                }
            }
        }
        else {
            SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
        }
    }
    return 1;
}
It use to work when it was saving in DINI/Y_INI, but now it keeps on returning unknown command, can there be something to do with MySQL?
Reply
#2

Does it show any warning?If no then it some other script that is making this happen.
Reply
#3

the scripts all fine,
Код:
mysql_fetch_field_row(sstr, "AdminJailCount"); PlayerInfo[playerid][pAjailc] = strval(sstr);
Код:
 mysql_fetch_field_row(sstr, "Jailed"); PlayerInfo[playerid][pJailed] = strval(sstr);
	mysql_fetch_field_row(sstr, "JailTime"); PlayerInfo[playerid][pJailTime] = strval(sstr);
This is how the mysql gets the rows...
Reply
#4

pawn Код:
if(strcmp(cmd, "/ajail", true) == 0)
{
    if(IsPlayerConnected(playerid)) {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason]");
            printf("was here");
            return 1;
        }
        new playa;
        new money;
        playa = ReturnUser(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason]");
            printf("was here");
            return 1;
        }
        money = strval(tmp);
        if (PlayerInfo[playerid][pAdmin] >= 1) {
            if(IsPlayerConnected(playa)) {
                if(playa != INVALID_PLAYER_ID) {
                    GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    GiveNameSpace(sendername);
                    GiveNameSpace(giveplayer);
                    if(PlayerInfo[playa][pAdmin]>0 && playa!=playerid) {
                        if(PlayerInfo[playerid][pAdmin] < 10) {
                            SendClientMessage(playerid, COLOR_GRAD2, "Your admin level is too low to jail other admins.");
                            printf("was here");
                            return 1;
                        }
                    }
                    if(PlayerInfo[playerid][pHidden] == 1) { sendername = "Hidden Admin"; }
                    else if(PlayerInfo[playerid][pAdmin] == 11) { sendername = "Hidden Admin"; }
                    new length = strlen(cmdtext);
                    while ((idx < length) && (cmdtext[idx] <= ' ')) {
                        idx++;
                    }
                    new offset = idx;
                    new result[128];
                    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) {
                        result[idx - offset] = cmdtext[idx];
                        idx++;
                    }
                    result[idx - offset] = EOS;
                    if(!strlen(result)) {
                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason]");
                        printf("was here");
                        return 1;
                    }
                    format(string, sizeof(string), "* You Jailed %s.", giveplayer);
                    SendClientMessage(playerid, COLOR_LIGHTRED, string);
                    format(string, sizeof(string), "* You were Jailed by Admin %s.", sendername);
                    SendClientMessage(playa, COLOR_LIGHTRED, string);
                    ResetPlayerWeaponsEx(playa);
                    PlayerInfo[playa][pJailed] = 2;
                    PlayerInfo[playa][pJailTime] = money*60;
                    Mute[playa] = 1;
                    PlayerInfo[playa][pAjailc]++;
                    SetPlayerInterior(playa, 0);
                    SetPlayerVirtualWorld(playa, playa);
                    PlayerInfo[playa][pInt] = 0;
                    DOO_SetPlayerPos(playa,3523.9175,-503.7138,270.5802);
                    format(string, sizeof(string), "You are jailed for %d minutes.", money);
                    SendClientMessage(playa, COLOR_WHITE, string);
                    format(string, 256, "AdmCmd: %s has been jailed by Admin %s for %i minutes [Reason: %s]", giveplayer, sendername,money,(result));
                    OOCOff(COLOR_LIGHTRED, string);
                    SavePlayerData(playa);
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, 256, "AdmCmd: %s has been jailed by Admin %s for %i minutes [Reason: %s]", giveplayer, sendername,money,(result));
                    JailLog(string);
                }
            }
        }
        else {
            SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
        }
    }
    printf("was here");
    return 1;
}
And tell us if it's printed("was here") in the capsule(samp-server.exe)?
Reply
#5

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
You need a positive return ("return 1;") at the end of a command, and a negative return ("return 0;") at the end of the callback.

However I can't read the code as easy because the indentation is all broken up and for some reason I just can't code with the braces at the end of the lines. Try using chrfind and sscanf to split the cmdtext instead (It's faster I think) or just use ZCMD and sscanf.
I've got a script doing that as I am a bit lazy, soon I should get a ZCMD + SSCANF system, but it wont fix any problems.

SouthClaw cleaned up:

pawn Код:
if(strcmp(cmd, "/ajail", true) == 0)
{
    new targetid,time,reason[128],string[128];
    if(sscanf(cmd,"uis[128]",targetid,time,reason))
    {
        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason]");
        return 1;
    }
    if (PlayerInfo[playerid][pAdmin] >= 1 && PlayerInfo[playerid][pAdmin] < 10)
    {
        SendClientMessage(playerid, COLOR_GRAD2, "Your admin level is too low to jail other admins.");
        return 1;
    }
    format(string, sizeof(string), "* You Jailed %s(%d).", PlayerName(targetid), targetid);
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "* You were Jailed by Admin %s. (%d minutes.)", PlayerName(playerid),time);
    SendClientMessage(targetid, COLOR_LIGHTRED, string);
    ResetPlayerWeaponsEx(targetid);
    PlayerInfo[targetid][pJailed] = 2;
    PlayerInfo[targetid][pJailTime] = time*60;
    Mute[targetid] = 1;
    PlayerInfo[targetid][pAjailc]++;
    SetPlayerInterior(targetid, 0);
    SetPlayerVirtualWorld(targetid, targetid);
    PlayerInfo[targetid][pInt] = 0;
    DOO_SetPlayerPos(targetid,3523.9175,-503.7138,270.5802);
    format(string, sizeof(string), "AdmCmd: %s has been jailed by Admin %s for %i minutes [Reason: %s]", PlayerName(targetid),PlayerName(playerid),time,reason);
    OOCOff(COLOR_RED, string);
    SavePlayerData(targetid);
    return 1;
}
@Roko this command functions fine, it set a player position, it saves all of the player, but it still returns the command.

Also, would mixing DINI with MySQL causes strcmp commands to stop working?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)