added amb852, create entity natives
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401434
This commit is contained in:
parent
7e3b07a594
commit
c6dba359c6
@ -101,9 +101,7 @@ void SDKTools::OnHandleDestroy(HandleType_t type, void *object)
|
||||
{
|
||||
ValveCall *v = (ValveCall *)object;
|
||||
delete v;
|
||||
}
|
||||
if (type == g_TraceHandle)
|
||||
{
|
||||
} else if (type == g_TraceHandle) {
|
||||
trace_t *tr = (trace_t *)object;
|
||||
delete tr;
|
||||
}
|
||||
|
@ -635,7 +635,68 @@ static cell_t IsPlayerAlive(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
return pContext->ThrowNativeError("\"IsPlayerAlive\" not supported by this mod");
|
||||
}
|
||||
return (*((uint8_t *)pEntity + lifeState_off) == LIFE_ALIVE) ? 1: 0;
|
||||
return (*((uint8_t *)pEntity + lifeState_off) == LIFE_ALIVE) ? 1 : 0;
|
||||
}
|
||||
|
||||
static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
static ValveCall *pCall = NULL;
|
||||
if (!pCall)
|
||||
{
|
||||
ValvePassInfo pass[3];
|
||||
InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
|
||||
InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
|
||||
InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
|
||||
if (!CreateBaseCall("CreateEntityByName", ValveCall_Static, &pass[2], pass, 2, &pCall))
|
||||
{
|
||||
return pContext->ThrowNativeError("\"CreateEntityByName\" not supported by this mod");
|
||||
} else if (!pCall) {
|
||||
return pContext->ThrowNativeError("\"CreateEntityByName\" wrapper failed to initialized");
|
||||
}
|
||||
}
|
||||
|
||||
CBaseEntity *pEntity = NULL;
|
||||
START_CALL();
|
||||
DECODE_VALVE_PARAM(1, vparams, 0);
|
||||
DECODE_VALVE_PARAM(2, vparams, 1);
|
||||
FINISH_CALL_SIMPLE(&pEntity);
|
||||
|
||||
if (pEntity == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
edict_t *pEdict = gameents->BaseEntityToEdict(pEntity);
|
||||
if (!pEdict)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return engine->IndexOfEdict(pEdict);
|
||||
}
|
||||
|
||||
static cell_t DispatchSpawn(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
static ValveCall *pCall = NULL;
|
||||
if (!pCall)
|
||||
{
|
||||
ValvePassInfo pass[2];
|
||||
InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
|
||||
InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
|
||||
if (!CreateBaseCall("DispatchSpawn", ValveCall_Static, &pass[1], pass, 1, &pCall))
|
||||
{
|
||||
return pContext->ThrowNativeError("\"DispatchSpawn\" not supported by this mod");
|
||||
} else if (!pCall) {
|
||||
return pContext->ThrowNativeError("\"DispatchSpawn\" wrapper failed to initialized");
|
||||
}
|
||||
}
|
||||
|
||||
int ret;
|
||||
START_CALL();
|
||||
DECODE_VALVE_PARAM(1, vparams, 0);
|
||||
FINISH_CALL_SIMPLE(&ret);
|
||||
|
||||
return (ret == -1) ? 0 : 1;
|
||||
}
|
||||
|
||||
sp_nativeinfo_t g_Natives[] =
|
||||
@ -657,5 +718,7 @@ sp_nativeinfo_t g_Natives[] =
|
||||
{"GetClientEyeAngles", GetClientEyeAngles},
|
||||
{"FindEntityByClassname", FindEntityByClassname},
|
||||
{"IsPlayerAlive", IsPlayerAlive},
|
||||
{"CreateEntityByName", CreateEntityByName},
|
||||
{"DispatchSpawn", DispatchSpawn},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
@ -172,6 +172,75 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Create Entity Signatures */
|
||||
"#default"
|
||||
{
|
||||
"#supported"
|
||||
{
|
||||
"game" "cstrike"
|
||||
"game" "dod"
|
||||
"game" "hl2mp"
|
||||
"game" "!Insurgency"
|
||||
"game" "!Pirates, Vikings and Knights II"
|
||||
}
|
||||
|
||||
"Signatures"
|
||||
{
|
||||
"DispatchSpawn"
|
||||
{
|
||||
"library" "server"
|
||||
"linux" "@_Z13DispatchSpawnP11CBaseEntity"
|
||||
"windows" "\x53\x55\x56\x8B\x74\x24\x10\x85\xF6\x57\x0F\x84\x2A\x2A\x2A\x2A\x8B\x1D\x2A\x2A\x2A\x2A\x8B\x03\x8B\xCB\xFF\x50\x60"
|
||||
}
|
||||
"CreateEntityByName"
|
||||
{
|
||||
"library" "server"
|
||||
"linux" "@_Z18CreateEntityByNamePKci"
|
||||
"windows" "\x56\x8B\x74\x24\x0C\x83\xFE\xFF\x57\x8B\x7C\x24\x0C\x74\x25\x8B\x0D\x2A\x2A\x2A\x2A\x8B\x01\x56\xFF\x50\x54\x85\xC0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create Entity Signatures */
|
||||
"!SourceForts v1.9.2"
|
||||
{
|
||||
"Signatures"
|
||||
{
|
||||
"DispatchSpawn"
|
||||
{
|
||||
"library" "server"
|
||||
"linux" "@_Z13DispatchSpawnP11CBaseEntity"
|
||||
"windows" "\x53\x56\x8B\x74\x24\x0C\x85\xF6\x57\x0F\x84\x2A\x2A\x2A\x2A\x8B\x1D\x2A\x2A\x2A\x2A\x8B\x03\x8B\xCB\xFF\x50\x14\x8B\x16\x8B\xCE"
|
||||
}
|
||||
"CreateEntityByName"
|
||||
{
|
||||
"library" "server"
|
||||
"linux" "@_Z18CreateEntityByNamePKci"
|
||||
"windows" "\x56\x8B\x74\x24\x0C\x83\xFE\xFF\x57\x8B\x7C\x24\x0C\x74\x25\x8B\x0D\x2A\x2A\x2A\x2A\x8B\x01\x56\xFF\x50\x54\x85\xC0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create Entity Signatures */
|
||||
"ship"
|
||||
{
|
||||
"Signatures"
|
||||
{
|
||||
"DispatchSpawn"
|
||||
{
|
||||
"library" "server"
|
||||
"linux" "@_Z13DispatchSpawnP11CBaseEntity"
|
||||
"windows" "\x53\x56\x8B\x74\x24\x0C\x85\xF6\x57\x0F\x84\x2A\x2A\x2A\x2A\x8B\x1D\x2A\x2A\x2A\x2A\x8B\x03\x8B\xCB\xFF\x50\x60\x8B\0x16"
|
||||
}
|
||||
"CreateEntityByName"
|
||||
{
|
||||
"library" "server"
|
||||
"linux" "@_Z18CreateEntityByNamePKci"
|
||||
"windows" "\x56\x8B\x74\x24\x0C\x83\xFE\xFF\x57\x8B\x7C\x24\x0C\x74\x25\x8B\x0D\x2A\x2A\x2A\x2A\x8B\x01\x56\xFF\x50\x54\x85\xC0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Counter-Strike: Source */
|
||||
"cstrike"
|
||||
{
|
||||
|
@ -151,6 +151,27 @@ native GetClientEyeAngles(client, Float:ang[3]);
|
||||
*/
|
||||
native bool:IsPlayerAlive(client);
|
||||
|
||||
/**
|
||||
* Creates an entity by string name, but does not spawn it (see DispatchSpawn).
|
||||
* If ForceEdictIndex is not -1, then it will use the edict by that index. If the index is
|
||||
* invalid or there is already an edict using that index, it will error out.
|
||||
*
|
||||
* @param classname Entity classname.
|
||||
* @param ForceEdictIndex Edict index used by the created entity.
|
||||
* @return Entity index on success, or -1 on failure.
|
||||
* @error Invalid edict index, or no mod support.
|
||||
*/
|
||||
native CreateEntityByName(const String:classname[], ForceEdictIndex=-1);
|
||||
|
||||
/**
|
||||
* Spawns an entity into the game.
|
||||
*
|
||||
* @param entity Entity index of the created entity.
|
||||
* @return True on success, false otherwise.
|
||||
* @error Invalid entity index, or no mod support.
|
||||
*/
|
||||
native bool:DispatchSpawn(entity);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user