-
Автор темы
- #1
Делал луа систему и столкнулся с проблемой, загружаю луа скрипт и он работает, но когда я хочу загрузить еще раз выдает ошибку.
code_language.lua:
local ffi = require("ffi")
ffi.cdef[[
typedef struct {
float x;
float y;
float z;
} vec3_t;
struct beam_info_t {
int m_type;
void* m_start_ent;
int m_start_attachment;
void* m_end_ent;
int m_end_attachment;
vec3_t m_start;
vec3_t m_end;
int m_model_index;
const char *m_model_name;
int m_halo_index;
const char *m_halo_name;
float m_halo_scale;
float m_life;
float m_width;
float m_end_width;
float m_fade_length;
float m_amplitude;
float m_brightness;
float m_speed;
int m_start_frame;
float m_frame_rate;
float m_red;
float m_green;
float m_blue;
bool m_renderable;
int m_num_segments;
int m_flags;
vec3_t m_center;
float m_start_radius;
float m_end_radius;
} ;
typedef void (__thiscall* draw_beams_t)(void*, void*);
typedef void*(__thiscall* create_beam_points_t)(void*, struct beam_info_t&);
]]
local render_beams_signature = "B9 ? ? ? ? A1 ? ? ? ? FF 10 A1 ? ? ? ? B9"
local match = utils.find_signature("client.dll", render_beams_signature)
local render_beams = ffi.cast('void**', ffi.cast("char*", match) + 1)[0]
local render_beams_class = ffi.cast("void***", render_beams)
local render_beams_vtbl = render_beams_class[0]
local draw_beams = ffi.cast("draw_beams_t", render_beams_vtbl[6])
local create_beam_points = ffi.cast("create_beam_points_t", render_beams_vtbl[12])
local get_eye = function()
local lc = entitylist.get_local_player()
local origin = lc:get_origin()
local offset = entitylist.get_local_player():get_prop_float("CBasePlayer", "m_vecViewOffset[2]")
return { origin.x, origin.y, origin.z + offset }
end
local bor = bit.bor
local new = ffi.new
local function create_beams(startpos, red, green, blue, alpha)
local beam_info = new("struct beam_info_t")
beam_info.m_type = 0x00
beam_info.m_model_index = -1
beam_info.m_halo_scale = 0
beam_info.m_life = 2
beam_info.m_fade_length = 1
beam_info.m_width = 20 * .1
beam_info.m_end_width = 20 * .1
beam_info.m_model_name = "sprites/purplelaser1.vmt"
beam_info.m_amplitude = 2.3
beam_info.m_speed = 0.2
beam_info.m_start_frame = 0
beam_info.m_frame_rate = 0
beam_info.m_red = red
beam_info.m_green = green
beam_info.m_blue = blue
beam_info.m_brightness = alpha
beam_info.m_num_segments = 2
beam_info.m_renderable = true
beam_info.m_flags = bor(0x00000100 + 0x00000200 + 0x00008000)
beam_info.m_start = startpos
beam_info.m_end = get_eye()
local beam = create_beam_points(render_beams_class, beam_info)
if beam ~= nil then
draw_beams(render_beams, beam)
end
end
events.register_event("bullet_impact", function(e)
if engine.get_player_for_user_id(e:get_int("userid")) == engine.get_local_player_index() then
local r,g,b,a = 255,255,255,255
create_beams({e:get_int("x"), e:get_int("y"), e:get_int("z")}, r, g, b, a)
end
end)
Пожалуйста, авторизуйтесь для просмотра ссылки.
( видео )
Последнее редактирование: