[SSGM Plugin] SpaceOut [message #474075] |
Fri, 07 September 2012 17:36 |
|
roszek
Messages: 296 Registered: June 2010
Karma:
|
Recruit |
|
|
After going through some source code of one of iran's plugins (that one called "join name regulator"), I threw together a simple plugin that changes spaces in nicks to underscores.
It seems to work and did not crash any servers I tested it on.
For 4.0
Toggle Spoiler#include "General.h"
#include "SpaceOut.h"
#include "engine_tt.h"
#include "engine_io.h"
#include "gmgame.h"
void Console(const char *Format, ...)
{
char buffer[256];
va_list va;
_crt_va_start(va, Format);
vsnprintf(buffer, 256, Format, va);
va_end(va);
Console_Input(buffer);
}
bool checkChars( WideStringClass incName ,int ID )
{
char* name = StringClass(incName).Peek_Buffer();
bool it=false;
int size = Find_Player(ID)->PlayerName.Get_Length();
int i = 0;
for ( ; i<size ; i++ )
{
if( name[i] == ' ')
{
name[i] = '_';
it = true;
}
}
if(it)
Find_Player(ID)->PlayerName = name;
return(it);
}
void SpaceOut::OnPlayerJoin(int PlayerID, const char *PlayerName)
{
WideStringClass aNick = Find_Player(PlayerID)->PlayerName;
if(checkChars(Find_Player(PlayerID)->PlayerName ,PlayerID))
Console("PAMSG %d Your name has been changed from: '%S' to: '%S'", PlayerID, aNick ,Find_Player(PlayerID)->PlayerName);
}
SpaceOut::SpaceOut()
{
RegisterEvent(EVENT_PLAYER_JOIN_HOOK,this);
}
SpaceOut::~SpaceOut()
{
UnregisterEvent(EVENT_PLAYER_JOIN_HOOK,this);
}
SpaceOut spaceout;
extern "C" __declspec(dllexport) Plugin* Plugin_Init()
{
return &spaceout;
}
-
Attachment: SpaceOut.rar
(Size: 9.20KB, Downloaded 130 times)
-
Attachment: so.jpg
(Size: 30.87KB, Downloaded 424 times)
[Updated on: Sat, 08 September 2012 06:02] Report message to a moderator
|
|
|