1

Topic: BanAddr

Hello all
I want to use banaddr in player.cpp file how do this

pThis->BanAddr(pThis->Server()->m_NetServer.ClientAddr(ClientID), 60*60, "Test");

2 (edited by xush 2016-03-04 20:24:19)

Re: BanAddr

I doubt that pThis exists on default somewhere in CPlayer... You should show us your whole snippet.

What you want to have is a pointer to the CServerBan object, which is AFAIK not accessible from CPlayer without some other modifications to the source. I would suggest you to use the (a bit hacky) way below if you are a beginner at programming and just want to hack your own mod quickly:

char aAddr[NETADDR_MAXSTRSIZE];
GameServer()->Server()->GetClientAddr(GetCID(), aAddr, NETADDR_MAXSTRSIZE);
char aBan[128];
str_format(aBan, sizeof aBan, "ban %s %d %s", aAddr, 60*60, "Test" );
GameServer()->Console()->ExecuteLine(aBan);

Not tested, but should be working. **note that this is not the proper way, but its even done in fng that way**

Real programmers don't comment their code - it was hard to write, it should be hard to understand.
Proudly verkeckt since 2010.