Example #1
0
static void G_Players_f (const Player &player)
{
    int count = 0;
    char smallBuf[64];
    char largeBuf[1280];

    /* print information */
    largeBuf[0] = 0;

    Player *p = nullptr;
    while ((p = G_PlayerGetNextActiveHuman(p))) {
        Com_sprintf(smallBuf, sizeof(smallBuf), "(%i) Team %i %s status: %s\n", p->getNum(),
                    p->getTeam(), p->pers.netname, (p->roundDone ? "waiting" : "playing"));

        /* can't print all of them in one packet */
        if (strlen(smallBuf) + strlen(largeBuf) > sizeof(largeBuf) - 100) {
            Q_strcat(largeBuf, "...\n", sizeof(largeBuf));
            break;
        }
        Q_strcat(largeBuf, smallBuf, sizeof(largeBuf));
        count++;
    }

    G_ClientPrintf(player, PRINT_CONSOLE, "%s\n%i players\n", largeBuf, count);
}
Example #2
0
static void G_Say_f (Player &player, bool arg0, bool team)
{
    char text[256];

    if (gi.Cmd_Argc() < 2 && !arg0)
        return;

    if (G_CheckFlood(player))
        return;

    if (!team)
        Com_sprintf(text, sizeof(text), "%s: ", player.pers.netname);
    else
        Com_sprintf(text, sizeof(text), "^B%s (team): ", player.pers.netname);

    if (arg0) {
        Q_strcat(text, gi.Cmd_Argv(0), sizeof(text));
        Q_strcat(text, " ", sizeof(text));
        Q_strcat(text, gi.Cmd_Args(), sizeof(text));
    } else {
        const char *p = gi.Cmd_Args();
        const char *token = Com_Parse(&p);

        Q_strcat(text, token, sizeof(text));
    }

    Q_strcat(text, "\n", sizeof(text));

    if (sv_dedicated->integer)
        gi.DPrintf("%s", text);

    Player *p = nullptr;
    while ((p = G_PlayerGetNextActiveHuman(p))) {
        if (team && p->getTeam() != player.getTeam())
            continue;
        G_ClientPrintf(*p, PRINT_CHAT, "%s", text);
    }
}
Example #3
0
/**
 * @brief Debug function to print a player's inventory
 */
void G_InvList_f (const Player &player)
{
    Edict *ent = nullptr;

    gi.DPrintf("Print inventory for '%s'\n", player.pers.netname);
    while ((ent = G_EdictsGetNextLivingActorOfTeam(ent, player.getTeam()))) {
        gi.DPrintf("actor: '%s'\n", ent->chr.name);

        const Container *cont = nullptr;
        while ((cont = ent->chr.inv.getNextCont(cont, true))) {
            Com_Printf("Container: %i\n", cont->id);
            Item *item = nullptr;
            while ((item = cont->getNextItem(item))) {
                Com_Printf(".. item.def(): %i, item.ammo: %i, item.ammoLeft: %i, x: %i, y: %i\n",
                           (item->def() ? item->def()->idx : NONE), (item->ammoDef() ? item->ammoDef()->idx : NONE),
                           item->getAmmoLeft(), item->getX(), item->getY());
                if (item->def())
                    Com_Printf(".... weapon: %s\n", item->def()->id);
                if (item->ammoDef())
                    Com_Printf(".... ammo:   %s (%i)\n", item->ammoDef()->id, item->getAmmoLeft());
            }
        }
    }
}