- Ошибка
-
Будет на скриншоте снизу.
- Компилятор
- Локальный
- Amx Mod X
- 1.9.0
- Исходный код
-
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <engine>
#include <hamsandwich>
//#include <dhudmessage>
#include <nvault>
#include <sqlx>
//#include <colorchat>
#pragma semicolon 1
#pragma tabsize 0
#define MAX_PLAYERS 32
#define linux_diff_player 5
const SPECIAL_CODE_BLOCK = 1551311;
const OFFSET_LINUX_WEAPONS = 4;
#if cellbits == 32;
const OFFSET_CLIPAMMO = 51;
#else
const OFFSET_CLIPAMMO = 65;
#endif
new const szBlockName[][] =
{
"Стандартный (1/7)",
"Черный (2/7)",
"Лазуритовый (3/7)",
"Изумрудный (4/7)",
"Адский (5/7)",
"Каменый (6/7)",
"Стальной (7/7)"
};
new const g_szClassBlock[] = "Class_luckyblock";
new g_PlayerBuild[33], g_szConfigFile[128];
public plugin_init()
{
register_plugin("LUCHY BLOCK", "1.0", "by thezolotoi");
register_menucmd(register_menuid("Show_BuildMenu"), (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9), "Handle_BuildMenu");
register_event("HLTV", "Event_HLTV", "a", "1=0", "2=0");
register_clcmd("luckyblock","Show_BuildMenu");
RegisterHam(Ham_Killed, "info_target", "TakeDamage", true);
// Загрузка моделей
new szMapName[32];
get_mapname(szMapName, charsmax(szMapName));
formatex(g_szConfigFile, charsmax(g_szConfigFile), "addons/amxmodx/data/lucky");
if(!dir_exists(g_szConfigFile))
{
mkdir(g_szConfigFile);
format(g_szConfigFile, charsmax(g_szConfigFile), "%s/%s.txt", g_szConfigFile, szMapName);
return;
}
format(g_szConfigFile, charsmax(g_szConfigFile), "%s/%s.txt", g_szConfigFile, szMapName);
if(!file_exists(g_szConfigFile))
return;
}
public TakeDamage(iEntity, iAttacker, attacker, corpse)
{
if(!pev_valid(iAttacker))
return;
new block[32], LuckyR;
pev(iEntity, pev_classname, block, charsmax(block));
if(equal(block,"Class_luckyblock"))
{
LuckyR = random_num(1,99);
if(LuckyR<50){
switch(random_num(1, 12))
{
case 1 : fm_give_item(iAttacker, "weapon_p228");
case 2 : fm_give_item(iAttacker, "weapon_scout");
case 3 : fm_give_item(iAttacker, "weapon_mac10");
case 4 : fm_give_item(iAttacker, "weapon_xm1014");
case 5 : fm_give_item(iAttacker, "weapon_usp");
case 6 : fm_give_item(iAttacker, "weapon_m4a1");
case 7 : fm_give_item(iAttacker, "weapon_awp");
case 8 : fm_give_item(iAttacker, "weapon_deagle");
case 9 : fm_give_item(iAttacker, "weapon_ak47");
case 10 : fm_give_item(iAttacker, "weapon_sg552");
case 11 : fm_give_item(iAttacker, "weapon_famas");
case 12 : fm_give_item(iAttacker, "weapon_galil");
}
ColorChat(iAttacker,GREEN,"[LuckyBlock] Вам выпало рандомное оружие!");
}else if(LuckyR>70 && LuckyR < 80 ){
ColorChat(iAttacker,GREEN,"[LuckyBlock] Вам выпало 255HP + 255AP");
set_user_health(iAttacker, 255);
set_user_armor(iAttacker, 255);
}else if(LuckyR>80 && LuckyR <99){
ColorChat(iAttacker,GREEN,"[LuckyBlock] Вам выпала скорость");
set_user_maxspeed(iAttacker,450.0);
}else ColorChat(iAttacker,GREEN,"[LuckyBlock] Вам нечего не выпало");
}
}
public Event_HLTV()
{
Block_Delete(0, true);
}
public plugin_precache()
{
engfunc(EngFunc_PrecacheModel, "models/jb_engine/luckyblock/luckyblock.mdl");
}
public Show_BuildMenu(id)
{
new szMenu[512], iKeys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<9), iLen;
iLen = formatex(szMenu, charsmax(szMenu), "Строительство^n^n");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[1] \wПоставить^n");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[2] \wУдалить^n");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[3] \wУдалить всё^n^n");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[4] \wЛаки блок: \y%s^n^n^n", szBlockName[g_PlayerBuild[id]]);
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[5] \wСохранить позиции^n");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[6] \wЗагрузить позиции^n");
formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r[0] \wВыход");
return show_menu(id, iKeys, szMenu, -1, "Show_BuildMenu");
}
public Handle_BuildMenu(id, iKey)
{
switch(iKey)
{
case 0:
{
new Float:vOrigin[3];
fm_get_aiming_position(id, vOrigin);
Block_Create(vOrigin, g_PlayerBuild[id]);
}
case 1:
{
Block_Delete(id, false);
}
case 2: Block_Delete(id, true);
case 3: if(++g_PlayerBuild[id] == 7) g_PlayerBuild[id] = 0;
case 4: Command_SaveAll(id);
case 5: Command_LoadObjects();
case 9: return PLUGIN_HANDLED;
}
return Show_BuildMenu(id);
}
Block_Create(Float:vOrigin[3], iBody)
{
new iEntity = -1; static siBlock;
if(siBlock || (siBlock = engfunc(EngFunc_AllocString, "info_target")))
iEntity = engfunc(EngFunc_CreateNamedEntity, siBlock);
if(!pev_valid(iEntity))
return;
set_pev(iEntity, pev_classname, g_szClassBlock);
set_pev(iEntity, pev_movetype, MOVETYPE_NONE);
set_pev(iEntity, pev_solid, SOLID_BBOX);
set_pev(iEntity, pev_iuser1, SPECIAL_CODE_BLOCK);
engfunc(EngFunc_SetModel, iEntity, "models/jb_engine/luckyblock/luckyblock.mdl");
set_pev(iEntity, pev_skin, iBody);
engfunc(EngFunc_SetOrigin, iEntity, vOrigin);
set_pev(iEntity, pev_takedamage, DAMAGE_YES);
engfunc(EngFunc_SetSize, iEntity, Float:{-15.0, -15.0, 0.0}, Float:{15.0, 15.0, 30.0});
set_pev(iEntity, pev_health, 1.0);
}
Block_Delete(id, bool:bAll)
{
new iEntity = -1;
if(!bAll)
{
new iBody; get_user_aiming(id, iEntity, iBody);
if(!pev_valid(iEntity) || pev(iEntity, pev_iuser1) != SPECIAL_CODE_BLOCK)
{
new Float:vOrigin[3];
fm_get_aiming_position(id, vOrigin);
while((iEntity = engfunc(EngFunc_FindEntityInSphere, iEntity, vOrigin, 15.0)) > 0)
{
if(pev(iEntity, pev_iuser1) != SPECIAL_CODE_BLOCK)
continue;
engfunc(EngFunc_RemoveEntity, iEntity);
break;
}
}
else
{
engfunc(EngFunc_RemoveEntity, iEntity);
}
}
else
{
while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", g_szClassBlock)))
engfunc(EngFunc_RemoveEntity, iEntity);
}
}
Command_SaveAll(id)
{
if(file_exists(g_szConfigFile))
delete_file(g_szConfigFile);
new iFile = fopen(g_szConfigFile, "wt");
if(!iFile)
return;
new Float:vOrigin[3], iEntity, szModelSkin[16];
while((iEntity = find_ent_by_class(iEntity, g_szClassBlock)) > 0)
{
pev(iEntity, pev_skin, szModelSkin, charsmax(szModelSkin));
entity_get_vector(iEntity, EV_VEC_origin, vOrigin);
fprintf(iFile, "^"%f^" ^"%f^" ^"%f^" ^"%s^"^n", vOrigin[0], vOrigin[1], vOrigin[2], szModelSkin);
}
fclose(iFile);
UTIL_SayText(id, "!y[LUCKY!y] Объекты сохранены.");
}
public Command_LoadObjects()
{
new iFile = fopen(g_szConfigFile, "rt");
if(!iFile) return PLUGIN_HANDLED;
new szBuffer[256];
new Float:vOrigin[3], fX[16], fY[16], fZ[16], szskin[16], iBody;
while(!feof(iFile))
{
fgets(iFile, szBuffer, charsmax(szBuffer));
trim(szBuffer);
if(!szBuffer[0]) continue;
parse(szBuffer, fX, charsmax(fX), fY, charsmax(fY), fZ, charsmax(fZ), szskin, charsmax(szskin));
vOrigin[0] = str_to_float(fX);
vOrigin[1] = str_to_float(fY);
vOrigin[2] = str_to_float(fZ);
iBody = str_to_num(szskin);
Block_Create(vOrigin, iBody);
}
fclose(iFile);
return PLUGIN_HANDLED;
}
stock fm_get_aiming_position(pPlayer, Float:vecReturn[3])
{
new Float:vecOrigin[3], Float:vecViewOfs[3], Float:vecAngle[3], Float:vecForward[3];
pev(pPlayer, pev_origin, vecOrigin);
pev(pPlayer, pev_view_ofs, vecViewOfs);
xs_vec_add(vecOrigin, vecViewOfs, vecOrigin);
pev(pPlayer, pev_v_angle, vecAngle);
engfunc(EngFunc_MakeVectors, vecAngle);
global_get(glb_v_forward, vecForward);
xs_vec_mul_scalar(vecForward, 8192.0, vecForward);
xs_vec_add(vecOrigin, vecForward, vecForward);
engfunc(EngFunc_TraceLine, vecOrigin, vecForward, DONT_IGNORE_MONSTERS, pPlayer, 0);
get_tr2(0, TR_vecEndPos, vecReturn);
}
stock xs_vec_add(const Float:vec1[], const Float:vec2[], Float:out[])
{
out[0] = vec1[0] + vec2[0];
out[1] = vec1[1] + vec2[1];
out[2] = vec1[2] + vec2[2];
}
stock xs_vec_mul_scalar(const Float:vec[], Float:scalar, Float:out[])
{
out[0] = vec[0] * scalar;
out[1] = vec[1] * scalar;
out[2] = vec[2] * scalar;
}
stock fm_set_user_bpammo(pPlayer, iWeaponId, iAmount)
{
new iOffset;
switch(iWeaponId)
{
case CSW_AWP: iOffset = 377; // ammo_338magnum
case CSW_SCOUT, CSW_AK47, CSW_G3SG1: iOffset = 378; // ammo_762nato
case CSW_M249: iOffset = 379; // ammo_556natobox
case CSW_FAMAS, CSW_M4A1, CSW_AUG, CSW_SG550, CSW_GALI, CSW_SG552: iOffset = 380; // ammo_556nato
case CSW_M3, CSW_XM1014: iOffset = 381; // ammo_buckshot
case CSW_USP, CSW_UMP45, CSW_MAC10: iOffset = 382; // ammo_45acp
case CSW_FIVESEVEN, CSW_P90: iOffset = 383; // ammo_57mm
case CSW_DEAGLE: iOffset = 384; // ammo_50ae
case CSW_P228: iOffset = 385; // ammo_357sig
case CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP, CSW_ELITE: iOffset = 386; // ammo_9mm
case CSW_FLASHBANG: iOffset = 387;
case CSW_HEGRENADE: iOffset = 388;
case CSW_SMOKEGRENADE: iOffset = 389;
case CSW_C4: iOffset = 390;
default: return;
}
set_pdata_int(pPlayer, iOffset, iAmount, linux_diff_player);
}
stock fm_give_item(pPlayer, const szItem[])
{
new iEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, szItem));
if(!pev_valid(iEntity)) return 0;
new Float:vecOrigin[3];
pev(pPlayer, pev_origin, vecOrigin);
set_pev(iEntity, pev_origin, vecOrigin);
set_pev(iEntity, pev_spawnflags, pev(iEntity, pev_spawnflags) | SF_NORESPAWN);
dllfunc(DLLFunc_Spawn, iEntity);
dllfunc(DLLFunc_Touch, iEntity, pPlayer);
if(pev(iEntity, pev_solid) != SOLID_NOT)
{
engfunc(EngFunc_RemoveEntity, iEntity);
return -1;
}
return iEntity;
}
stock UTIL_SayText(pPlayer, const szMessage[], any:...)
{
new szBuffer[190];
if(numargs() > 2) vformat(szBuffer, charsmax(szBuffer), szMessage, 3);
else copy(szBuffer, charsmax(szBuffer), szMessage);
while(replace(szBuffer, charsmax(szBuffer), "!y", "^1")) {}
while(replace(szBuffer, charsmax(szBuffer), "!t", "^3")) {}
while(replace(szBuffer, charsmax(szBuffer), "!g", "^4")) {}
switch(pPlayer)
{
case 0:
{
for(new iPlayer = 1; iPlayer <= 32; iPlayer++)
{
if(!is_user_connected(iPlayer)) continue;
engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, 76, {0.0, 0.0, 0.0}, iPlayer);
write_byte(iPlayer);
write_string(szBuffer);
message_end();
}
}
default:
{
engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, 76, {0.0, 0.0, 0.0}, pPlayer);
write_byte(pPlayer);
write_string(szBuffer);
message_end();
}
}
}
С иклудом колорчат ещё больше ошибок. Как я понял, колорчат вшит в 1.9.0 версию. В коде, где colorchat нужно изменить код, пробовал по разному не получалась. Подскажите пожалуйста, как правильно заменить?
В этой теме было размещено решение! Перейти к решению.
Вложения
-
23.5 KB Просмотры: 127