Добрый день пользователи Pawno-info
Написал довольно интересную систему, аналогов которой я пока что не замечал (возможно они и есть)
Собственно сам код:
Ко всем дефайнам добавим диалоги
PHP:
#define d_hack_car 2000
#define d_buy_hack 2001
PHP:
// settings
const Float:a_x = 2033.9963, // actor x
Float:a_y = 1336.3312, // actor y
Float:a_z = 10.8203, // actor z
Float:a_angle = 98.0844; // actor angle
const count_cen_1 = 1000, //Цена флешки с вирусами
count_cen_2 = 1000; //Цена провадов
//
new Float:minus_size[MAX_PLAYERS] = 0.5555, //Поднимаем бокс
Float:size[MAX_PLAYERS] = -0.705555; //Точка минимума бокса
new PlayerText:h_box_update[MAX_PLAYERS],
PlayerText:h_text_update[MAX_PLAYERS],
PlayerText:h_time_update[MAX_PLAYERS];
new Text:h_static_box[8],
Text:h_text[6];
new hacked_vehicle[MAX_VEHICLES],
h_vehicle[MAX_VEHICLES],
h_vehicle_count;
new timer_minus_count[MAX_PLAYERS];
new timer_check[MAX_PLAYERS],
minus_timer[MAX_PLAYERS] = 1, //Сколько секунд мы отнимаем каждую секунду
timer_cell[MAX_PLAYERS] = 60; //Время которое мы даем на взлом машины
PHP:
enum hHack{ pProvod, pFlesh, pStatus, pHacked, pCountHacked, pKeyHack}
new pHackInfo[MAX_PLAYERS][hHack];
Добавим диалоги (OnDialogResponse)
PHP:
case d_hack_car:
{
if(response)
{
if(pHackInfo[playerid][pStatus] == 0)
{
SendClientMessage(playerid, -1, "Вы не можете взломать данную машину");
return RemovePlayerFromVehicle(playerid);
}
PlayerTextDrawShow(playerid, h_box_update[playerid]);
PlayerTextDrawShow(playerid, h_text_update[playerid]);
PlayerTextDrawShow(playerid, h_time_update[playerid]);
for(new i = 0; i < 8; i ++) { TextDrawShowForPlayer(playerid, h_static_box[i]); }
pHackInfo[playerid][pHacked] = 1;
pHackInfo[playerid][pFlesh] = 0;
pHackInfo[playerid][pProvod] = 0;
pHackInfo[playerid][pStatus] = 0;
timer_minus_count[playerid] = SetTimerEx("@_Minus_Count",1000,true,"i",playerid);
return TogglePlayerControllable(playerid, false);
}
else RemovePlayerFromVehicle(playerid);
}
case d_buy_hack:
{
if(!response) return true;
switch(listitem)
{
case 0:
{
if(pHackInfo[playerid][pFlesh] == 1) return SendClientMessage(playerid, -1, "У вас уже имеется флешка");
if(GetPlayerMoney(playerid) < count_cen_1) return SendClientMessage(playerid, -1, "Недостаточно денег");
GivePlayerMoney(playerid, -count_cen_1);
pHackInfo[playerid][pFlesh] = 1;
return SendClientMessage(playerid, -1, "Вы купили флешку");
}
case 1:
{
if(pHackInfo[playerid][pProvod] == 1) return SendClientMessage(playerid, -1, "У вас уже имеется провод");
if(GetPlayerMoney(playerid) < count_cen_2) return SendClientMessage(playerid, -1, "Недостаточно денег");
GivePlayerMoney(playerid, -count_cen_2);
pHackInfo[playerid][pProvod] = 1;
return SendClientMessage(playerid, -1, "Вы купили провод");
}
}
}
}
PHP:
#include "../Source/hack_car_td_players.inc"
ClearDate(playerid);
в OnPlayerDeath
PHP:
if(pHackInfo[playerid][pHacked] == 1)
{
SendClientMessage(playerid, -1, "Вы не смогли взломать машину и вас ударило током");
pHackInfo[playerid][pHacked] = 0;
PlayerTextDrawLetterSize(playerid, h_box_update[playerid], 0.000000, -0.705555);
PlayerTextDrawHide(playerid, h_box_update[playerid]);
PlayerTextDrawHide(playerid, h_text_update[playerid]);
PlayerTextDrawHide(playerid, h_time_update[playerid]);
for(new i = 0; i < 8; i ++) { TextDrawHideForPlayer(playerid, h_static_box[i]); }
for(new i = 0; i < 6; i ++) { TextDrawHideForPlayer(playerid, h_text[i]); }
ClearDate(playerid);
return RemovePlayerFromVehicle(playerid);
}
в OnGameModeInit
PHP:
#include "../Source/hack_car_td_static.inc"
CreateActor(5, a_x, a_y, a_z, a_angle);// Актер
Create3DTextLabel( "Продавец.\nНажмите Y", 0x008080FF, a_x, a_y, a_z, 40.0, 0 );
Добавим кастомную функцию спавна машин которые можно будет взломать ( В любое место )
PHP:
stock h_veh(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay=-1)
{
h_vehicle[h_vehicle_count] = AddStaticVehicleEx(modelid, x, y, z, angle, color1, color2, respawn_delay + 600);
hacked_vehicle[h_vehicle_count] = 0;
h_vehicle_count ++;
return h_vehicle[h_vehicle_count];
}
В OnPlayerStateChange
PHP:
new newcar = GetPlayerVehicleID(playerid);
new Float:hp; GetPlayerHealth(playerid, hp);
for(new b; b < h_vehicle_count; b ++)
{
if(newcar == h_vehicle[b] && hp > 0 && hacked_vehicle[b] == 0)
{
new _str[3][30]; new string_static[70 - 2 - 2 - 2 + 10 + 11 + 7 + 50];
if(pHackInfo[playerid][pProvod] == 1) {_str[0] = "{53BE57}Имеется{FFFFFF}";} else {_str[0] = "{C9435E}Не имеется{FFFFFF}";}
if(pHackInfo[playerid][pFlesh] == 1){_str[1] = "{53BE57}Имеется{FFFFFF}";}else{_str[1] = "{C9435E}Не имеется{FFFFFF}";}
if(pHackInfo[playerid][pFlesh] == 1 && pHackInfo[playerid][pProvod] == 1) {_str[2] = "{53BE57}Возможно{FFFFFF}"; pHackInfo[playerid][pStatus] = 1;} else {_str[2] = "{C9435E}Не возможно{FFFFFF}"; pHackInfo[playerid][pStatus] = 0;}
format(string_static, sizeof(string_static), "{FFFFFF}Информация о взломе машины:\nПровод: %s\nФлешка: %s\nСтатус взлома: %s",_str[0],_str[1],_str[2]);
ShowPlayerDialog(playerid, d_hack_car, DIALOG_STYLE_MSGBOX,"Взлом машины", string_static, "Взломать","Отмена");
break;
}
}
В OnPlayerKeyStateChange
PHP:
if(newkeys == KEY_YES)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, a_x, a_y, a_z))
{
new string[62 + 22];
format(string, sizeof(string),"Название\tЦена\n\
Флешка с вирусами\t[%d $]\n\
Провода\t[%d $]", count_cen_1,count_cen_2);
ShowPlayerDialog(playerid, d_buy_hack, DIALOG_STYLE_TABLIST_HEADERS, "Покупка техники", string, "Купить","Отмена");
}
// pKeyHack == 1 (Y) pKeyHack == 0 (N)
if(pHackInfo[playerid][pHacked] == 1)
{
if(pHackInfo[playerid][pKeyHack] == 1)
{
pHackInfo[playerid][pCountHacked] += 1;
switch(pHackInfo[playerid][pCountHacked])
{
case 3: TextDrawShowForPlayer(playerid, h_text[0]);
case 6: TextDrawShowForPlayer(playerid, h_text[1]);
case 9: TextDrawShowForPlayer(playerid, h_text[2]);
case 11: TextDrawShowForPlayer(playerid, h_text[3]);
case 14: TextDrawShowForPlayer(playerid, h_text[4]);
case 19: TextDrawShowForPlayer(playerid, h_text[5]), Finish_Hack(playerid);
}
update_box_hack(playerid);
}
if(pHackInfo[playerid][pKeyHack] == 0 )
{
minus_health(playerid);
}
switch(random(2)) { case 0: pHackInfo[playerid][pKeyHack] = 0; case 1: pHackInfo[playerid][pKeyHack] = 1; }
switch(pHackInfo[playerid][pKeyHack])
{
case 0: PlayerTextDrawSetString(playerid, h_text_update[playerid], "PRESS: N");
case 1: PlayerTextDrawSetString(playerid, h_text_update[playerid], "PRESS: Y");
}
PlayerTextDrawShow(playerid, h_text_update[playerid]);
}
}
if(newkeys == KEY_NO)
{
if(pHackInfo[playerid][pHacked] == 1)
{
if(pHackInfo[playerid][pKeyHack] == 0)
{
pHackInfo[playerid][pCountHacked] += 1;
switch(pHackInfo[playerid][pCountHacked])
{
case 3: TextDrawShowForPlayer(playerid, h_text[0]);
case 6: TextDrawShowForPlayer(playerid, h_text[1]);
case 9: TextDrawShowForPlayer(playerid, h_text[2]);
case 11: TextDrawShowForPlayer(playerid, h_text[3]);
case 14: TextDrawShowForPlayer(playerid, h_text[4]);
case 19: TextDrawShowForPlayer(playerid, h_text[5]), Finish_Hack(playerid);
}
update_box_hack(playerid);
}
if(pHackInfo[playerid][pKeyHack] == 1)
{
minus_health(playerid);
}
switch(random(2)) { case 0: pHackInfo[playerid][pKeyHack] = 0; case 1: pHackInfo[playerid][pKeyHack] = 1; }
switch(pHackInfo[playerid][pKeyHack])
{
case 0: PlayerTextDrawSetString(playerid, h_text_update[playerid], "PRESS: N");
case 1: PlayerTextDrawSetString(playerid, h_text_update[playerid], "PRESS: Y");
}
PlayerTextDrawShow(playerid, h_text_update[playerid]);
}
}
Добавим сток ( В любое место )
PHP:
stock Finish_Hack(playerid)
{
pHackInfo[playerid][pHacked] = 0;
SendClientMessage(playerid, -1, "Машина успешно взломана\n Скрываем комьютер...");
SetTimerEx("@_Hide_H_Draws",2000,false,"i",playerid);
new newcar = GetPlayerVehicleID(playerid);
for(new b = 1; b < h_vehicle_count; b ++)
{
if(newcar == b)
{
hacked_vehicle[newcar-1] = 1;
break;
}
}
ClearDate(playerid);
return true;
}
Добавим таймер ( В любое место )
PHP:
@_Hide_H_Draws(playerid);
@_Hide_H_Draws(playerid)
{
PlayerTextDrawHide(playerid, h_box_update[playerid]);
PlayerTextDrawHide(playerid, h_text_update[playerid]);
PlayerTextDrawHide(playerid, h_time_update[playerid]);
for(new i = 0; i < 8; i ++) { TextDrawHideForPlayer(playerid, h_static_box[i]); }
for(new i = 0; i < 6; i ++) { TextDrawHideForPlayer(playerid, h_text[i]); }
TogglePlayerControllable(playerid, true);
pHackInfo[playerid][pCountHacked] = 0;
}
Добавим сток обновления бокса (В любое место)
PHP:
stock update_box_hack(playerid)
{
new Float:si = size[playerid] - minus_size[playerid];
size[playerid] = si;
PlayerTextDrawLetterSize(playerid, h_box_update[playerid], 0.000000, si);
PlayerTextDrawShow(playerid, h_box_update[playerid]);
return true;
}
Добавим сток который будет отнимать нам хп (В любое место)
PHP:
stock minus_health(playerid)
{
new Float:hp; GetPlayerHealth(playerid, hp);
new Float:m_hp = hp - 10;
SetPlayerHealth(playerid, m_hp);
}
Добавим основной таймер (В любое место)
PHP:
@_Minus_Count(playerid);
@_Minus_Count(playerid)
{
if(pHackInfo[playerid][pCountHacked] != 0)
{
pHackInfo[playerid][pCountHacked] -= 1;
new Float:si = size[playerid] + minus_size[playerid];
size[playerid] = si;
PlayerTextDrawLetterSize(playerid, h_box_update[playerid], 0.000000, si);
PlayerTextDrawShow(playerid, h_box_update[playerid]);
}
switch(timer_check[playerid])
{
case 60..100:
{
SendClientMessage(playerid, -1, "Вы не смогли взломать машину и вас ударило током");
PlayerTextDrawHide(playerid, h_box_update[playerid]);
PlayerTextDrawHide(playerid, h_text_update[playerid]);
PlayerTextDrawHide(playerid, h_time_update[playerid]);
for(new i = 0; i < 8; i ++) { TextDrawHideForPlayer(playerid, h_static_box[i]); }
for(new i = 0; i < 6; i ++) { TextDrawHideForPlayer(playerid, h_text[i]); }
RemovePlayerFromVehicle(playerid);
ClearDate(playerid);
return true;
}
}
timer_check[playerid] ++;
new count = timer_cell[playerid] - minus_timer[playerid];
timer_cell[playerid] = count;
new _str[13];
format(_str, sizeof(_str), "TIME: %d",count);
PlayerTextDrawSetString(playerid, h_time_update[playerid], _str);
PlayerTextDrawShow(playerid,h_time_update[playerid]);
return true;
}
И добавим сток, который будет очищать переменные игрока (В любое место)
PHP:
stock ClearDate(playerid)
{
PlayerTextDrawLetterSize(playerid, h_box_update[playerid], 0.000000, -0.705555); // Восстанавливаем высоту бокса
size[playerid] = -0.705555;
KillTimer(timer_minus_count[playerid]);
timer_check[playerid] = 0;
minus_timer[playerid] = 1;
timer_cell[playerid] = 60;
pHackInfo[playerid][pProvod] = 0;
pHackInfo[playerid][pFlesh] = 0;
pHackInfo[playerid][pStatus] = 0;
pHackInfo[playerid][pHacked] = 0;
pHackInfo[playerid][pCountHacked] = 0;
pHackInfo[playerid][pKeyHack] = 0;
}
Полезная информация:
Кастомная функция h_veh
Параметры: modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay=-1
Как использовать?
- Допустим вам надо создать простую машину без системы взлома - Используем CreateVehicle или AddStaticVehicle
- Если нужно создать машину с системой взлома - Используем h_veh
Пример:
- CreateVehicle(403, 2035.8324, 1332.5811, 11.3482, 0.0000, -1, -1, 100); - Создаст кар без взлома
- h_veh(403, 2051.5430, 1349.5922, 10.8316, 0.0000, -1, -1, 100); - создаст кар со взломом
Где можно использовать:
Допустим у вас стандартный скриллакс мод, то эту систему можно использовать для гос фракций, типа:
lspd_car = h_veh(403, 2051.5430, 1349.5922, 10.8316, 0.0000, -1, -1, 100);
Скриншоты
Видео
Сервер на котором я все тестировал и писал: yadi.sk/d/ACFx_6_N3QecBL
Скачать и поместить в корневую папку с вашим сервером: yadi.sk/d/Lg2uRqQ23QecV2
RP 1000/10
На этом вроде все. Жду адекватной критики.
UPDATE: Чуть подредактировал код и убрал дублированные переменные
Последнее редактирование: