Ecco-SC / Ecco

A complete economy & buy menu plugin for Sven Co-op 5.x
Mozilla Public License 2.0
9 stars 0 forks source link

Commands not working #7

Open TheReflectingVoid opened 5 months ago

TheReflectingVoid commented 5 months ago

Hello can you give me a working example scripts that would allow a player to purchase low gravity, change speed or heal everyone in the game.

name: heal all cost: 100 heal 100 %PLAYERTEAM% category: magic broadcast %PLAYER% cast a healing spell for 100 credits!

I tried this and it only worked for the player who does it. PLAYERTEAM does not seem to work.

name: mk ii cost: 1 maxspeed 540 %PLAYER% category: speed broadcast %PLAYER% purchased a speed upgrade for 500 credits!

this does not seem to change player speed unless I set the server speed higher than default values which defeats the purpose of letting players buy speed upgrades. My guess with this is that the map defaults are overriding the value.

and I have never gotten gravity to work.

Also, is it possible to use the buy menu to allow a player to buy a "say command" so that I could make them type things into chat such as commands for unrelated plugins?

DrAbcOfficial commented 5 months ago
  1. This marco cannot be used with %PLAYERTEAM%, you can write a new marco to do that.
  2. Yes, this is SC's setting and I can't change it, but you can use a new plugin to increase the maximum speed.
  3. Gravity is unavailable due to sc updates, I've implemented it in the latest commit using a more straightforward approach
  4. yes u can do it with a addon, i suppose…….
DrAbcOfficial commented 5 months ago

this is a addon for healing all teammate

namespace EccoAddon{
namespace EchoHealAll
{
    void PluginInit(){
        EccoScriptParser::Register(CEccoMarco("healall_teammate", Marco_healall_teammate));
    }

    string GetAuthor(){
        return "Dr.Abc";
    }

    string GetContactInfo(){
        return "https://github.com/Ecco-SC/Ecco";
    }

    bool Marco_healall_teammate(CBasePlayer@ pPlayer, array<string>@ args)
    {
        int clas = pPlayer.Classify();
        for(int i = 1; i <= 32; i++){
            CBasePlayer@ pTarget = g_PlayerFuncs.FindPlayerByIndex(i);
            if ( pTarget !is null && pTarget.IsConnected() && pTarget.Classify() == clas ){
                pTarget.TakeHealth(atof(args[1]), DMG_MEDKITHEAL, 1);
            }
        }
        return true;
    }
}
}
DrAbcOfficial commented 5 months ago

here is a example plugin to unlock server maxspeed limit

float g_flOriginalMaxSpeed = 240.0f;
void PluginInit(){
    g_Module.ScriptInfo.SetAuthor( "drabc" );
    g_Module.ScriptInfo.SetContactInfo( "bruh" );
    g_Hooks.RegisterHook(Hooks::Player::PlayerSpawn, @PlayerSpawn);
}
void MapStart(){
    g_flOriginalMaxSpeed = g_EngineFuncs.CVarGetFloat("sv_maxspeed");
    g_EngineFuncs.CVarSetFloat("sv_maxspeed", 9999999.0f);
}
HookReturnCode PlayerSpawn( CBasePlayer@ pPlayer ){
    pPlayer.SetMaxSpeed(g_flOriginalMaxSpeed);
    return HOOK_CONTINUE;
}
DrAbcOfficial commented 5 months ago

maybe this addon work, idk, never tried it.

namespace EccoAddon{
namespace EchoSayCommand
{
    dicitonary dicAvaliable = {};
    void PluginInit(){
        EccoScriptParser::Register(CEccoMarco("enable_say", Marco_enable_say));
        g_Hooks.RegisterHook(Hooks::Player::ClientSay, @EccoAddon::EchoSayCommand::ClientSay);
    }

    string GetAuthor(){
        return "Dr.Abc";
    }

    string GetContactInfo(){
        return "https://github.com/Ecco-SC/Ecco";
    }

    bool Marco_enable_say(CBasePlayer@ pPlayer, array<string>@ args)
    {
        string id = EccoPlayerInventory::GetUniquePlayerId(@pPlayer);
        if(!dicAvaliable.exists(id))
            dicAvaliable[id] = true;
        else
            return false;
        return true;
    }
    HookReturnCode ClientSay(SayParameters@ pParams){
        CBasePlayer@ pPlayer = pParams.GetPlayer();
        const CCommand@ pCommand = pParams.GetArguments();
        string arg = pCommand[0].ToLowercase();
        arg.Trim();
        string id = EccoPlayerInventory::GetUniquePlayerId(@pPlayer);
        if(pPlayer !is null && EccoUtility::CanOpenShop(arg)){
            if(!dicAvaliable.exists(id))
                return HOOK_HANDLED;
        }
        return HOOK_CONTINUE;
    }
}
}
TheReflectingVoid commented 5 months ago

I tried to add three of these as addons after making them into .as scripts but it breaks Ecco and it won't run. I have tried running one at a time and they all break Ecco. Maybe I am missing a step.

include "addons/EchoMaxSpeed"

include "addons/EchoHealAll"

include "addons/EchoSayCommand"


From: Dimethylbiguanide Difrax @.> Sent: Tuesday, May 7, 2024 10:23 PM To: Ecco-SC/Ecco @.> Cc: TheReflectingVoid @.>; Author @.> Subject: Re: [Ecco-SC/Ecco] Commands not working (Issue #7)

maybe this addon work, idk, never tried it.

namespace EccoAddon{ namespace EchoSayCommand { dicitonary dicAvaliable = {}; void PluginInit(){ EccoScriptParser::Register(CEccoMarco("enable_say", Marco_enable_say)); g_Hooks.RegisterHook(Hooks::Player::ClientSay, @EccoAddon::EchoSayCommand::ClientSay); }

string GetAuthor(){
    return "Dr.Abc";
}

string GetContactInfo(){
    return "https://github.com/Ecco-SC/Ecco";
}

bool Marco_enable_say(CBasePlayer@ pPlayer, array<string>@ args)
{
            string id = ***@***.***);
    if(!dicAvaliable.exists(id))
                    dicAvaliable[id] = true;
            else
                    return false;
    return true;
}
HookReturnCode ClientSay(SayParameters@ pParams){
            CBasePlayer@ pPlayer = pParams.GetPlayer();
            const CCommand@ pCommand = pParams.GetArguments();
            string arg = pCommand[0].ToLowercase();
            arg.Trim();
            string id = ***@***.***);
            if(pPlayer !is null && EccoUtility::CanOpenShop(arg)){
                    if(!dicAvaliable.exists(id))
                            return HOOK_HANDLED;
            }
            return HOOK_CONTINUE;
}

} }

— Reply to this email directly, view it on GitHubhttps://github.com/Ecco-SC/Ecco/issues/7#issuecomment-2099613525, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANQJ73RLRPTSMSFGF6UEEXDZBGECLAVCNFSM6AAAAABHIFXMHCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJZGYYTGNJSGU. You are receiving this because you authored the thread.