static cell_t ReadPlugin(IPluginContext *pContext, const cell_t *params) { Handle_t hndl = (Handle_t)params[1]; HandleError err; IPluginIterator *pIter; HandleSecurity sec; sec.pIdentity = g_pCoreIdent; sec.pOwner = pContext->GetIdentity(); if ((err=handlesys->ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None) { return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); } IPlugin *pPlugin = pIter->GetPlugin(); if (!pPlugin) { return BAD_HANDLE; } pIter->NextPlugin(); return pPlugin->GetMyHandle(); }
static cell_t FindPluginByNumber(IPluginContext *pContext, const cell_t *params) { IPlugin *pPlugin = scripts->FindPluginByOrder(params[1]); if (pPlugin == NULL) { return BAD_HANDLE; } return pPlugin->GetMyHandle(); }
static cell_t sm_LogAction(IPluginContext *pContext, const cell_t *params) { char buffer[2048]; g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); { DetectExceptions eh(pContext); g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3); if (eh.HasException()) return 0; } IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); LogAction(pPlugin->GetMyHandle(), 2, params[1], params[2], buffer); return 1; }
static cell_t sm_AddFrameAction(IPluginContext *pContext, const cell_t *params) { IPlugin *pPlugin = pluginsys->FindPluginByContext(pContext->GetContext()); IPluginFunction *pFunction = pPlugin->GetBaseContext()->GetFunctionById(params[1]); if (!pFunction) { return pContext->ThrowNativeError("Invalid function id (%X)", params[1]); } IChangeableForward *pForward = forwardsys->CreateForwardEx(NULL, ET_Ignore, 1, NULL, Param_Cell); IdentityToken_t *pIdentity = pContext->GetIdentity(); Handle_t Handle = handlesys->CreateHandle(g_PrivateFwdType, pForward, pIdentity, g_pCoreIdent, NULL); if (Handle == BAD_HANDLE) { forwardsys->ReleaseForward(pForward); return 0; } pForward->AddFunction(pFunction); SMFrameActionData *pData = new SMFrameActionData(Handle, pPlugin->GetMyHandle(), params[2]); g_pSM->AddFrameAction(PawnFrameAction, pData); return 1; }