Need Help on Code!

Submit your code requests, and if you are good at coding come help others with their requests.
Post Reply
molo
Member
Posts: 140
Joined: Mon Jan 17, 2005 1:19 am

Post by molo »

well i have this code.. but when i try to add it.. it give me one Error... here check it out.. ;)

<span style='color:red'>go to function ChatMsgHandler and add</span>
//SetEk BY Drajwer!!!!!!!!!!
if (memcmp(cp, "/setek", 6) == 0) {
AdminOrder_SetEK(iClientH, cp, dwMsgSize - 21);;
return;
}
<span style='color:red'>later to add this anywhere in game.cpp</span>
//SetEk BY Drajwer!!!!!!!!!!
void CGame::AdminOrder_SetEK (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 != NULL)
  && (memcmp (m_pClientList->m_cCharName, cNick, strlen (cNick)) ==
  0))
{
  oldpk = m_pClientList->m_iEnemyKillCount;
  m_pClientList->m_iEnemyKillCount = atoi (cPK);
  SendNotifyMsg (NULL, i, DEF_NOTIFY_ENEMYKILLS,
   m_pClientList->m_iEnemyKillCount, NULL, NULL,
   NULL);
  wsprintf (notice,
   "EK Count has been changed for player %s from %d to %d.",
   m_pClientList[iClientH]->m_cCharName, oldpk, atoi (cPK));
  ShowNotice (iClientH, notice);
}
}
delete pStrTok;
}


<span style='color:red'>and to register the function in game.h</span>

//SetEk BY Drajwer!!!!!!!!!!
void AdminOrder_SetEK(int iClientH, char *pData, DWORD dwMsgSize);


<span style='color:red'>and here is the Error it show's me..</span>

Compiling...
Game.cpp
C:\.....\HG SRC\Game.cpp(2043) : warning C4305: '=' : truncation from 'const int' to 'char'
C:\.....\HG SRC\Game.cpp(2043) : warning C4309: '=' : truncation of constant value
C:\.....\HG SRC\Game.cpp(8788) : warning C4305: '=' : truncation from 'const int' to 'short'
C:\.....\HG SRC\Game.cpp(8788) : warning C4309: '=' : truncation of constant value
C:\.....\HG SRC\Game.cpp(9064) : error C2601: 'AdminOrder_SetEK' : local function definitions are illegal
Error executing cl.exe.



Results
HGserver.exe - 1 error(s), 4 warning(s)


if anyone know why it show me.. please let me know...
EvilHit
Loyal fan
Posts: 356
Joined: Sun Jan 16, 2005 3:20 am

Post by EvilHit »

thats all rite but change to this it works fine like this

Code: Select all

void CGame::AdminOrder_SetEK (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_iEnemyKillCount;
  m_pClientList[i]->m_iEnemyKillCount = atoi (cPK);
  SendNotifyMsg (NULL, i, DEF_NOTIFY_ENEMYKILLS,
   m_pClientList[i]->m_iEnemyKillCount, NULL, NULL,
   NULL);
  wsprintf (notice,
   "EK Count has been changed for player %s from %d to %d.",
   m_pClientList[iClientH]->m_cCharName, oldpk, atoi (cPK));
}
}
delete pStrTok;
}
EvilHit
Loyal fan
Posts: 356
Joined: Sun Jan 16, 2005 3:20 am

Post by EvilHit »

if u have any problems give me a buzz and ill try and help u as much as i can
molo
Member
Posts: 140
Joined: Mon Jan 17, 2005 1:19 am

Post by molo »

owww.. thanks EvilHit it works perfect!! :D

thanks a lot :D

and one more thing.. i have some other code, that give me some errors.. do want to help me fix those errors? if you want to give me PM with your msn.. or i PM you.. and give my msn :P


Drajwer
&lt;3 bd long time
Posts: 841
Joined: Fri Dec 10, 2004 3:24 pm

Post by Drajwer »

And u forgot write that, its MINE CODE.

If you dont know how to use MINE codes then dont use them.
<img src='http://img440.imageshack.us/img440/2627/15pt.jpg' border='0' alt='user posted image' /><br><br>HBPolska characters:<br><br>Hellios 150+ Aresden Hero Mage<br>TheBill 120 Aresden plrider<br>Kill_Me 100 Full-Hero plrider<br>Rockeater 110+ Aresden Plate Mage<br><br><a href='http://www.helbreath.org' target='_blank'>http://www.helbreath.org</a> come and play (250 ppl online)
molo
Member
Posts: 140
Joined: Mon Jan 17, 2005 1:19 am

Post by molo »

OK SORRY! I DONT KNOW IT WAS YOURS.... I GOT THIS FROM FRIEND.!

IF IT MAKE YOU HAPPY, I'LL PUT YOUR NAME THERE!!!!!!!

and it was giving me un error.. so i just posted to see what was wrong...

anyway SORRY I FORGOT :rolleyes:
Tafka12
&lt;3 bd long time
Posts: 772
Joined: Wed Dec 28, 2005 6:32 pm

Post by Tafka12 »

Drajwer wrote: And u forgot write that, its MINE CODE.

If you dont know how to use MINE codes then dont use them.
Go beat your weenie
<img src='http://www.hot.ee/carvanho/taavi.png' border='0' alt='user posted image' /><br><br><img src='http://www.hot.ee/carvanho/Elvine.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/LieroX.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/Football.png' border='0' alt='user posted image' />
Pollof
noob
Posts: 15
Joined: Sat Jan 14, 2006 5:51 pm

Post by Pollof »

And if i want this to decrase ek... i have to put something in these word?

Code: Select all

pGet ();
But if it's that... what i have to put ?...
Drajwer
&lt;3 bd long time
Posts: 841
Joined: Fri Dec 10, 2004 3:24 pm

Post by Drajwer »

its not that
<img src='http://img440.imageshack.us/img440/2627/15pt.jpg' border='0' alt='user posted image' /><br><br>HBPolska characters:<br><br>Hellios 150+ Aresden Hero Mage<br>TheBill 120 Aresden plrider<br>Kill_Me 100 Full-Hero plrider<br>Rockeater 110+ Aresden Plate Mage<br><br><a href='http://www.helbreath.org' target='_blank'>http://www.helbreath.org</a> come and play (250 ppl online)
Pollof
noob
Posts: 15
Joined: Sat Jan 14, 2006 5:51 pm

Post by Pollof »

Drajwer wrote: its not that
So... what i have to change n what i have to put ¿?...
Post Reply