Re: [Plug-in] SSGM2.02 Ping Plugin [message #439345 is a reply to message #439296] |
Fri, 12 November 2010 13:25 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/20487.jpg) |
Xpert
Messages: 1588 Registered: December 2005 Location: New York City
Karma: 0
|
General (1 Star) |
|
|
reborn wrote on Fri, 12 November 2010 04:45 | Did you use my code as an example? I think I fixed the bug in get_part_names for that to work, you should post that too. ![Smile](images/smiley_icons/icon_smile.gif)
Good effort! ![Smile](images/smiley_icons/icon_smile.gif)
|
Ahh yes I forgot about that.
engine_player.cpp
int Get_Part_Names(const char *name1)
{
GenericSLNode *x = BaseGameObjList->HeadNode;
int count = 0;
while (x)
{
GameObject *o = As_ScriptableGameObj((GameObject *)x->NodeData);
if (o && Commands->Is_A_Star(o) && As_SoldierGameObj(o)){
const char *name = Get_Player_Name(o);
if (stristr(name,name1))
{
count++;
}
delete[] name;
}
x = x->NodeNext;
}
return count;
}
const char *Get_Player_Name(GameObject *obj)
{
if (!Commands->Get_ID(obj) || !obj)
{
return newstr("None");
}
GameObject *o = As_SoldierGameObj(obj);
char *c = (char *)o;
if (!o)
{
return newstr("None");
}
c += 0x960;
cPlayer *x = (cPlayer *)*(unsigned int *)c;
if (!x)
{
return newstr("None");
}
return WideCharToChar(x->PlayerName);
}
const char *Get_Player_Name_By_ID(int PlayerID)
{
cPlayer *x = FindPlayer(PlayerID);
if (!x)
{
return 0;
}
return WideCharToChar(x->PlayerName);
}
![http://i32.photobucket.com/albums/d42/XpertMaverick/xpertyankee.jpg](http://i32.photobucket.com/albums/d42/XpertMaverick/xpertyankee.jpg)
Creator of NetGuard, an IRC network regulator.
Developer of the CloudyServ 0.982-X project.
Developer of the CloudyServ Ren-X bot.
Part time streamer - https://twitch.tv/gg_wonder
[Updated on: Fri, 12 November 2010 13:26] Report message to a moderator
|
|
|
|
Re: [Plug-in] SSGM2.02 Ping Plugin [message #439451 is a reply to message #439290] |
Sat, 13 November 2010 23:59 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](/images/avatars/N_Tech.jpg) |
ExEric3
Messages: 746 Registered: February 2005 Location: Slovakia
Karma: 0
|
Colonel |
|
|
Xpert wrote on Fri, 12 November 2010 08:41 | This is an old bump, I know, but I was browsing the forums to see if there's anything I can make use for myself and I came across this. So I decided to show mine, I'll paste it. Maybe if Exeric still browse these forums, you can make use of it too? You don't have to put the whole player's name.
class ConnectionChatCommand : public ChatCommandClass {
void Triggered(int ID,const TokenClass &Text,int ChatType) {
if (!Text[1].empty()) {
GameObject *obj;
std::string name = Text[1].c_str();
std::string sender = Get_Player_Name_By_ID(ID);
int amount = 0;
amount = Get_Part_Names(name.c_str());
if (amount == 1) {
obj = Get_Part_Name(name.c_str());
int PID = Get_Player_ID(obj);
name = Get_Player_Name(obj);
if (ID != PID) {
Console_Input(StrFormat("ppage %d Connection for %s -> Ping: %d; Kbits: %d; Used bandwidth: %d;",ID,name.c_str(),Get_Ping(PID),Get_Kbits(PID),Get_Bandwidth(PID)).c_str());
}
else {
Console_Input(StrFormat("ppage %d Your connection -> Ping: %d; Kbits: %d; Used bandwidth: %d;",ID,Get_Ping(ID),Get_Kbits(ID),Get_Bandwidth(ID)).c_str());
}
}
else if (amount == 0) {
Console_Input(StrFormat("ppage %d Player not found.",ID).c_str());
return;
}
else if (amount > 1) {
obj = Get_GameObj_By_Player_Name(name.c_str());
if (!obj) {
Console_Input(StrFormat("ppage %d There are %i players with that substring, please make the name more unique.",ID,amount).c_str());
return;
}
}
}
else {
Console_Input(StrFormat("ppage %d Your connection -> Ping: %d; Kbits: %d; Used bandwidth: %d;",ID, Get_Ping(ID), Get_Kbits(ID), Get_Bandwidth(ID)).c_str());
}
}
};
ChatCommandRegistrant<ConnectionChatCommand> ConnectionChatCommandReg("!ping;!lag",CHATTYPE_ALL,0,GAMEMODE_ALL);
|
Thanks for your code. For you all works? Because when I use in game !ping partname FDS crash with this:
Exception occurred at 0x38D1B717 (No Owner)
The Renegade FDS tried to write to address 0x38d1b717 (No Owner)
Yeah I updated engine_player.cpp which you posted here.
|
|
|
Re: [Plug-in] SSGM2.02 Ping Plugin [message #439453 is a reply to message #381102] |
Sun, 14 November 2010 01:37 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/20487.jpg) |
Xpert
Messages: 1588 Registered: December 2005 Location: New York City
Karma: 0
|
General (1 Star) |
|
|
Get_Part_Name was also fixed by reborn, I forgot to paste that too.
GameObject *Get_Part_Name(const char *name1)
{
GenericSLNode *x = BaseGameObjList->HeadNode;
int count = 0;
GameObject *current = 0;
while (x)
{
GameObject *o = As_ScriptableGameObj((GameObject *)x->NodeData);
if (o && Commands->Is_A_Star(o) && As_SoldierGameObj(o)){
const char *name = Get_Player_Name(o);
if (stristr(name,name1))
{
current = o;
count++;
}
delete[] name;
}
x = x->NodeNext;
}
if ((count == 1) && (current) && (Commands->Get_ID(current)))
{
return current;
}
else
{
return 0;
}
}
It should work now with this.
![http://i32.photobucket.com/albums/d42/XpertMaverick/xpertyankee.jpg](http://i32.photobucket.com/albums/d42/XpertMaverick/xpertyankee.jpg)
Creator of NetGuard, an IRC network regulator.
Developer of the CloudyServ 0.982-X project.
Developer of the CloudyServ Ren-X bot.
Part time streamer - https://twitch.tv/gg_wonder
[Updated on: Sun, 14 November 2010 01:38] Report message to a moderator
|
|
|
Re: [Plug-in] SSGM2.02 Ping Plugin [message #439601 is a reply to message #381102] |
Tue, 16 November 2010 05:30 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) |
![](http://renegadeforums.com/images/avatars/gosticon 0000.jpeg) |
jnz
Messages: 3396 Registered: July 2006 Location: 30th century
Karma: 0
|
General (3 Stars) |
|
|
That Get_Part_Names function can be exploited, if a player's name has a substring of another player's name then Get_Part_Name will always fail for the substring. IE:
jnz joins the game
jnzkiller joins the game
Get_Part_Names("jnz"); //returns 0
Also note that it would be worth changing stricmp and stristr to strcmp and strstr, I am not sure but I think 2 players can join with the same name but in diffrent case. ("jnz", "JNZ"). If this is not the case then just ignore me.
A fix would be:
GameObject *Get_Part_Name(const char *name1)
{
GenericSLNode *x = BaseGameObjList->HeadNode;
int count = 0;
GameObject *current = 0;
while (x)
{
GameObject *o = As_ScriptableGameObj((GameObject *)x->NodeData);
if (o && Commands->Is_A_Star(o) && As_SoldierGameObj(o)){
const char *name = Get_Player_Name(o);
if(stricmp(name, name1) != 0)
{
delete []name;
return o;
}
if (stristr(name,name1))
{
current = o;
count++;
}
delete[] name;
}
x = x->NodeNext;
}
if ((count == 1) && (current) && (Commands->Get_ID(current)))
{
return current;
}
else
{
return 0;
}
}
|
|
|