Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.26 KB

ADDSCRIPTCOMMAND_EXAMPLE.md

File metadata and controls

48 lines (36 loc) · 1.26 KB

This is a very simple example how to use chat commands added by scripts in CoD4X. This example should help to make use of the new added callback maps\mp\gametypes\_globallogic::Callback_ScriptCommand and the new added function: addscriptcommand().


Add to maps\mp\gametypes\_callbacksetup:

/*================
Called by code when a script defined command has been invoked.
================*/
CodeCallback_ScriptCommand(command, arguments)
{
    [[level.callbackScriptCommand]](command, arguments);
}

In the same file, in function SetDefaultCallbacks add:

level.callbackScriptCommand = maps\mp\gametypes\_globallogic::Callback_ScriptCommand;

Add to maps\mp\gametypes\_globallogic::SetupCallbacks

level.onScriptCommand = ::blank;

In the same file, in function Callback_StartGameType add

addScriptCommand("scriptfunctiontest", 1);
addScriptCommand("anotherfunction", 1);

Add to maps\mp\gametypes\_globallogic this function

Callback_ScriptCommand(command, arguments)
{
    waittillframeend;

    if( isDefined( self.name ) )
        print("Executed by: " + self.name + " Command:" + command + " Args: " + arguments + "\n");
    else
        print("Executed by: Rcon Command:" + command + " Args: " + arguments + "\n");
}