| 685 | static bool s_QueryAlreadyWarned = false; |
| 686 | |
| 687 | static 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 | |
| 733 | static cell_t sm_RegServerCmd(IPluginContext *pContext, const cell_t *params) |
| 734 | { |
nothing calls this directly
no test coverage detected