-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# QueryCvar in AngelScript (aka asqcvar) | ||
|
||
* Exposes "server.NewDllFunction.pfnCvarValue" and "server.NewDllFunction.pfnCvarValue2" to AngelScript engine | ||
|
||
* Being able to read response of network message "svc_sendcvarvalue" and "svc_sendcvarvalue2" from client. | ||
|
||
## Send a cvar query requset to client | ||
|
||
``` | ||
//NetworkMessages::NetworkMessageType(58) means "svc_sendcvarvalue2" | ||
NetworkMessage m( MSG_ONE, NetworkMessages::NetworkMessageType(58), pPlayer.edict() ); | ||
m.WriteLong(114514);//RequestId | ||
m.WriteString("default_fov"); | ||
m.End(); | ||
``` | ||
|
||
## Register an asynchronous callback for cvar query response | ||
|
||
``` | ||
g_EngineFuncs.SetQueryCvar2Callback(1, function(CBasePlayer@ pPlayer, int requestId, string cvarName, string value){ | ||
g_Game.AlertMessage(at_aiconsole, "%1's %2 is %3\n", pPlayer.pev.netname, cvarName, value ); | ||
}); | ||
``` | ||
|
||
## Register global hooks | ||
|
||
``` | ||
HookReturnCode PlayerQueryCvar(CBasePlayer @pPlayer, const string &in value) | ||
{ | ||
g_Game.AlertMessage(at_aiconsole, "%1's cvar is %2\n", pPlayer.pev.netname, value ); | ||
return HOOK_CONTINUE; | ||
} | ||
HookReturnCode PlayerQueryCvar2(CBasePlayer @pPlayer, int requestId, const string &in cvarName, const string &in value) | ||
{ | ||
g_Game.AlertMessage(at_aiconsole, "%1's %2 is %3\n", pPlayer.pev.netname, cvarName, value ); | ||
return HOOK_CONTINUE; | ||
} | ||
void MapInit() | ||
{ | ||
g_Hooks.RegisterHook(Hooks::Player::QueryCvar, @PlayerQueryCvar); | ||
g_Hooks.RegisterHook(Hooks::Player::QueryCvar2, @PlayerQueryCvar2); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters