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

Function GetStructFloat

extensions/structs/natives.cpp:159–186  ·  view source on GitHub ↗

native GetStructFloat(Handle:struct, const String:member[], &Float:value);

Source from the content-addressed store, hash-verified

157
158//native GetStructFloat(Handle:struct, const String:member[], &Float:value);
159static cell_t GetStructFloat(IPluginContext *pContext, const cell_t *params)
160{
161 Handle_t hndl = static_cast<Handle_t>(params[1]);
162 HandleError err;
163 HandleSecurity sec;
164
165 sec.pOwner = NULL;
166 sec.pIdentity = myself->GetIdentity();
167
168 StructHandle *pHandle;
169 if ((err = g_pHandleSys->ReadHandle(hndl, g_StructHandle, &sec, (void **)&pHandle))
170 != HandleError_None)
171 {
172 return pContext->ThrowNativeError("Invalid struct handle %x (error %d)", hndl, err);
173 }
174
175 char *member;
176 pContext->LocalToString(params[2], &member);
177
178 float value;
179
180 if (!pHandle->GetFloat(member, &value))
181 {
182 return pContext->ThrowNativeError("Invalid member, or incorrect data type");
183 }
184
185 return sp_ftoc(value);
186}
187
188//native SetStructFloat(Handle:struct, const String:member[], Float:value);
189static cell_t SetStructFloat(IPluginContext *pContext, const cell_t *params)

Callers

nothing calls this directly

Calls 3

GetIdentityMethod · 0.45
ReadHandleMethod · 0.45
GetFloatMethod · 0.45

Tested by

no test coverage detected