1.1 --- a/core/smn_halflife.cpp Mon Jul 30 20:26:18 2007 +0000
1.2 +++ b/core/smn_halflife.cpp Mon Jul 30 23:16:58 2007 +0000
1.3 @@ -326,6 +326,78 @@
1.4 return 1;
1.5 }
1.6
1.7 +static cell_t PrintHintText(IPluginContext *pContext, const cell_t *params)
1.8 +{
1.9 + int client = params[1];
1.10 + CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
1.11 +
1.12 + if (!pPlayer)
1.13 + {
1.14 + return pContext->ThrowNativeError("Client index %d is invalid", client);
1.15 + }
1.16 +
1.17 + if (!pPlayer->IsInGame())
1.18 + {
1.19 + return pContext->ThrowNativeError("Client %d is not in game", client);
1.20 + }
1.21 +
1.22 + g_SourceMod.SetGlobalTarget(client);
1.23 +
1.24 + char buffer[192];
1.25 + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
1.26 +
1.27 + /* Check for an error before printing to the client */
1.28 + if (pContext->GetContext()->n_err != SP_ERROR_NONE)
1.29 + {
1.30 + return 0;
1.31 + }
1.32 +
1.33 + if (!g_HL2.HinTextMsg(client, buffer))
1.34 + {
1.35 + return pContext->ThrowNativeError("Could not send a usermessage");
1.36 + }
1.37 +
1.38 + return 1;
1.39 +}
1.40 +
1.41 +static cell_t ShowVGUIPanel(IPluginContext *pContext, const cell_t *params)
1.42 +{
1.43 + HandleError herr;
1.44 + char *name;
1.45 + KeyValues *pKV = NULL;
1.46 + int client = params[1];
1.47 + Handle_t hndl = static_cast<Handle_t>(params[3]);
1.48 + CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
1.49 +
1.50 + if (!pPlayer)
1.51 + {
1.52 + return pContext->ThrowNativeError("Client index %d is invalid", client);
1.53 + }
1.54 +
1.55 + if (!pPlayer->IsInGame())
1.56 + {
1.57 + return pContext->ThrowNativeError("Client %d is not in game", client);
1.58 + }
1.59 +
1.60 + if (hndl != BAD_HANDLE)
1.61 + {
1.62 + pKV = g_SourceMod.ReadKeyValuesHandle(hndl, &herr, true);
1.63 + if (herr != HandleError_None)
1.64 + {
1.65 + return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
1.66 + }
1.67 + }
1.68 +
1.69 + pContext->LocalToString(params[2], &name);
1.70 +
1.71 + if (!g_HL2.ShowVGUIMenu(client, name, pKV, (params[4]) ? true : false))
1.72 + {
1.73 + return pContext->ThrowNativeError("Could not send a usermessage");
1.74 + }
1.75 +
1.76 + return 1;
1.77 +}
1.78 +
1.79 static HalfLifeNatives s_HalfLifeNatives;
1.80
1.81 REGISTER_NATIVES(halflifeNatives)
1.82 @@ -354,5 +426,7 @@
1.83 {"CreateDialog", smn_CreateDialog},
1.84 {"PrintToChat", PrintToChat},
1.85 {"PrintCenterText", PrintCenterText},
1.86 + {"PrintHintText", PrintHintText},
1.87 + {"ShowVGUIPanel", ShowVGUIPanel},
1.88 {NULL, NULL},
1.89 };