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

Function smn_ReadPackString

core/logic/smn_datapacks.cpp:322–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322static cell_t smn_ReadPackString(IPluginContext *pContext, const cell_t *params)
323{
324 Handle_t hndl = static_cast<Handle_t>(params[1]);
325 HandleError herr;
326 HandleSecurity sec;
327 CDataPack *pDataPack;
328
329 sec.pOwner = pContext->GetIdentity();
330 sec.pIdentity = g_pCoreIdent;
331
332 if ((herr=handlesys->ReadHandle(hndl, g_DataPackType, &sec, (void **)&pDataPack))
333 != HandleError_None)
334 {
335 return pContext->ThrowNativeError("Invalid data pack handle %x (error %d).", hndl, herr);
336 }
337
338 if (!pDataPack->IsReadable())
339 {
340 return pContext->ThrowNativeError("Data pack operation is out of bounds.");
341 }
342
343 if (pDataPack->GetCurrentType() != CDataPackType::String)
344 {
345 return pContext->ThrowNativeError("Invalid data pack type (got %d / expected %d).", pDataPack->GetCurrentType(), CDataPackType::String);
346 }
347
348 const char *str = pDataPack->ReadString(NULL);
349 pContext->StringToLocal(params[2], params[3], str);
350
351 return 1;
352}
353
354static cell_t smn_ReadPackFunction(IPluginContext *pContext, const cell_t *params)
355{

Callers

nothing calls this directly

Calls 5

IsReadableMethod · 0.80
GetCurrentTypeMethod · 0.80
ReadStringMethod · 0.80
GetIdentityMethod · 0.45
ReadHandleMethod · 0.45

Tested by

no test coverage detected