I need help with script, it seem not to work.

Hello i need help to get scripts working, cos right now i can apply them and stuff but nothing happends. i got the newest pull. is it a tc bug atm or is it just me? and why is it just me?

Please help me, i don’t understand scripting alot, but i have followed all tutorial and everything noone works for me /cry.

-Please ask questions that can make you understand why it don’t work

-I got my script here, and yes i know how to add a script -.-

#include "ScriptPCH.h"
#include "Chat.h"
 
#define FACTION_SPECIFIC 0
 
std::string GetNameLink(Player* player)
{
        std::string name = player->GetName();
        std::string color;
        switch(player->getClass())
        {
        case CLASS_DEATH_KNIGHT:
                color = "|cffC41F3B";
                break;
        case CLASS_DRUID:
                color = "|cffFF7D0A";
                break;
        case CLASS_HUNTER:
                color = "|cffABD473";
                break;
        case CLASS_MAGE:
                color = "|cff69CCF0";
                break;
        case CLASS_PALADIN:
                color = "|cffF58CBA";
                break;
        case CLASS_PRIEST:
                color = "|cffFFFFFF";
                break;
        case CLASS_ROGUE:
                color = "|cffFFF569";
                break;
        case CLASS_SHAMAN:
                color = "|cff0070DE";
                break;
        case CLASS_WARLOCK:
                color = "|cff9482C9";
                break;
        case CLASS_WARRIOR:
                color = "|cffC79C6E";
                break;
        }
        return "|Hplayer:"+name+"|h|cffFFFFFF["+color+name+"|cffFFFFFF]|h|r";
}
 
class cs_world_chat : public CommandScript
{
        public:
                cs_world_chat() : CommandScript("cs_world_chat"){}
 
        ChatCommand * GetCommands() const
        {
                static ChatCommand WorldChatCommandTable[] =
                {
                        {"c",        SEC_PLAYER,             true,           &HandleWorldChatCommand,        "", NULL},
                        {NULL,          0,                              false,          NULL,                                           "", NULL}
                };
 
                return WorldChatCommandTable;
        }
 
        static bool HandleWorldChatCommand(ChatHandler * handler, const char * args)
        {
                if (!handler->GetSession()->GetPlayer()->CanSpeak())
                        return false;
                std::string temp = args;
 
                if (!args || temp.find_first_not_of(' ') == std::string::npos)
                        return false;
 
                std::string msg = "";
                Player * player = handler->GetSession()->GetPlayer();
 
                switch(player->GetSession()->GetSecurity())
                {
                        // Player
                        case SEC_PLAYER:
                                if (player->GetTeam() == ALLIANCE)
                                {
                                        msg += "|cff0000ff[Alliance] ";
                                        msg += GetNameLink(player);
                                        msg += " |cfffaeb00";
                                }
 
                                else
                                {
                                        msg += "|cffff0000[Horde] ";
                                        msg += GetNameLink(player);
                                        msg += " |cfffaeb00";
                                }
                                break;
                        // Moderator/trial
                        case SEC_MODERATOR:
                                msg += "|cffff8a00[Mod] ";
                                msg += GetNameLink(player);
                                msg += " |cfffaeb00";
                                break;
                        // GM
                        case SEC_GAMEMASTER:
                                msg += "|cff00ffff[GM] ";
                                msg += GetNameLink(player);
                                msg += " |cfffaeb00";
                                break;
                        // Admin
                        case SEC_ADMINISTRATOR:
                                msg += "|cfffa9900[Admin] ";
                                msg += GetNameLink(player);
                                msg += " |cfffaeb00";
                                break;
 
                }
                       
                msg += args;
                if (FACTION_SPECIFIC)
                {
                        SessionMap sessions = sWorld->GetAllSessions();
                        for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr)
                                if (Player* plr = itr->second->GetPlayer())
                                        if (plr->GetTeam() == player->GetTeam())
                                                sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), plr);
                }
                else
                        sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), 0);  
 
                return true;
        }
};
 
void AddSC_cs_world_chat()
{
        new cs_world_chat();
}

— Canned message start —

This thread is not related to the official Trinity codebase and was moved to the Custom Code section.

Please read the stickies next time.

— Canned message end —

Can anyone help please i think its the new trinitycore version. some kinda bug maby Helpz!

Can you take 5 min of ur time to compile a new one with the newest version new sql everything new and add my script. And tell me if it works i have tried almost everything, mine wont work just made a whole new one.

Not going to work since we shifted over to the RBAC System. Look at one of the recent commits for instructions on how to convert normal commands to RBAC.

So i have to rewrite the script for it to work rewrite it into rbac? and can you link where to do that, would really apreciate it!

https://github.com/TrinityCore/TrinityCore/commit/3232b69ff3b12441723349e2febe74f81d98cd24

https://github.com/TrinityCore/TrinityCore/commit/ea26928a99fbd0cc8ce33141b690152cfe49fe28

Pretty much self-explanatory.

I have tried to edit now

#include “ScriptPCH.h”
#include “Chat.h”

#define FACTION_SPECIFIC 0

std::string GetNameLink(Player* player)
{
std::string name = player->GetName();
std::string color;
switch(player->getClass())
{
case CLASS_DEATH_KNIGHT:
color = “|cffC41F3B”;
break;
case CLASS_DRUID:
color = “|cffFF7D0A”;
break;
case CLASS_HUNTER:
color = “|cffABD473”;
break;
case CLASS_MAGE:
color = “|cff69CCF0”;
break;
case CLASS_PALADIN:
color = “|cffF58CBA”;
break;
case CLASS_PRIEST:
color = “|cffFFFFFF”;
break;
case CLASS_ROGUE:
color = “|cffFFF569”;
break;
case CLASS_SHAMAN:
color = “|cff0070DE”;
break;
case CLASS_WARLOCK:
color = “|cff9482C9”;
break;
case CLASS_WARRIOR:
color = “|cffC79C6E”;
break;
}
return “|Hplayer:”+name+“|h|cffFFFFFF[”+color+name+“|cffFFFFFF]|h|r”;
}

class cs_world_chat : public CommandScript
{
public:
cs_world_chat() : CommandScript(“cs_world_chat”){}

    ChatCommand * GetCommands() const
    {
            static ChatCommand WorldChatCommandTable[] =
            {
                    {"c",        RBAC_PERM_PLAYER_COMMANDS,             true,           &HandleWorldChatCommand,        "", NULL},
                    {NULL,          0,                              false,          NULL,                                           "", NULL}
            };

            return WorldChatCommandTable;
    }

    static bool HandleWorldChatCommand(ChatHandler * handler, const char * args)
    {
            if (!handler->GetSession()->GetPlayer()->CanSpeak())
                    return false;
            std::string temp = args;

            if (!args || temp.find_first_not_of(' ') == std::string::npos)
                    return false;

            std::string msg = "";
            Player * player = handler->GetSession()->GetPlayer();

            switch(player->GetSession()->GetSecurity())
            {
                    // Player
                    case RBAC_PERM_PLAYER_COMMANDS:
                            if (player->GetTeam() == ALLIANCE)
                            {
                                    msg += "|cff0000ff[Alliance] ";
                                    msg += GetNameLink(player);
                                    msg += " |cfffaeb00";
                            }

                            else
                            {
                                    msg += "|cffff0000[Horde] ";
                                    msg += GetNameLink(player);
                                    msg += " |cfffaeb00";
                            }
                            break;
                    // Moderator/trial
                    case RBAC_PERM_MODERATOR_COMMANDS:
                            msg += "|cffff8a00[Mod] ";
                            msg += GetNameLink(player);
                            msg += " |cfffaeb00";
                            break;
                    // GM
                    case RBAC_PERM_GAMEMASTER_COMMANDS:
                            msg += "|cff00ffff[GM] ";
                            msg += GetNameLink(player);
                            msg += " |cfffaeb00";
                            break;
                    // Admin
                    case RBAC_PERM_ADMINISTRATOR_COMMANDS:
                            msg += "|cfffa9900[Admin] ";
                            msg += GetNameLink(player);
                            msg += " |cfffaeb00";
                            break;

            }
                   
            msg += args;
            if (FACTION_SPECIFIC)
            {
                    SessionMap sessions = sWorld->GetAllSessions();
                    for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr)
                            if (Player* plr = itr->second->GetPlayer())
                                    if (plr->GetTeam() == player->GetTeam())
                                            sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), plr);
            }
            else
                    sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), 0);  

            return true;
    }

};

void AddSC_cs_world_chat()
{
new cs_world_chat();
}

-And added REPLACE INTO rbac_permissions (id, name) VALUES (472, ‘c’);

to sql db

-and added same for world.commands REPLACE INTO command (name, permission, help) VALUES (‘c’, 472, NULL);

-Any ideas what im doing wrong now?

Should i add something into somewhere else?

i really don’t understand alot about this rbac /emoticons/default_tongue.png

-And btw if its not working how do i downgrade theese changes with the rbac?

Bump…

I found the problem only thing i had to edit was in world.command permission 7! But thx for making me understand /emoticons/default_tongue.png

Added custom ranks 1 hour of db work later and i had custom ranks! Anyone need help with it just message me.

Thanks

-Pie

It isn’t hard. Especially since RBAC is extremely adaptable. So, see ? Once you get the gist of it, RBAC is awesome.

You are totally right but there should be a guide that tells all the information we have gathered.

-to make it easier for new trinitycore users

-make everyone spare time, as we say time is money /emoticons/default_wink.png

Agree

-Pie

http://collab.kpsn.org/display/tc/RBAC%3A+Role+based+Access+Control

Took me about 30 seconds, including but not only closing the “WHAT’S NEW ?!” window.

Also, the commits are also helpful.

Well, i made custom gm ranks. I thought i had to edit my script to make it work. xD