PDA

Просмотр полной версии : [Вопрос] Криво работает выбор скина



TheOrsini
31.01.2016, 11:56
new register_skins[2][14] = {
{78, 160, 230, 213, 212, 200, 137, 136, 135, 134, 132, 79},
{10, 218, 198, 197, 186, 157, 151, 130, 127, 77, 54, 39, 31, 13}
};
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
if(clickedid == prev_reg_skin)
{
if(Select[playerid]) Select[playerid] = (PlayerInfo[playerid][pSex] ? 12 : 14);
else Select[playerid]--;
SetPlayerSkin(playerid, register_skins[PlayerInfo[playerid][pSex]-1][Select[playerid]-1]);
}
else if(clickedid == next_reg_skin)
{
if(Select[playerid] == 12 && PlayerInfo[playerid][pSex] == 1) Select[playerid] = 1;
else if(Select[playerid] == 14 && PlayerInfo[playerid][pSex] == 2) Select[playerid] = 1;
else Select[playerid]++;
SetPlayerSkin(playerid, register_skins[PlayerInfo[playerid][pSex]-1][Select[playerid]-1]);
}
return 1;
}


Листает скины не в таком порядке как в массиве (при нажатии на левую стрелку всё время выдаёт 79 скин), не могу понять по какой причине.
При начале выбора скина ставлю Select[playerid] = 1;
pSex - 1 мужской, 2 - женский

VVWVV
31.01.2016, 12:07
static const
register_skins[2][] =
{
{78, 160, 230, 213, 212, 200, 137, 136, 135, 134, 132, 79},
{10, 218, 198, 197, 186, 157, 151, 130, 127, 77, 54, 39, 31, 13}
};

public
OnPlayerClickTextDraw(playerid, Text:clickedid)
{
static select_id[MAX_PLAYERS];
if(clickedid == prev_reg_skin)
{
if (--select_id[playerid] >= 0)
select_id[playerid] = sizeof register_skins[PlayerInfo[playerid][pSex]] - 1;
SetPlayerSkin(playerid, register_skins[select_id[playerid]]);
}
else if(clickedid == next_reg_skin)
{
if (++select_id[playerid] <= sizeof register_skins[PlayerInfo[playerid][pSex]])
select_id[playerid] = 0;
SetPlayerSkin(playerid, register_skins[select_id[playerid]]);
}
return 1;
}

Не проверял, возможно не работает.