mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Add error messages and fix documentation
This commit is contained in:
parent
e0426f10b2
commit
4ceb767022
@ -251,9 +251,9 @@ void CtrlDetours_ClientCommand(bool set)
|
|||||||
#endif
|
#endif
|
||||||
ClientCommandDetour = DETOUR_CREATE_STATIC_FIXED(C_ClientCommand, target);
|
ClientCommandDetour = DETOUR_CREATE_STATIC_FIXED(C_ClientCommand, target);
|
||||||
|
|
||||||
if (ClientCommandDetour == NULL)
|
if (!ClientCommandDetour)
|
||||||
{
|
{
|
||||||
MF_Log("No Client Commands detour could be initialized - Disabled Client Command forward.");
|
MF_Log("ClientCommand is not available - forward client_command has been disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -337,9 +337,24 @@ void CtrlDetours_BuyCommands(bool set)
|
|||||||
GiveNamedItemDetour = DETOUR_CREATE_MEMBER_FIXED(GiveNamedItem, giveNamedItemAddress);
|
GiveNamedItemDetour = DETOUR_CREATE_MEMBER_FIXED(GiveNamedItem, giveNamedItemAddress);
|
||||||
AddAccountDetour = DETOUR_CREATE_MEMBER_FIXED(AddAccount, addAccountAddress);
|
AddAccountDetour = DETOUR_CREATE_MEMBER_FIXED(AddAccount, addAccountAddress);
|
||||||
|
|
||||||
if (GiveNamedItemDetour == NULL || AddAccountDetour == NULL)
|
if (!GiveShieldDetour || !GiveNamedItemDetour || !AddAccountDetour)
|
||||||
{
|
{
|
||||||
MF_Log("No Buy Commands detours could be initialized - Disabled Buy forward.");
|
if (!GiveNamedItemDetour)
|
||||||
|
{
|
||||||
|
MF_Log("GiveShield is not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GiveNamedItemDetour)
|
||||||
|
{
|
||||||
|
MF_Log("GiveNamedItem is not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!AddAccountDetour)
|
||||||
|
{
|
||||||
|
MF_Log("AddAccount is not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
MF_Log("Some functions are not available - forward CS_OnBuyAttempt and CS_OnBuy have been disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1714,17 +1714,20 @@ extern UTIL_FindEntityByStringFunc CS_UTIL_FindEntityByString;
|
|||||||
// cs_create_entity(const classname[])
|
// cs_create_entity(const classname[])
|
||||||
static cell AMX_NATIVE_CALL cs_create_entity(AMX* amx, cell* params)
|
static cell AMX_NATIVE_CALL cs_create_entity(AMX* amx, cell* params)
|
||||||
{
|
{
|
||||||
if (CS_CreateNamedEntity > 0)
|
if (CS_CreateNamedEntity <= 0)
|
||||||
{
|
{
|
||||||
int len;
|
MF_LogError(amx, AMX_ERR_NATIVE, "Native cs_create_entity() is disabled");
|
||||||
int iszClass = ALLOC_STRING(MF_GetAmxString(amx, params[1], 0, &len));
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
edict_t *pEnt = CS_CreateNamedEntity(iszClass);
|
int len;
|
||||||
|
int iszClass = ALLOC_STRING(MF_GetAmxString(amx, params[1], 0, &len));
|
||||||
|
|
||||||
if (!FNullEnt(pEnt))
|
edict_t *pEnt = CS_CreateNamedEntity(iszClass);
|
||||||
{
|
|
||||||
return ENTINDEX(pEnt);
|
if (!FNullEnt(pEnt))
|
||||||
}
|
{
|
||||||
|
return ENTINDEX(pEnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1733,18 +1736,21 @@ static cell AMX_NATIVE_CALL cs_create_entity(AMX* amx, cell* params)
|
|||||||
// cs_find_ent_by_class(start_index, const classname[])
|
// cs_find_ent_by_class(start_index, const classname[])
|
||||||
static cell AMX_NATIVE_CALL cs_find_ent_by_class(AMX* amx, cell* params)
|
static cell AMX_NATIVE_CALL cs_find_ent_by_class(AMX* amx, cell* params)
|
||||||
{
|
{
|
||||||
if (CS_UTIL_FindEntityByString > 0)
|
if (CS_UTIL_FindEntityByString <= 0)
|
||||||
{
|
{
|
||||||
int len;
|
MF_LogError(amx, AMX_ERR_NATIVE, "Native cs_find_ent_by_class() is disabled");
|
||||||
void* pEntity = G_HL_TypeConversion.id_to_cbase(params[1]);
|
return 0;
|
||||||
const char* value = MF_GetAmxString(amx, params[2], 0, &len);
|
}
|
||||||
|
|
||||||
int index = G_HL_TypeConversion.cbase_to_id(CS_UTIL_FindEntityByString(pEntity, "classname", value));
|
int len;
|
||||||
|
void* pEntity = G_HL_TypeConversion.id_to_cbase(params[1]);
|
||||||
|
const char* value = MF_GetAmxString(amx, params[2], 0, &len);
|
||||||
|
|
||||||
if (index != -1)
|
int index = G_HL_TypeConversion.cbase_to_id(CS_UTIL_FindEntityByString(pEntity, "classname", value));
|
||||||
{
|
|
||||||
return index;
|
if (index != -1)
|
||||||
}
|
{
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1836,7 +1842,7 @@ AMX_NATIVE_INFO CstrikeNatives[] = {
|
|||||||
{"cs_get_c4_defusing", cs_get_c4_defusing},
|
{"cs_get_c4_defusing", cs_get_c4_defusing},
|
||||||
{"cs_set_c4_defusing", cs_set_c4_defusing},
|
{"cs_set_c4_defusing", cs_set_c4_defusing},
|
||||||
{"cs_create_entity", cs_create_entity },
|
{"cs_create_entity", cs_create_entity },
|
||||||
{"cs_find_ent_by_class", cs_find_ent_by_class },
|
{"cs_find_ent_by_class", cs_find_ent_by_class},
|
||||||
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -48,9 +48,19 @@ void OnAmxxAttach()
|
|||||||
|
|
||||||
// cs_create_entity()
|
// cs_create_entity()
|
||||||
CS_CreateNamedEntity = reinterpret_cast<CreateNamedEntityFunc>(UTIL_FindAddressFromEntry(CS_IDENT_CREATENAMEDENTITY, CS_IDENT_HIDDEN_STATE));
|
CS_CreateNamedEntity = reinterpret_cast<CreateNamedEntityFunc>(UTIL_FindAddressFromEntry(CS_IDENT_CREATENAMEDENTITY, CS_IDENT_HIDDEN_STATE));
|
||||||
|
|
||||||
|
if (CS_CreateNamedEntity <= 0)
|
||||||
|
{
|
||||||
|
MF_Log("CREATE_NAMED_ENITTY is not available - native cs_create_entity() has been disabled");
|
||||||
|
}
|
||||||
|
|
||||||
// cs_find_ent_by_class()
|
// cs_find_ent_by_class()
|
||||||
CS_UTIL_FindEntityByString = reinterpret_cast<UTIL_FindEntityByStringFunc>(UTIL_FindAddressFromEntry(CS_IDENT_UTIL_FINDENTITYBYSTRING, CS_IDENT_HIDDEN_STATE));
|
CS_UTIL_FindEntityByString = reinterpret_cast<UTIL_FindEntityByStringFunc>(UTIL_FindAddressFromEntry(CS_IDENT_UTIL_FINDENTITYBYSTRING, CS_IDENT_HIDDEN_STATE));
|
||||||
|
|
||||||
|
if (CS_UTIL_FindEntityByString <= 0)
|
||||||
|
{
|
||||||
|
MF_Log("UTIL_FindEntByString is not available - native cs_find_ent_by_class() has been disabled");
|
||||||
|
}
|
||||||
|
|
||||||
// Search pev offset automatically.
|
// Search pev offset automatically.
|
||||||
G_OffsetHandler = new OffsetHandler;
|
G_OffsetHandler = new OffsetHandler;
|
||||||
|
@ -354,17 +354,18 @@ native cs_set_c4_defusing(c4index, bool:defusing);
|
|||||||
* Creates an entity using Counter-Strike's custom CreateNamedEntity wrapper.
|
* Creates an entity using Counter-Strike's custom CreateNamedEntity wrapper.
|
||||||
*
|
*
|
||||||
* @note Unlike other mods CS keeps track of entities using a custom hashtable.
|
* @note Unlike other mods CS keeps track of entities using a custom hashtable.
|
||||||
* This function will add entities to this hashtable, providing benefits
|
* This function adds entities to this hashtable, providing benefits over
|
||||||
* over the default engine functions (used by create_entity() for example):
|
* the default CreateNamedEntity (used by create_entity() for example):
|
||||||
* - Storing entities in a hashtable allows CS to improve classname lookup
|
* - Storing entities in a hashtable allows CS to improve classname lookup
|
||||||
* performance compared to functions like FindEntityByString that usually
|
* performance compared to functions like FindEntityByString (used by
|
||||||
* have to loop incrementally through all entities.
|
* find_ent_by_class() for example) that usually have to loop
|
||||||
|
* through all entities incrementally.
|
||||||
* - As CS exclusively uses the hashtable for classname lookup, entities
|
* - As CS exclusively uses the hashtable for classname lookup, entities
|
||||||
* created using the default engine functions will not be found by the
|
* created using the default engine functions will not be found by the
|
||||||
* game. For example "weaponbox" entities are supposed to be
|
* game. For example "weaponbox" entities are supposed to be
|
||||||
* automatically cleaned up on round restart but are not considered if
|
* automatically cleaned up on round restart but are not considered if
|
||||||
* they have not been added to the hashtable.
|
* they have not been added to the hashtable.
|
||||||
* @note CS's faster hashtable lookup can be utilized with cs_find_ent_by_class()
|
* @note The faster hashtable lookup can be utilized with cs_find_ent_by_class()
|
||||||
*
|
*
|
||||||
* @param classname Entity class name
|
* @param classname Entity class name
|
||||||
*
|
*
|
||||||
@ -372,14 +373,14 @@ native cs_set_c4_defusing(c4index, bool:defusing);
|
|||||||
*/
|
*/
|
||||||
native cs_create_entity(const classname[]);
|
native cs_create_entity(const classname[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds an entity in the world using Counter-Strike's custom FindEntityByString
|
* Finds an entity in the world using Counter-Strike's custom FindEntityByString
|
||||||
* wrapper.
|
* wrapper.
|
||||||
*
|
*
|
||||||
* @note Unlike other mods CS keeps track of entities using a custom hashtable.
|
* @note Unlike other mods CS keeps track of entities using a custom hashtable.
|
||||||
* This function utilizes the custom hasthable and allows for considerably
|
* This function utilizes the hasthable and allows for considerably faster
|
||||||
* faster classname lookup compared to the default engine functions (used
|
* classname lookup compared to the default FindEntityByString (used by
|
||||||
* by find_ent_by_class() for example).
|
* find_ent_by_class() for example).
|
||||||
* @note This exclusively considers entities in the hashtable, created by the
|
* @note This exclusively considers entities in the hashtable, created by the
|
||||||
* game itself or using cs_create_entity().
|
* game itself or using cs_create_entity().
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user