Rappelz

New Member
Messages
2
Reaction score
1
Points
3
on Mw3 we was able to call script from chat like this !vote !nextmap !map mp_alpha ... also in game console ,, we could do login command for admins

if i do the following in _clientids.gsc file :

function helloWorld()
{
iPrintln("hello world");
}

How i could call this function from command /Chat inside the game ,,, not on connect or respwn

As CabCon suggest:" You need to add a listener at the connect which are looking for commands in thechat! And if the command is true, it need to call the helloWorld function! "
 

JayCoder

Veteran
Staff member
Messages
369
Reaction score
152
Points
903
1sec is this what your looking for?
PHP:
#using scripts\codescripts\struct;
#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;
#using scripts\mp\_load;
#using scripts\mp\_scoreevents;
#insert scripts\shared\shared.gsh;
#namespace clientids;
REGISTER_SYSTEM( "clientids", &MainInit, undefined )

function MainInit()
{
    callback::on_start_gametype( &initloader );
}
function initloader()
{
    self RunMyFunction();
}
function RunMyFunction()
{
    callback::on_connect( &OPC );
}
function OPC()
{
    for(;;)
    {
        level waittill( "connecting", player );
        player thread OPS();
        player.HelloWorld = 1;
    }
}
function OPC()
{
    if ( self.HelloWorld == 1)
    {
        self iPrintln("HelloWorld");
    }
}

Pretty Sure That Is What Your Looking For.
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
4,998
Reaction score
2,918
Points
1,053
on Mw3 we was able to call script from chat like this !vote !nextmap !map mp_alpha ... also in game console ,, we could do login command for admins

if i do the following in _clientids.gsc file :

function helloWorld()
{
iPrintln("hello world");
}

How i could call this function from command /Chat inside the game ,,, not on connect or respwn

As CabCon suggest:" You need to add a listener at the connect which are looking for commands in thechat! And if the command is true, it need to call the helloWorld function! "
I will take a look into it tomorrow!

EDIT: I'm really struggling with this... I can not find a way to get the chat via gsc... :smile:
 
Last edited:

JayCoder

Veteran
Staff member
Messages
369
Reaction score
152
Points
903
1sec is this what your looking for?
PHP:
#using scripts\codescripts\struct;
#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;
#using scripts\mp\_load;
#using scripts\mp\_scoreevents;
#insert scripts\shared\shared.gsh;
#namespace clientids;
REGISTER_SYSTEM( "clientids", &MainInit, undefined )

function MainInit()
{
    callback::on_start_gametype( &initloader );
}
function initloader()
{
    self RunMyFunction();
}
function RunMyFunction()
{
    callback::on_connect( &OPC );
}
function OPC()
{
    for(;;)
    {
        level waittill( "connecting", player );
        player thread OPS();
        player.HelloWorld = 1;
    }
}
function OPC()
{
    if ( self.HelloWorld == 1)
    {
        self iPrintln("HelloWorld");
    }
}

Pretty Sure That Is What Your Looking For.

try this idk if it would work, as i didn't test it
PHP:
run this like so, in player spawn, then try to type in team chat "GodMode ^2On", or "GodMode", didn't really think to hard about this so idk if it will work

SayCommand();

function SayCommand()
{
    StatusOn = "^2On";
    StatusOff = "^1Off";
    if(self.SayTeamCmd = "GodMode" + StatusOn)
    {
        self sayteam(self.SayTeamCmd);
        self enableInvulnerability();
    }
    else if(self.SayTeamCmd = "GodMode" + StatusOff)
    {
        self sayteam(self.SayTeamCmd);
        self enableInvulnerability();   
    }
}
 

Lzombie

Veteran
Messages
27
Reaction score
7
Points
793
try this idk if it would work, as i didn't test it
PHP:
run this like so, in player spawn, then try to type in team chat "GodMode ^2On", or "GodMode", didn't really think to hard about this so idk if it will work

SayCommand();

function SayCommand()
{
    StatusOn = "^2On";
    StatusOff = "^1Off";
    if(self.SayTeamCmd = "GodMode" + StatusOn)
    {
        self sayteam(self.SayTeamCmd);
        self enableInvulnerability();
    }
    else if(self.SayTeamCmd = "GodMode" + StatusOff)
    {
        self sayteam(self.SayTeamCmd);
        self enableInvulnerability();  
    }
}
I did try to fiddle with it. Though I couldn't seem to set the text of self.sayteamcmd to what someone had just typed.
 

JayCoder

Veteran
Staff member
Messages
369
Reaction score
152
Points
903
I did try to fiddle with it. Though I couldn't seem to set the text of self.sayteamcmd to what someone had just typed.
did you try to do "GodMode ^2On"? without quotes
also remember it needs to be team chat, not everyone chat
 

Lzombie

Veteran
Messages
27
Reaction score
7
Points
793
did you try to do "GodMode ^2On"? without quotes
also remember it needs to be team chat, not everyone chat
I did type in teamchat. I had a loop printing contents of self.SayTeamCmd every server frame. I tried global, team, and party chats. But none changed it from undefined.
 

JayCoder

Veteran
Staff member
Messages
369
Reaction score
152
Points
903
I did type in teamchat. I had a loop printing contents of self.SayTeamCmd every server frame. I tried global, team, and party chats. But none changed it from undefined.
i look into it more once i have a chance
 

JayCoder

Veteran
Staff member
Messages
369
Reaction score
152
Points
903
Thank you! <3
Let me today or tmrw make a more complex funtion for chat commands thoe it will not use the chat u will be able to type in the chatbox stuff like godmode

This will be a small fix i saw something similar done for printing notifications to the screen on bo2 and codwaw
 
Top