Please or Register to create posts and topics.

Vscripts and Alias (WHY U NO WORK?)

Ok, so I've been trying for days now to get a simple script to tell the console "alias" for some "secret codes" but it isn't. I've so far tried three ways about it:

Code: Select all
function PlayerComment(playercon_comment, comment_here)
{
EntFire("generic_serv_command","Command","alias playercon_comment say comment_here",0.0)
printl("THIS CODE IS RUNNING.")
}

//--Execute at start--
PlayerComment()

This doesn't error (assuming generic_serv_command is in the map) but it doesn't work. I could tell it was running because the printl code worked. (also it's being run off another function that replaces palyercon_comment and comment_here but that can't be the cuase of the problem since the ONLY function within that function is this function.)

So I tried a different method:

Code: Select all
function PlayerComment(alias_name, relay_name)
{
        SendToConsole("alias + alias_name + say + relay_name")
        printl("IT HOPEFULLY WORKS")
}

This produced the same results; no error, but no alias, and printl worked.(and again being run on another function that replaces alias_name and relay_name.)

As a last resort I tried:

Code: Select all
function  Test1()
{
SendToConsole("alias Test say Works")
}

I typed this very command ingame and it works but from the script it does not.(I mean the whole command not just test)

Vscript tries Alias -> I type test -> nothing happens
I type the Alias manually -> I type test -> Works appears.

Anyone know what i'm doing wrong?

Image

perhaps you need a comma between alias Test and say Works?

SendToConsole("alias Test", "say Works")

?????????????????????????????TWP Releases | My Workshop
chickenmobile wrote:
perhaps you need a comma between alias Test and say Works?

SendToConsole("alias Test", "say Works")

That wasn't it but I did fix it thanks to help from Omnicoder:

Code: Select all
function ConsoleComment(b1, b2)
{
        SendToConsole("alias" + b1 + ""echo" + b2 + """);
}
function Commenta()
{
ConsoleComment(word_put_in_console_here, Console_output_here);
}

the are important apparently which was why mine wasn't working before. (also this one uses echo instead of say to it echos in the console and doesn't make your say it in typed chat.) I do like how Vscripts can put in variables for placeholders (b1 and b2 in this case) it made the code much cleaner in the long run.

Image

To seperate two commands in one line you need to use ;.
For example: alias Test; say Works

Skotty wrote:
To seperate two commands in one line you need to use ;.
For example: alias Test; say Works

He already figured it out but thanks for trying!

?????????????????????????????TWP Releases | My Workshop
Skotty wrote:
To seperate two commands in one line you need to use ;.
For example: alias Test; say Works

It's not two commands, alias is used to make a custom phrase typed in the console execute a console command.

"alias test say works" means the Alias for "say works" is "test". if you typed "test" in the console after typing that command, it would be like you typed "say works" and you would say "works" in typed chat.

Anyway the above code only works for SP but (thanks to Omnicoder) I have managed to get a MP version functioning. (that mostly omnicoder coded :P)

here's both working versions:

SP

Code: Select all
function ConsoleCommentSP(b1, b2)
{
        SendToConsole("alias " + b1 + ""echo " + b2 + """);
}
function  Comment1()
{
ConsoleCommentSP("fatty", "Fatty fatty,no parents.");
}

---CODE--- //executed on map spawn
Comment1()

MP <--- works when I tested it with ss_map, not sure if it works online.

Code: Select all
function ConsoleCommentMP(b1, b2)
{
for (local ent = Entities.FindByName(null, "player"); ent != null; ent = Entities.FindByName(ent,"player"));
{
SendToConsole("alias " + b1 + ""echo " + b2 + """);
}
}

function  Comment1()
{
ConsoleCommentMP("GlaDOSisdumb", "I do hope you know she can read this console.");
}

---CODE--- //executed on map spawn
Comment1()

All you need to do to get these to run is just putting the script in a logic_script entity. (you can also trigger both manually using "RunScriptCode -> Comment1()".) Then ingame just type "fatty" or "GlaDOSisdumb" into the console to get the reply.

Image