Code: Select all
void CGame::AdminOrder_SetPK(int iClientH, char *pData, DWORD dwMsgSize)
{
char seps[] = "= \t\n";
char * token, cBuff[256];
class CStrTok * pStrTok;
char * pk;
char cNick[20];
char cPK[5];
char notice[100];
int oldpk;
int i;
if (m_pClientList[iClientH] == NULL) return;
if ((dwMsgSize) <= 0) return;
if (m_pClientList[iClientH]->m_iAdminUserLevel == 0) {
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_ADMINUSERLEVELLOW, NULL, NULL, NULL, NULL);
return;
}
ZeroMemory(cBuff, sizeof(cBuff));
memcpy(cBuff, pData, dwMsgSize);
pStrTok = new class CStrTok(cBuff, seps);
token = pStrTok->pGet();
token = pStrTok->pGet();
if (token == NULL) {
delete pStrTok;
return;
}
strcpy(cNick, token);
pk = pStrTok->pGet();
if (pk == NULL) {
delete pStrTok;
return;
}
strcpy(cPK, pk);
for (i = 0; i < DEF_MAXCLIENTS; i++) {
if ((m_pClientList[i] != NULL) && (memcmp(m_pClientList[i]->m_cCharName, cNick, strlen(cNick)) == 0)) {
oldpk = m_pClientList[i]->m_iPKCount;
m_pClientList[i]->m_iPKCount=atoi(cPK);
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_PKPENALTY, NULL, NULL, NULL, NULL);
wsprintf(notice,"PK Count has been changed for player %s from %d to %d.",m_pClientList[iClientH]->m_cCharName,oldpk,atoi(cPK));
ShowNotice(iClientH,notice);
}
}
delete pStrTok;
}
ShowNotice is
Code: Select all
void CGame::ShowNotice(int iClientH,char *pMsg)
{
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_NOTICEMSG, NULL, NULL, NULL, pMsg);
}
Code: Select all
if (memcmp(cp, "/setpk ", 7) == 0) {
AdminOrder_SetPK(iClientH, cp, dwMsgSize - 21);
return;
}