MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / sm_QueryClientConVar

Function sm_QueryClientConVar

core/smn_console.cpp:687–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

685static bool s_QueryAlreadyWarned = false;
686
687static cell_t sm_QueryClientConVar(IPluginContext *pContext, const cell_t *params)
688{
689 CPlayer *pPlayer;
690 char *name;
691 IPluginFunction *pCallback;
692
693 if (!g_ConVarManager.IsQueryingSupported())
694 {
695 if (!s_QueryAlreadyWarned)
696 {
697 s_QueryAlreadyWarned = true;
698 return pContext->ThrowNativeError("Game does not support client convar querying (one time warning)");
699 }
700
701 return 0;
702 }
703
704 pPlayer = g_Players.GetPlayerByIndex(params[1]);
705
706 if (!pPlayer)
707 {
708 return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
709 }
710
711 if (!pPlayer->IsConnected())
712 {
713 return pContext->ThrowNativeError("Client %d is not connected", params[1]);
714 }
715
716 /* Trying a query on a bot results in callback not be fired, so don't bother */
717 if (pPlayer->IsFakeClient())
718 {
719 return 0;
720 }
721
722 pContext->LocalToString(params[2], &name);
723 pCallback = pContext->GetFunctionById(params[3]);
724
725 if (!pCallback)
726 {
727 return pContext->ThrowNativeError("Invalid function id (%X)", params[3]);
728 }
729
730 return g_ConVarManager.QueryClientConVar(pPlayer->GetEdict(), name, pCallback, params[4]);
731}
732
733static cell_t sm_RegServerCmd(IPluginContext *pContext, const cell_t *params)
734{

Callers

nothing calls this directly

Calls 6

IsQueryingSupportedMethod · 0.80
GetPlayerByIndexMethod · 0.80
IsConnectedMethod · 0.80
IsFakeClientMethod · 0.80
GetEdictMethod · 0.80
QueryClientConVarMethod · 0.45

Tested by

no test coverage detected