Witam,
ostatnio mam problem z bytami, mianowicie kod crashuje serwer:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <engine>
#include <fakemeta>
#include <codmod>
#include <xs>
#define PLUGIN "MW3 Mod - Meczennik"
#define VERSION "1.0"
#define AUTHOR "Czaso Umilacz"
#define MAX 32
new const perk_classname[] = "mw3_martydom";
new const perk_model[] = "models/w_hegrenade.mdl";
new sprite_blast;
new bool:ma_perk[MAX+1];
public plugin_init(){
register_plugin(PLUGIN, VERSION, AUTHOR);
cod_register_perk("Meczennik", "Po smierci wypuszczasz odbezpiecozy granat");
RegisterHam(Ham_Killed, "player", "Deatch");
register_think(perk_classname, "MartydomeThink");
register_event("HLTV", "NowaRunda", "a", "1=0", "2=0");
}
public plugin_precache(){
sprite_blast = precache_model("sprites/dexplo.spr");
precache_model(perk_model);
}
public cod_perk_enable(id){
ma_perk[id] = true;
}
public cod_perk_disable(id){
ma_perk[id] = false;
}
public Deatch(this, attacker, shouldgib){
if(!is_user_connected(this) || !ma_perk[this])
return HAM_IGNORED;
new Float:origin[3];
entity_get_vector(this, EV_VEC_origin, origin);
new ent = create_entity("info_target");
entity_set_model(ent, perk_model);
entity_set_string(ent, EV_SZ_classname, perk_classname);
entity_set_vector(ent, EV_VEC_origin, origin);
entity_set_float(ent, EV_FL_nextthink, get_gametime() + 3.0);
entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER);
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS);
entity_set_edict(ent, EV_ENT_owner, this);
return HAM_IGNORED;
}
public MartydomeThink(ent){
if(!is_valid_ent(ent))
return PLUGIN_CONTINUE;
new entlist[MAX+1], numfound = find_sphere_class(ent, "player", 100.0, entlist, MAX);
new owner = entity_get_edict(ent, EV_ENT_owner);
for(new i = 0; i < numfound; i ++){
new pid = entlist[i];
if(!is_user_alive(pid) || !fm_is_ent_visible(ent, pid) || get_user_team(owner) == get_user_team(pid))
continue;
cod_inflict_damage(owner, pid, 150.0, 0.0, ent, (1<<1));
}
new Float:forigin[3], iorigin[3];
entity_get_vector(ent, EV_VEC_origin, forigin);
FVecIVec(forigin, iorigin);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY, iorigin);
write_byte(TE_EXPLOSION);
write_coord(iorigin[0]);
write_coord(iorigin[1]);
write_coord(iorigin[2]);
write_short(sprite_blast);
write_byte(32);
write_byte(20);
write_byte(0);
message_end();
remove_entity(ent);
return PLUGIN_CONTINUE;
}
public client_disconnect(id){
new ent = find_ent_by_class(0, perk_classname);
while(ent > 0){
if(is_valid_ent(ent))
if(entity_get_edict(id, EV_ENT_owner) == id)
remove_entity(ent);
ent = find_ent_by_class(ent, perk_classname);
}
}
public NowaRunda(){
new ent = find_ent_by_class(0, perk_classname);
while(ent > 0){
if(is_valid_ent(ent))
remove_entity(ent);
ent = find_ent_by_class(ent, perk_classname);
}
}
stock bool:fm_is_ent_visible(index, entity, ignoremonsters = 0) {
new Float:start[3], Float:dest[3];
pev(index, pev_origin, start);
pev(index, pev_view_ofs, dest);
xs_vec_add(start, dest, start);
pev(entity, pev_origin, dest);
engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index, 0);
new Float:fraction;
get_tr2(0, TR_flFraction, fraction);
if(fraction == 1.0 || get_tr2(0, TR_pHit) == entity)
return true;
return false;
}
Skąd wiem że to wina tego pluginu? Długa i żmudna analiza pluginów wskazała na tego słodziaka.
A teraz kilka pytań:
1. Czy w tworzeniu bytów istotna jest kolejność przypisywania mu właściwości (classname, origin, wartości int/float/byte itd.)
2. Czy w powyższym kodzie wykonałem coś nie tak, i czemu.
Użytkownik Czaso Umilacz edytował ten post 13.09.2014 20:06


Dodatki SourceMod












