Jump to content

Recommended Posts

Posted

Code? I have the feeling that you don't want to learn anything but just want that feature working. I've already written how to implement this in a proper way:

Try adding a new variable to the player class and handle it in Player::Update instead :)
If you have still a concrete question, you can ask, but don't request working code. For that you should fill a feature request at lighthouse or here -_-
  • 38 years later...
Posted

First i would like to say sorry if posted in wrong location.

heres what i have so far but its not working right..

as you know why you kick a player you just DC them they have no clue they got kicked.

so i added some code from arcemu and mangos but i still dont have it yet.

void Player::Kick(uint32 delay )
{
   sLog.outString("Kick Block");
   if(!delay)
   {
       sLog.outString("Kick Block IF !DELAY");
       return;
   } 
   else 
   {

       GetSession()->KickPlayer();



   }
}

player update

if(m_KickDelay > 0)

{

ChatHandler(this).GreenSystemMessageToPlr(this,"You will be removed from the server in %u seconds.",p_time);

if(p_time >= m_KickDelay)

{

m_KickDelay = 0;

Kick(p_time);

}

else

{

m_KickDelay -=p_time;

}

}

Posted
First i would like to say sorry if posted in wrong location.

heres what i have so far but its not working right..

as you know why you kick a player you just DC them they have no clue they got kicked.

so i added some code from arcemu and mangos but i still dont have it yet.

void Player::Kick(uint32 delay )
{
   sLog.outString("Kick Block");
   if(!delay)
   {
       sLog.outString("Kick Block IF DELAY");
       return;
   } 
   else 
   {
       sLog.outString("Kick Block ELSE DELAY");
       ChatHandler(this).GreenSystemMessageToPlr(this,"You will be removed from the server in %u seconds.",delay);
       SendDelayResponse(delay)

       GetSession()->KickPlayer();


   }
}

can any one help i thount is i used SenDelayResponce(delay) ot would delay the time and not go to GetSession()->LogoutPlayer(true);

until the timer was done.

at mangos, Kick doesn't take any argument as in arcemu.. and there isn't any timer for counting elapsed time or time to kick.. So this simple edit isn't enough. You should rewrite kick function at all

Posted

i already did

#include "Links.h"
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{

   Player * plr =getSelectedPlayer();
   if(plr->activate_commands == false)
   {
   RedSystemMessage(m_session,"Sorry Your Comamnds Are Not Activated Type .ac");
   return true;
   }
   //=====================================================================
   // REQUIRED RANK FOR COMMAND
   //=====================================================================
   if(m_session->GetSecurity() >= R5 || m_session->GetSecurity() >= R4)
   {
   Player* plrgplr =PlayerGetSelectedPlayer();
   if(!plrgplr)
   {
   // This pervents the player from selecting a creature and crashing the server.
   RedSystemMessage(m_session,"Sorry This Command Requires You To Select A Player.");
   return false;
   }
   Unit* unit = PlayerGetSelectedUnit();
   if(!unit)
   {
   // This pervents the player from selecting a creature and crashing the server.
   RedSystemMessage(m_session,"Sorry This Command Requires You To Select A Player.");
   return false;
   }
   plrgplr->Kick(6);
   GreenSystemMessage(m_session,"You Kicked %s",static_cast< Player* >( unit )->GetName());
   GreenSystemMessageToPlr(plrgplr,"%s Kicked You",m_session->GetPlayer()->GetName());
   char KickPlyer[1024];
    std::string input2;
    // GET RANK COLOR
    input2="|cffFFFF00(";
    if(m_session->GetSecurity() >= R5)input2+="Rank 5)";
    else if(m_session->GetSecurity() >= R4)input2+="Rank 4)";
    //GET NAME COLOR
    input2+=" |r|c1f00FF00";
    input2+=m_session->GetPlayer()->GetName();
    input2+=":|r";
    input2+=" |r|c1fFFFFFF";
    input2+=" Kicked";
    input2+=":|r";
    input2+=" |r|c1f00FFFF";
    input2+=static_cast< Player* >( unit )->GetName();
    input2+=":|r";
    // GET MESSAGE COLOR
    input2+=" |r|c2f888888";
    input2+=snprintf((char*)KickPlyer,1024,"%s From The Server.",input2.c_str());
    input2+=":|r ";
    sWorld.SendWorldWideScreenText(KickPlyer,false);
   Unit * uni=getSelectedUnit();
   uni->CastSpell(uni, 40436, true);
   uni->CastSpell(uni, 34442, true);
   return true;
   }
   if(m_session->GetSecurity() >= R3 || m_session->GetSecurity() >= R2|| m_session->GetSecurity() >= R1|| m_session->GetSecurity() >= R0)
   {
       RedSystemMessage(m_session,"Sorry This Command Actions Is For Staff Or The Server Owner.");
       return true;
   }
   return true;

}

Posted
i already did

#include "Links.h"
bool ChatHandler::HandleKickPlayerCommand(const char *args)
{

   Player * plr =getSelectedPlayer();
   if(plr->activate_commands == false)
   {
   RedSystemMessage(m_session,"Sorry Your Comamnds Are Not Activated Type .ac");
   return true;
   }
   //=====================================================================
   // REQUIRED RANK FOR COMMAND
   //=====================================================================
   if(m_session->GetSecurity() >= R5 || m_session->GetSecurity() >= R4)
   {
   Player* plrgplr =PlayerGetSelectedPlayer();
   if(!plrgplr)
   {
   // This pervents the player from selecting a creature and crashing the server.
   RedSystemMessage(m_session,"Sorry This Command Requires You To Select A Player.");
   return false;
   }
   Unit* unit = PlayerGetSelectedUnit();
   if(!unit)
   {
   // This pervents the player from selecting a creature and crashing the server.
   RedSystemMessage(m_session,"Sorry This Command Requires You To Select A Player.");
   return false;
   }
   plrgplr->Kick(6);
   GreenSystemMessage(m_session,"You Kicked %s",static_cast< Player* >( unit )->GetName());
   GreenSystemMessageToPlr(plrgplr,"%s Kicked You",m_session->GetPlayer()->GetName());
   char KickPlyer[1024];
    std::string input2;
    // GET RANK COLOR
    input2="|cffFFFF00(";
    if(m_session->GetSecurity() >= R5)input2+="Rank 5)";
    else if(m_session->GetSecurity() >= R4)input2+="Rank 4)";
    //GET NAME COLOR
    input2+=" |r|c1f00FF00";
    input2+=m_session->GetPlayer()->GetName();
    input2+=":|r";
    input2+=" |r|c1fFFFFFF";
    input2+=" Kicked";
    input2+=":|r";
    input2+=" |r|c1f00FFFF";
    input2+=static_cast< Player* >( unit )->GetName();
    input2+=":|r";
    // GET MESSAGE COLOR
    input2+=" |r|c2f888888";
    input2+=snprintf((char*)KickPlyer,1024,"%s From The Server.",input2.c_str());
    input2+=":|r ";
    sWorld.SendWorldWideScreenText(KickPlyer,false);
   Unit * uni=getSelectedUnit();
   uni->CastSpell(uni, 40436, true);
   uni->CastSpell(uni, 34442, true);
   return true;
   }
   if(m_session->GetSecurity() >= R3 || m_session->GetSecurity() >= R2|| m_session->GetSecurity() >= R1|| m_session->GetSecurity() >= R0)
   {
       RedSystemMessage(m_session,"Sorry This Command Actions Is For Staff Or The Server Owner.");
       return true;
   }
   return true;

}

Is is also from ArcEmu, isn't it ? You can't do it only by adding chat function, also "GreenSystemMessage" isn't mangos function.. Wait a moment I will try make it.

Posted

no my core is mangos and arcemu i have been combining the two emus together for about month sence rev 6767..

my code is really just for fun and learning.. just to see what i can make it do.. i enjoy it so much i wish i was a pro maybe in 5 years i will be..

maybe not.

but mangos is really so stable and arcemu is really unstable..

but i like alot of function arcemu has.. so i took mangos the stable server and added arcemu functions with it to make a project called

the mancent project

lol its all for fun..

Look at my retared code but it works so thats all i want.

sLog.outString("Kick Block");

if(!delay)

{

sLog.outString("Kick Block IF !DELAY");

return;

}

else

{

sLog.outString("Kick Block ELSE DELAY");

ChatHandler(this).GreenSystemMessageToPlr(this,"You will be removed from the server in 6 seconds.");

for (int A = 0; A < 1000000000; ++A);

ChatHandler(this).GreenSystemMessageToPlr(this,"You have 5 seconds left.");

for (int B = 0; B < 1000000000; ++B);

ChatHandler(this).GreenSystemMessageToPlr(this,"4 seconds left what are you going to do?");

for (int C = 0; C < 1000000000; ++C);

ChatHandler(this).GreenSystemMessageToPlr(this,"3 seconds. Try not to be so silly next time.");

for (int D = 0; D < 1000000000; ++D);

ChatHandler(this).GreenSystemMessageToPlr(this,"2 seconds left I hope you will try a little better next time.");

for (int E = 0; E < 1000000000; ++E);

ChatHandler(this).GreenSystemMessageToPlr(this,"You have 1 seconds.");

for (int F = 0; F < 1000000000; ++F);

ChatHandler(this).GreenSystemMessageToPlr(this,"Good Bye.");

GetSession()->KickPlayer();

}

I would show it to you guys if you wanted to see it.. but i dont want to post any URLs i like this community

Posted
I think that will make the CPU run 100% for a few seconds and probably make the whole server lag :P I'm sure there are better ways to do it.

I agree, this is a really bad coding style. Try adding a new variable to the player class and handle it in Player::Update instead :)

Posted

sLog.outString("Kick Block");
   if(!delay)
   {
       sLog.outString("Kick Block IF !DELAY");
       return;
   } 
   else 
   {
       sLog.outString("Kick Block ELSE DELAY");
       ChatHandler(this).GreenSystemMessageToPlr(this,"Yo  u will be removed from the server in 6 seconds.");

       for (int A = 0; A < 1000000000; ++A);
       ChatHandler(this).GreenSystemMessageToPlr(this,"Yo  u have 5 seconds left.");
       for (int B = 0; B < 1000000000; ++:cool:;
       ChatHandler(this).GreenSystemMessageToPlr(this,"4 seconds left what are you going to do?");
       for (int C = 0; C < 1000000000; ++C);
       ChatHandler(this).GreenSystemMessageToPlr(this,"3 seconds. Try not to be so silly next time.");
       for (int D = 0; D < 1000000000; ++D);
       ChatHandler(this).GreenSystemMessageToPlr(this,"2 seconds left I hope you will try a little better next time.");
       for (int E = 0; E < 1000000000; ++E);
       ChatHandler(this).GreenSystemMessageToPlr(this,"Yo  u have 1 seconds.");
       for (int F = 0; F < 1000000000; ++F);
       ChatHandler(this).GreenSystemMessageToPlr(this,"Go  od Bye.");
       GetSession()->KickPlayer();



   }                      

THis is _horrible_ .

If you try to understand it a bit, there are 6 loops that each count from 0 to 1000000000. (and the time for the processor to do it is wrongly estimated to 1s by the maker of this code)

So :

1) This gonna make the CPU 100% and freeze the server

2) who said 1000000000 loops made one second? This isn't accurate at all

You absolutly need to find another method.

Posted

Why do you think i asked you guys i need help with it.. im learning i dont know..

its funny that i even found a way to do it where it works..

and your all right that it dose lag the server..

so help me stop telling me how bad it is send a better example..

stop posting comments and post code.

Posted

Do you honestly think this tells any one any thing at all if they dont know what you know?

Try adding a new variable to the player class and handle it in Player::Update instead

how do you learn if you dont know or are told? or showed?

but to you comment i did try but i dont see a example..

And its not very cool to judge.. i read this code every day for hours and hours..

just becasue i cant learn as fast as some doesn't mean i dont want to learn.

you say make a veriable and add it to player.. then place it in the player update.

so like what this..

small exampel of

player.cpp

Player::Player (WorldSession *session): Unit()

{

m_kicktime =0;

}

player.h

class MANGOS_DLL_SPEC Player : public Unit

{

uint32 m_kicktime;

};

then what.. go to player update and add some thing?

void Player::Update( uint32 p_time )

{

if(m_KickDelay > 0)

{

ChatHandler(this).GreenSystemMessageToPlr(this,"You will be removed from the server in %u seconds.",p_time);

if(p_time >= m_KickDelay)

{

m_KickDelay = 0;

Kick(p_time);

}

else

{

m_KickDelay -=p_time;

}

}

my send to player chat timer is all messed up it gose so fast and the time is like 6000 so i counts down from 6000 to 0 lol how can i do it so it counts down only 6 seconds

it dont matter but hay it works good. now. thanx for pointing me in the right direction.

Posted

my send to player chat timer is all messed up it gose so fast and the time is like 6000 so i counts down from 6000 to 0 lol how can i do it so it counts down only 6 seconds

it dont matter but hay it works good. now. thanx for pointing me in the right direction.

something like

    if(m_KickDelay > 0)
   {
       if( (m_KickDelay%1000) < ( (m_KickDelay-p_time)%1000) ))
           ChatHandler(this).GreenSystemMessageToPlr(this,"You will be removed from the server in %u seconds.",p_time/1000);
       if(p_time >= m_KickDelay)
       {
           m_KickDelay = 0;
           Kick(p_time);
       }
       else
       {
           m_KickDelay -=p_time;
       }
   }

should fix this ^_^

Posted

btw the pacman developers used the same coding-style, if you try to run an old pacman version on a new computer, you cant even see your enemies, so fast is this game now ^^

and i looked at your code and i think that you got wrong with the miliseconds

cause 6000 ms are just 6 seconds (1000ms are 1s)

i wish you good luck, that you'll have succes :)

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use