[SSGM Plugin] SpaceOut [message #474075] |
Fri, 07 September 2012 17:36 ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/25488.jpg) |
roszek
Messages: 296 Registered: June 2010
Karma: 0
|
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;
}
![index.php?t=getfile&id=14461&private=0](index.php?t=getfile&id=14461&private=0)
-
Attachment: SpaceOut.rar
(Size: 9.20KB, Downloaded 116 times)
-
Attachment: so.jpg
(Size: 30.87KB, Downloaded 376 times)
[Updated on: Sat, 08 September 2012 06:02] Report message to a moderator
|
|
|
Re: [SSGM Plugin] SpaceOut [message #474112 is a reply to message #474075] |
Sat, 08 September 2012 14:29 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) |
iRANian
Messages: 4307 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
This should work too.
bool Replace_Spaces_Name(int id)
{
StringClass name = StringClass(Find_Player(id)->PlayerName);
bool foundSpace = false;
for (int i = 0, e = name.Get_Length(); i < e; i++)
{
if( name[i] == ' ')
{
name[i] = '_';
foundSpace = true;
}
}
if( foundSpace )
{
Find_Player(ID)->PlayerName = name;
return true;
}
return false;
}
Long time and well respected Renegade community member, programmer, modder and tester.
Scripts 4.0 private beta tester since May 2011.
My Renegade server plugins releases
|
|
|