20.07.2015, 17:24
Доброго времени суток. Недавно столкнулся с такой проблемой, что при нажатии на текстдрав, в консоль вылетает ошибка.
Пошарив на просторах интернета, я выяснил, что данная ошибка вылетает тогда, когда отсутствует main(){}, однако у меня в моде данная функция присутствует.
Вот кэлбек:
Ошибка вылетет когда код работает в данном месте:
PHP код:
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
Вот кэлбек:
PHP код:
hook OnPlayerClickTextDraw(playerid, Text: clickedid)
{
printf("start clicl");
for(new i; i < sizeof textdraw_gamemode_inventory_box; i++)
{
if(clickedid != textdraw_gamemode_inventory_box[i]) continue;
if(PlayerInfo[playerid][p_bag] == false && i > 9) return SendClientMessage(playerid, -1, "* У вас отсутствует сумка.");
switch(GetPVarInt(playerid, "player_item_click"))
{
case -1:
{
if(PlayerInfo[playerid][p_item][i] == -1) return 1;
if(i_info[PlayerInfo[playerid][p_item][i]][i_type] == INV_TYPE_WEAPON && i > 9){
if(IsPlayerAttachedObjectSlotUsed(playerid, GetSlotAttachedWeapon(GetWeaponIndex(i_info[PlayerInfo[playerid][p_item][GetPVarInt(playerid,"player_item_click")]][i_model])))){
RemovePlayerAttachedObject(playerid, GetSlotAttachedWeapon(GetWeaponIndex(i_info[PlayerInfo[playerid][p_item][GetPVarInt(playerid,"player_item_click")]][i_model])));
}
}
SetPVarInt(playerid, "player_item_click", i);
player_textdraw_update_inv(playerid, i);
}
default:
{
if(GetPVarInt(playerid, "player_item_click") == i)
{
SetPVarInt(playerid,"player_item_click", -1);
player_textdraw_update_inv(playerid, i);
return 1;
}
else
{
if(i > 9 && i_info[PlayerInfo[playerid][p_item][GetPVarInt(playerid, "player_item_click")]][i_type] == INV_TYPE_BAG) return SendClientMessage(playerid, -1, "Нельзя положить одну сумку в другую.");
switch(PlayerInfo[playerid][p_item][i])
{
case -1:
{
PlayerInfo[playerid][p_item][i] = PlayerInfo[playerid][p_item][GetPVarInt(playerid, "player_item_click")];
PlayerInfo[playerid][p_amount][i] = PlayerInfo[playerid][p_amount][GetPVarInt(playerid, "player_item_click")];
PlayerInfo[playerid][p_item][GetPVarInt(playerid, "player_item_click")] = -1;
PlayerInfo[playerid][p_amount][GetPVarInt(playerid, "player_item_click")] = 0;
player_textdraw_update_inv(playerid, i);
player_textdraw_update_inv(playerid, GetPVarInt(playerid, "player_item_click"));
SetPVarInt(playerid, "player_item_click", -1);
}
default:
{
if(PlayerInfo[playerid][p_item][i] == PlayerInfo[playerid][p_item][GetPVarInt(playerid, "player_item_click")])
{
if(i_info[PlayerInfo[playerid][p_item][i]][i_type] == INV_TYPE_SKIN) return SendClientMessage(playerid, -1, "Нельзя совмещать одежду.");
PlayerInfo[playerid][p_amount][i] += PlayerInfo[playerid][p_amount][GetPVarInt(playerid, "player_item_click")];
PlayerInfo[playerid][p_item][GetPVarInt(playerid, "player_item_click")] = -1;
}
else
{
new last_item,
last_amount;
last_item = PlayerInfo[playerid][p_item][GetPVarInt(playerid, "player_item_click")];
last_amount = PlayerInfo[playerid][p_amount][GetPVarInt(playerid, "player_item_click")];
PlayerInfo[playerid][p_item][GetPVarInt(playerid, "player_item_click")] = PlayerInfo[playerid][p_item][i];
PlayerInfo[playerid][p_amount][GetPVarInt(playerid, "player_item_click")] = PlayerInfo[playerid][p_amount][i];
PlayerInfo[playerid][p_item][i] = last_item;
PlayerInfo[playerid][p_amount][i] = last_amount;
}
SetPVarInt(playerid,"player_last_item_click",GetPVarInt(playerid,"player_item_click"));
SetPVarInt(playerid, "player_item_click", -1);
player_textdraw_update_inv(playerid, i);
player_textdraw_update_inv(playerid, GetPVarInt(playerid, "player_last_item_click"));
}
}
}
}
}
SetPVarInt(playerid,"click_inventory",1);
}
if(GetPVarInt(playerid,"click_inventory") == 1)
{
if(clickedid == textdraw_gamemode_inventory[3])
{
if(GetPVarInt(playerid,"player_item_click") == -1) return SendClientMessage(playerid, -1, "Вы не выбрали предмет");
UseItemInventory(playerid, i_info[PlayerInfo[playerid][p_item][GetPVarInt(playerid,"player_item_click")]][i_type]);
}
else if(clickedid == textdraw_gamemode_inventory[4])
{
if(GetPVarInt(playerid,"player_item_click") == -1) return SendClientMessage(playerid, -1, "Вы не выбрали предмет");
format(a_string, sizeof a_string, "\t\t\tПредмет\nНазвание: %s\nОписание: %s\nКолличество: %d",
i_info[PlayerInfo[playerid][p_item][GetPVarInt(playerid,"player_item_click")]][i_name],
i_info[PlayerInfo[playerid][p_item][GetPVarInt(playerid,"player_item_click")]][i_assignment],
PlayerInfo[playerid][p_amount][GetPVarInt(playerid,"player_item_click")]);
Dialog_ShowCallback(playerid, using callback InventoryShowInfo, DIALOG_STYLE_MSGBOX, "Инвентарь", a_string, "Далее","");
}
else if(clickedid == textdraw_gamemode_inventory[5])
{
if(GetPVarInt(playerid,"player_item_click") == -1) return SendClientMessage(playerid, -1, "Вы не выбрали предмет");
Dialog_ShowCallback(playerid, using callback InventoryInputGivePlayerid, DIALOG_STYLE_INPUT, "Инвентарь", "Введите ID игрока, которому хотите передать предмет.", "Далее","Отмена");
}
else if(clickedid == textdraw_gamemode_inventory[6])
{
if(GetPVarInt(playerid,"player_item_click") == -1) return SendClientMessage(playerid, -1, "Вы не выбрали предмет");
if(i_info[PlayerInfo[playerid][p_item][GetPVarInt(playerid,"player_item_click")]][i_type] == INV_TYPE_WEAPON && PlayerInfo[playerid][p_faction_duty] == 1) return SendClientMessage(playerid, -1, "* Нельзя выбросить оружие, будучи на дежурстве!");
Dialog_ShowCallback(playerid, using callback InventoryInputDropItem, DIALOG_STYLE_INPUT, "Инвентарь", "Введите колличество предмета.", "Далее","Отмена");
}
else if(clickedid == textdraw_gamemode_inventory[7])
{
if(GetPVarInt(playerid,"player_item_click") == -1) return SendClientMessage(playerid, -1, "Вы не выбрали предмет");
if(PlayerInfo[playerid][p_bag] == false) return SendClientMessage(playerid, -1, "У вас отсутствуют сумки.");
SetDropBag(playerid);
}
}
printf("end click");
return true;
}
PHP код:
case -1:
{
if(PlayerInfo[playerid][p_item][i] == -1) return 1;
if(i_info[PlayerInfo[playerid][p_item][i]][i_type] == INV_TYPE_WEAPON && i > 9){
if(IsPlayerAttachedObjectSlotUsed(playerid, GetSlotAttachedWeapon(GetWeaponIndex(i_info[PlayerInfo[playerid][p_item][GetPVarInt(playerid,"player_item_click")]][i_model])))){
RemovePlayerAttachedObject(playerid, GetSlotAttachedWeapon(GetWeaponIndex(i_info[PlayerInfo[playerid][p_item][GetPVarInt(playerid,"player_item_click")]][i_model])));
}
}
SetPVarInt(playerid, "player_item_click", i);
player_textdraw_update_inv(playerid, i);
}