PDA

View Full Version : Variation for #showstats


ChaosSlayerZ
07-06-2009, 12:08 AM
As you know #showstats allows you to see exact server stats for player or npc. Some servers even allowed this command to be used by players in order to find out their own exact stats or their pets. (/pet report just doesn't give much info)

I do want players to be able to see own or exact pet stats, but I realy do not want them to use this command to look at mobs or other players.

Is it posible to make a minor version of this command which can ONLY be used on self or own pet? Like #mystats - give players stat when player targets self, or pet's stats if pet is targeted, but will not give any info if you target other players, other player's pets, or mobs.

What you think?

AndMetal
07-06-2009, 01:27 AM
Should be pretty easy to do. Just copy the #showstats command, but add 2 checks: 1 to see if the target is your pet, and another to see if your target is you. If not, it will default to you.

Here's the current #showstats command code from zone/command.cpp (http://code.google.com/p/projecteqemu/source/browse/trunk/EQEmuServer/zone/command.cpp?r=747#4146):

void command_showstats(Client *c, const Seperator *sep)
{
if (c->GetTarget() != 0 )
c->GetTarget()->ShowStats(c);
else
c->ShowStats(c);
}


You can change the first if statement to check if the target is your pet (not sure what the function is off the top of my head, something like IsPet()). The else should be able to stay the same.

Methinks this might be a good time to learn you some coding :-)

ChaosSlayerZ
07-06-2009, 01:43 AM
Hey you are the briliant coder, I am just the ideas generator =P
One day I will actualy sit down and start looking at the source... but it will be a while before I get there - I am desperatly trying to complite my custom DB content first.
Plus I am hoping to convince you guys to make this part of official code (not just a custom insert) :cool:

AndMetal
07-06-2009, 02:44 AM
Hey you are the briliant coder

Now I dunno about all that...

But seriously, this is a pretty straightforward change (basically just need to dig through the code a bit, which is a heck of a lot easier to do with Visual Studio), so I think it would be a good chance to get your feet wet. Plus, it should help with learning how to do (at the least) some of the small tweaks.

That, and I'm feeling kinda lazy right now :D

Zeice
07-06-2009, 05:22 PM
I was thinking about this the other day for my server as well. I'm not a coder either but I figured I'd give something simple like this a shot. This is what I came up with, I'm not sure if I have the checks right...but I figure it should be in the ballpark. Let me know if it looks ok, I can't compile and test it just yet.


command_add("mystats","- Show details about you or your pet",50,command_mystats) ||

void command_mystats(Client *c, const Seperator *sep)
{
if (c->GetTarget() != 0 )
c->GetTarget()->IsPet()->IsClient()->ShowStats(c);
else if (!c->GetTarget()->IsClient()->IsPet())
c->Message(0, "This command only works on players and pets.");
else
c->ShowStats(c);
}

Zeice
07-06-2009, 09:01 PM
Yeah, so that definitely didn't work. I figured it out though. Not bad for my first attempt at doing anything with the code. However, as far as keeping it to your own stats I couldn't figure out how to do that. This atleast allows it to only work on clients and pets, which for me is the biggest thing.

SQL:

INSERT INTO commands VALUES ('mystats', '0', 'Allows player to view pet and client stats, but not npc');

File changes:


command.h
---------------

ADD

void command_mystats(Client *c, const Seperator *sep);

AFTER

void command_showstats(Client *c, const Seperator *sep);



command.cpp
----------------

ADD
command_add("mystats","- Show details about you or your pet",50,command_mystats) ||

AFTER

command_add("showstats","- Show details about you or your target",50,command_showstats) ||


ADD

void command_mystats(Client *c, const Seperator *sep)
{
if (c->GetTarget() != 0 )
if (c->GetTarget()->IsClient())
c->GetTarget()->ShowStats(c);
else if (c->GetTarget()->IsPet())
c->GetTarget()->ShowStats(c);
else
c->ShowStats(c);
}


AFTER

void command_showstats(Client *c, const Seperator *sep)
{
if (c->GetTarget() != 0 )
c->GetTarget()->ShowStats(c);
else
c->ShowStats(c);
}

ChaosSlayerZ
07-06-2009, 09:57 PM
nice =)
I hope this will make it into the main source

trevius
07-10-2009, 06:36 AM
I added this into R762 on the SVN. I made a slight modification to it so that it only works on the client itself or on it's own pet and nothing else. Seems to work just fine now.

void command_mystats(Client *c, const Seperator *sep)
{
if (c->GetTarget() && c->GetPet()) {
if (c->GetTarget()->IsPet() && c->GetTarget() == c->GetPet())
c->GetTarget()->ShowStats(c);
else
c->ShowStats(c);
}
else
c->ShowStats(c);
}

Thanks for bringing this up, as it is something I have been meaning to add for a while, and just hadn't looked into adding yet. ChaosSlayer was bugging me about it, so I spent a couple minutes looking into it and it was quite simple and quick to do :P

ChaosSlayerZ
07-10-2009, 09:40 AM
hey, technicly I wasn't bugging you - I seduced you on the very fist atempt =P