Add error messages and fix documentation
This commit is contained in:
@ -251,9 +251,9 @@ void CtrlDetours_ClientCommand(bool set)
|
||||
#endif
|
||||
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
|
||||
@ -337,9 +337,24 @@ void CtrlDetours_BuyCommands(bool set)
|
||||
GiveNamedItemDetour = DETOUR_CREATE_MEMBER_FIXED(GiveNamedItem, giveNamedItemAddress);
|
||||
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
|
||||
|
@ -1714,17 +1714,20 @@ extern UTIL_FindEntityByStringFunc CS_UTIL_FindEntityByString;
|
||||
// cs_create_entity(const classname[])
|
||||
static cell AMX_NATIVE_CALL cs_create_entity(AMX* amx, cell* params)
|
||||
{
|
||||
if (CS_CreateNamedEntity > 0)
|
||||
if (CS_CreateNamedEntity <= 0)
|
||||
{
|
||||
int len;
|
||||
int iszClass = ALLOC_STRING(MF_GetAmxString(amx, params[1], 0, &len));
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Native cs_create_entity() is disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = CS_CreateNamedEntity(iszClass);
|
||||
int len;
|
||||
int iszClass = ALLOC_STRING(MF_GetAmxString(amx, params[1], 0, &len));
|
||||
|
||||
if (!FNullEnt(pEnt))
|
||||
{
|
||||
return ENTINDEX(pEnt);
|
||||
}
|
||||
edict_t *pEnt = CS_CreateNamedEntity(iszClass);
|
||||
|
||||
if (!FNullEnt(pEnt))
|
||||
{
|
||||
return ENTINDEX(pEnt);
|
||||
}
|
||||
|
||||
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[])
|
||||
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;
|
||||
void* pEntity = G_HL_TypeConversion.id_to_cbase(params[1]);
|
||||
const char* value = MF_GetAmxString(amx, params[2], 0, &len);
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Native cs_find_ent_by_class() is disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
int index = G_HL_TypeConversion.cbase_to_id(CS_UTIL_FindEntityByString(pEntity, "classname", value));
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1836,7 +1842,7 @@ AMX_NATIVE_INFO CstrikeNatives[] = {
|
||||
{"cs_get_c4_defusing", cs_get_c4_defusing},
|
||||
{"cs_set_c4_defusing", cs_set_c4_defusing},
|
||||
{"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}
|
||||
};
|
||||
|
@ -48,9 +48,19 @@ void OnAmxxAttach()
|
||||
|
||||
// cs_create_entity()
|
||||
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_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.
|
||||
G_OffsetHandler = new OffsetHandler;
|
||||
|
Reference in New Issue
Block a user