void CGame::AdminOrder_SetPlayerReputation(int iClientH, char *pData, DWORD dwMsgSize)
{
char seps[] = "= \t\n";
char * token, cBuff[256];
class CStrTok * pStrTok;
char * rep;
char cNick[20];
char cRep[5];
char notice[100];
int oldrep;
int i;
if (m_pClientList[iClientH] == NULL) return;
if ((dwMsgSize) <= 0) return; //if user types /SetREP wifout nick
if (m_pClientList[iClientH]->m_iAdminUserLevel == 0) {
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_ADMINUSERLEVELLOW, NULL, NULL, NULL, NULL); //if user is not enuf admin lvl
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);
rep = pStrTok->pGet();
if (rep == NULL) {
delete pStrTok;
return;
}
strcpy(cRep, rep);
for (i = 0; i < DEF_MAXCLIENTS; i++) {
if ((m_pClientList != NULL) && (memcmp(m_pClientList->m_cCharName, cNick, strlen(cNick)) == 0)) {
oldrep = m_pClientList->m_iRating; //this is to define the previous rep
m_pClientList->m_iRating=atoi(cRep); //this is to change the current value to the one typed
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_RATINGPLAYER, NULL, NULL, NULL, NULL); //this is to show the notice of succesful change of rep count.
wsprintf(notice,"Rep Count has been changed for player %s from %d to %d.",m_pClientList[iClientH]->m_cCharName,oldrep,atoi(cRep));
ShowNotice(iClientH,notice);
}
}
delete pStrTok;
}
Im not sure about hte shownotice part, what it does and where to add it but is use Drajwer's one.
void CGame::ShowNotice(int iClientH,char *pMsg)
{
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_NOTICEMSG, NULL, NULL, NULL, pMsg);
}
and the usage is
if (memcmp(cp, "/setrep ",== 0) {
AdminOrder_SetPlayerReputation(iClientH, cp, dwMsgSize - 21);
return;
}
so pls, point out my mistakes. im noob in this area, im learning, not like some noobs who just ask for codes. <span style='color:red'>And thx drajwer cos ur post made me want to learn to code lol.</span>
