07.08.2015, 16:45
Hello dear visitors of the portal sowing!
The problem is that the shift is 128!
debag:
Codding:
Sorry for my English! I am Russian!
Thanks in advance
The problem is that the shift is 128!
PHP код:
enum
{
GANG_ID_BALLAS, // = 0
GANG_ID_VAGOS,
GANG_ID_GROVE,
GANG_ID_AZTECAS,
GANG_ID_RIFA,
__LAST_GANG_ID // = 5, the value will be used hereinafter
}
enum(+= 2)
{
REL_SHIFT_BALLAS, // bits 0-1
REL_SHIFT_VAGOS, // = 2, bits 2-3
REL_SHIFT_GROVE, // = 4, bits 4-5
REL_SHIFT_AZTECAS, // ...
REL_SHIFT_RIFA // ... 8-9
};
enum
{
GANG_REL_NEGATIVE,
GANG_REL_NEUTRAL,
GANG_REL_POSITIVE
};
PHP код:
new gang_relationships[__LAST_GANG_ID];
PHP код:
const GANG_REL_MASK = 0b11111111_11111111_11111111_11111100;
PHP код:
case 11103: //Rifa
{
if(!response) return 0; //Ballas
if(PlayerInfo[playerid][p_leaders] == 12)
{
if(ismysqlnull(inputtext))
return SPD(playerid, 11103, DIALOG_STYLE_INPUT, " ","С какой бандой вы желаете заключить союз\n\nRifa\n\
Grove\n\
Aztec\n\
Vagos", "Ок", "Отмена");
}
if(PlayerInfo[playerid][p_leaders] == 13)
{
if(ismysqlnull(inputtext))
return SPD(playerid, 11103, DIALOG_STYLE_INPUT, " ","С какой бандой вы желаете заключить союз\n\nRifa\n\
Grove\n\
Ballas\n\
Aztec", "Ок", "Отмена");
}
//Grove
if(PlayerInfo[playerid][p_leaders] == 15)
{
if(ismysqlnull(inputtext))
return SPD(playerid, 11103, DIALOG_STYLE_INPUT, " ","С какой бандой вы желаете заключить союз\n\nRifa\n\
Aztec\n\
Ballas\n\
Vagos", "Ок", "Отмена");
}
//Aztec
if(PlayerInfo[playerid][p_leaders] == 17)
{
if(ismysqlnull(inputtext))
return SPD(playerid, 11103, DIALOG_STYLE_INPUT, " ","С какой бандой вы желаете заключить союз\n\nRifa\n\
Grove\n\
Ballas\n\
Vagos", "Ок", "Отмена");
}
//Rifa
if(PlayerInfo[playerid][p_leaders] == 18)
{
if(ismysqlnull(inputtext))
return SPD(playerid, 11103, DIALOG_STYLE_INPUT, " ","С какой бандой вы желаете заключить союз\n\nAztec\n\
Grove\n\
Ballas\n\
Vagos", "Ок", "Отмена");
}
if( PlayerInfo[playerid][p_leaders] == 12 ||
PlayerInfo[playerid][p_leaders] == 13 ||
PlayerInfo[playerid][p_leaders] == 15 ||
PlayerInfo[playerid][p_leaders] == 17 ||
PlayerInfo[playerid][p_leaders] == 18)
{
new
string_band_union[46],
my_orgazantion[8];
switch(PlayerInfo[playerid][p_members])
{
case 12: my_orgazantion = "ballas";
case 13: my_orgazantion = "vagos";
case 15: my_orgazantion = "grove";
case 17: my_orgazantion = "aztecas";
case 18: my_orgazantion = "rifa";
}
for(new interator_name_band; interator_name_band < sizeof(name_diplamation); interator_name_band ++)
{
printf("inputtext: %s | name_diplamation[interator_name_band][e_Name]: %s", inputtext, name_diplamation[interator_name_band][e_Name]);
if(strcmp(inputtext, name_diplamation[interator_name_band][e_Name], false) != 0)
{
print("1) Работает");
continue;
}
print("2) Работает");
new i_gang_id = GetGangID(name_diplamation[interator_name_band][e_Value]);
new player_gang_id = GetGangID(PlayerInfo[playerid][p_members]);
// ID другой банды - в переменной i
new shift_val = i_gang_id + i_gang_id;
gang_relationships[player_gang_id] &= GANG_REL_MASK << shift_val;
gang_relationships[player_gang_id] |= GANG_REL_POSITIVE << shift_val;
shift_val = player_gang_id + player_gang_id;
gang_relationships[i_gang_id] &= GANG_REL_MASK << shift_val;
gang_relationships[i_gang_id] |= GANG_REL_POSITIVE << shift_val;
print("3) Работает");
//sting_debbag[0] = EOS;
// strcat(save_union_band_one_to_array[playerid], name_band_for_diplamation[interator_name_band]);
// strcat(save_union_band_two_to_array[playerid], my_orgazantion);
// format(sting_debbag, sizeof(sting_debbag), "Cоюз | После | SetPVarString | name_band_one: %s | name_band_two: %s", save_union_band_one_to_array[playerid], save_union_band_two_to_array[playerid]);
//SendClientMessageToAll(-1, sting_debbag);
SPD(playerid,22201,DIALOG_STYLE_INPUT," ","Введите в поле ID Лидера Банды","Ок","Отмена");
format(string_band_union, sizeof(string_band_union), "Вы предложили союз банде %s", name_diplamation[interator_name_band][e_Name]);
SendClientMessage(playerid, COLOR_NEWS, string_band_union);
print("4) Работает");
}
}
}
PHP код:
GetGangID(family_id)
{
switch(family_id)
{
case 12:
return GANG_ID_BALLAS;
case 13:
return GANG_ID_VAGOS;
case 17:
return GANG_ID_AZTECAS;
case 18:
return GANG_ID_RIFA;
}
return -1;
}
PHP код:
if(strcmp(cmd, "/debbuging", true) == 0)
{
new string_debbag[30];
format(string_debbag, sizeof(string_debbag), "%d | %d | %d | %d", gang_relationships[GANG_ID_AZTECAS],
gang_relationships[GANG_ID_VAGOS],
PlayerInfo[playerid][p_members],
PlayerInfo[playerid][p_leaders]);
SendClientMessageToAll(-1, string_debbag);
}
PHP код:
20:46:14] inputtext: Los Santos Vagos | name_diplamation[interator_name_band][e_Name]: The Ballas
[20:46:14] 1) Job
[20:46:14] inputtext: Los Santos Vagos | name_diplamation[interator_name_band][e_Name]: Los Santos Vagos
[20:46:14] 2) Job
[20:46:14] i_gang_id: 1 | player_gang_id: 3
[20:46:14] 1) shift_val: 2
[20:46:14] 1) gang_relationships[player_gang_id]: 0
GANG_REL_MASK: -4
shift_val: 2
[20:46:14] 2) gang_relationships[player_gang_id]: 8
GANG_REL_MASK: -4
shift_val: 2
[20:46:14] 2) shift_val: 6
[20:46:14] 1) gang_relationships[i_gang_id]: 0
GANG_REL_MASK: -4
shift_val: 6
[20:46:14] 2) gang_relationships[i_gang_id]: 128
GANG_REL_MASK: -4
shift_val: 6
[20:46:14] 3) Job
[20:46:14] 4) Job
[20:46:14] inputtext: Los Santos Vagos | name_diplamation[interator_name_band][e_Name]: Grove Street
[20:46:14] 1) Job
[20:46:14] inputtext: Los Santos Vagos | name_diplamation[interator_name_band][e_Name]: Varios Los Aztecas
[20:46:14] 1) Job
[20:46:14] inputtext: Los Santos Vagos | name_diplamation[interator_name_band][e_Name]: The Rifa
[20:46:14] 1) Job
PHP код:
for (new interator_name_band; interator_name_band < sizeof(name_diplamation); interator_name_band++)
{
printf("inputtext: %s | name_diplamation[interator_name_band][e_Name]: %s", inputtext, name_diplamation[interator_name_band][e_Name]);
if (strcmp(inputtext, name_diplamation[interator_name_band][e_Name], false) != 0)
{
print("1) Job");
continue;
}
print("2) Job");
new i_gang_id = GetGangID(name_diplamation[interator_name_band][e_Value]);
new player_gang_id = GetGangID(PlayerInfo[playerid][p_members]);
printf("i_gang_id: %d | player_gang_id: %d", i_gang_id, player_gang_id);
// ID другой банды - в переменной i
new shift_val = i_gang_id + i_gang_id;
printf("1) shift_val: %d", shift_val);
gang_relationships[player_gang_id] &= GANG_REL_MASK << shift_val;
printf("1) gang_relationships[player_gang_id]: %d \n GANG_REL_MASK: %d \n shift_val: %d", gang_relationships[player_gang_id], GANG_REL_MASK, shift_val);
gang_relationships[player_gang_id] |= GANG_REL_POSITIVE << shift_val;
printf("2) gang_relationships[player_gang_id]: %d \n GANG_REL_MASK: %d \n shift_val: %d", gang_relationships[player_gang_id], GANG_REL_MASK, shift_val);
shift_val = player_gang_id + player_gang_id;
printf("2) shift_val: %d", shift_val);
gang_relationships[i_gang_id] &= GANG_REL_MASK << shift_val;
printf("1) gang_relationships[i_gang_id]: %d \n GANG_REL_MASK: %d \n shift_val: %d", gang_relationships[i_gang_id], GANG_REL_MASK, shift_val);
gang_relationships[i_gang_id] |= GANG_REL_POSITIVE << shift_val; // Apparently the error in this line
printf("2) gang_relationships[i_gang_id]: %d \n GANG_REL_MASK: %d \n shift_val: %d", gang_relationships[i_gang_id], GANG_REL_MASK, shift_val);
print("3) Job");
SPD(playerid, 22201, DIALOG_STYLE_INPUT, " ", "Введите в поле ID Лидера Банды", "Ок", "Отмена");
format(string_band_union, sizeof(string_band_union), "Вы предложили союз банде %s", name_diplamation[interator_name_band][e_Name]);
SendClientMessage(playerid, COLOR_NEWS, string_band_union);
Thanks in advance