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

Function SetStructEnt

extensions/structs/natives.cpp:382–423  ·  view source on GitHub ↗

native SetStructEnt(Handle:struct, const String:member[], ent);

Source from the content-addressed store, hash-verified

380
381//native SetStructEnt(Handle:struct, const String:member[], ent);
382static cell_t SetStructEnt(IPluginContext *pContext, const cell_t *params)
383{
384 Handle_t hndl = static_cast<Handle_t>(params[1]);
385 HandleError err;
386 HandleSecurity sec;
387
388 sec.pOwner = NULL;
389 sec.pIdentity = myself->GetIdentity();
390
391 StructHandle *pHandle;
392 if ((err = g_pHandleSys->ReadHandle(hndl, g_StructHandle, &sec, (void **)&pHandle))
393 != HandleError_None)
394 {
395 return pContext->ThrowNativeError("Invalid struct handle %x (error %d)", hndl, err);
396 }
397
398 char *member;
399 pContext->LocalToString(params[2], &member);
400
401 CBaseHandle *value;
402 if (!pHandle->GetEHandle(member, &value))
403 {
404 return pContext->ThrowNativeError("Invalid member, or incorrect data type");
405 }
406
407 edict_t *pEdict = GetEdict(params[3]);
408
409 if (pEdict == NULL)
410 {
411 return pContext->ThrowNativeError("Invalid entity %i", params[3]);
412 }
413
414 IServerEntity *pEntOther = pEdict->GetIServerEntity();
415 value->Set(pEntOther);
416
417 if (!pHandle->SetEHandle(member, value))
418 {
419 return pContext->ThrowNativeError("Invalid member, or incorrect data type");
420 }
421
422 return 1;
423}
424
425static cell_t GetWeaponStruct(IPluginContext *pContext, const cell_t *params)
426{

Callers

nothing calls this directly

Calls 5

GetEHandleMethod · 0.80
SetEHandleMethod · 0.80
GetEdictFunction · 0.70
GetIdentityMethod · 0.45
ReadHandleMethod · 0.45

Tested by

no test coverage detected