|
Veteran Member
|

05-14-2020
, 07:12
Re: Can anyone help fix this plugin?
|
#2
|
nexttime:
HTML Code:
register_clcmd ("amx_mycommand", "MyFunction", ADMIN_KICK, "Description of the command")
This code is so messy, I don't even know if it's going to work for you.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta_util>
#define PLUGIN "weapon box"
#define AUTHOR "apocalips"
#define VERSION "0.3"
new munitieModel[] = "models/ammo4.mdl"
new aimVector[3]
new explode
new Float:g_origin[33][3];
new Float:nr_bullets[33];
new projectile_MODEL[] = "models/projectile.mdl";
new projectile_SOUND[] = "ar2laungher.wav";
new open_box[] = "open_box.wav";
new VIEW_MODEL[] = "models/v_ar2.mdl"
new PLAYER_MODEL[] = "models/p_ar2.mdl"
new munitieEnt
new box_file[200]
new Configsdir[200]
public plugin_precache()
{
precache_model(munitieModel)
precache_model(VIEW_MODEL)
precache_model(PLAYER_MODEL)
explode = precache_model("sprites/zerogxplode33.spr")
engfunc(EngFunc_PrecacheModel, projectile_MODEL);
engfunc(EngFunc_PrecacheSound, projectile_SOUND);
engfunc(EngFunc_PrecacheSound, open_box);
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("munitie_spawn","create", ADMIN_SLAY, "Description of the command")
//register_clcmd ("amx_mycommand", "MyFunction", ADMIN_KICK, "Description of the command")
register_clcmd("remove","delet_munitie", ADMIN_SLAY, "Description of the command")
register_clcmd("removeall","delet_munitie_all ",ADMIN_SLAY,"")
register_forward(FM_Touch,"fw_touch");
register_menucmd(register_menuid("\yweapons:" ), 1023, "menu_command" );
register_forward(FM_Touch,"plasma_interact");
register_event("CurWeapon", "Event_CurWeapon", "be","1=1")
set_task(1.0,"map_load_weapon_box")
}
public create(id,level,cid)
{
if(!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
set_task( 1.0 , "lada_munitie" , id )
}
public lada_munitie(id)
{
new Floatrigin[3]
new Float:angles[3]
new Float:v_angle[3]
entity_get_vector(id,EV_VEC_v_angle,v_angle)
entity_get_vector(id,EV_VEC_angles,angles)
munitieEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"));
set_pev(munitieEnt, pev_classname, "munitie");
get_user_origin(id, aimVector, 3) //where the player is aiming
IVecFVec(aimVector, Floatrigin); //covert aim origin(int) to float.
set_pev(munitieEnt, pev_origin, Floatrigin);
engfunc(EngFunc_SetModel, munitieEnt, munitieModel);
set_pev(munitieEnt,pev_solid,SOLID_BBOX);
new Float:vRetVector[3]
entity_get_vector(id, EV_VEC_v_angle, vRetVector)
vRetVector[0]=float(0)
entity_set_vector(munitieEnt, EV_VEC_angles, vRetVector)
if( ((vRetVector[1]>=45.0) && (vRetVector[1]<=135.0)) || ((vRetVector[1]>=-135.0) && (vRetVector[1]<=-45.0)) )
{
engfunc(EngFunc_SetSize, munitieEnt, Float:{-30.0, -20.0, -90.0}, Float:{30.0, 20.0, 90.0} )
}
else
{
engfunc(EngFunc_SetSize, munitieEnt, Float:{-20.0, -30.0, -90.0}, Float:{20.0, 30.0, 90.0} )
}
get_configsdir( Configsdir, 199 )
format(box_file, 199, "%s/weapon_box.ini", Configsdir )
new mapname[32]
new string[16]
get_mapname(mapname,31)
format(mapname,31,"[%s]",mapname)
write_file(box_file,mapname,-1)
format(string,15,"%f",Floatrigin[0])
write_file(box_file,string,-1)
format(string,15,"%f",Floatrigin[1])
write_file(box_file,string,-1)
format(string,15,"%f",Floatrigin[2])
write_file(box_file,string,-1)
format(string,15,"%f",angles[0])
write_file(box_file,string,-1)
format(string,15,"%f",angles[1])
write_file(box_file,string,-1)
format(string,15,"%f",angles[2])
write_file(box_file,string,-1)
format(string,15,"%f",v_angle[0])
write_file(box_file,string,-1)
format(string,15,"%f",v_angle[1])
write_file(box_file,string,-1)
format(string,15,"%f",v_angle[2])
write_file(box_file,string,-1)
return PLUGIN_HANDLED
}
public map_load_weapon_box(id)
{
new mapname[32]
get_mapname(mapname,31)
format(mapname,31,"[%s]",mapname)
get_configsdir( Configsdir, 199 )
format(box_file, 199, "%s/weapon_box.ini", Configsdir )
new read[32], trash
new Floatrigin[3], Float:angles[3], Float:v_angle[3]
if(file_exists(box_file))
{
for(new i=0;i<file_size(box_file,1);i++)
{
read_file(box_file,i,read,31,trash)
if(equali(read,mapname))
{
i++
read_file(box_file,i,read,31,trash)
Floatrigin[0] = str_to_float(read)
i++
read_file(box_file,i,read,31,trash)
Floatrigin[1] = str_to_float(read)
i++
read_file(box_file,i,read,31,trash)
Floatrigin[2] = str_to_float(read)
i++
read_file(box_file,i,read,31,trash)
angles[0] = str_to_float(read)
i++
read_file(box_file,i,read,31,trash)
angles[1] = str_to_float(read)
i++
read_file(box_file,i,read,31,trash)
angles[2] = str_to_float(read)
i++
read_file(box_file,i,read,31,trash)
v_angle[0] = str_to_float(read)
i++
read_file(box_file,i,read,31,trash)
v_angle[1] = str_to_float(read)
i++
read_file(box_file,i,read,31,trash)
v_angle[2] = str_to_float(read)
v_angle[0] = 0.000000
munitieEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"));
set_pev(munitieEnt, pev_classname, "munitie");
set_pev(munitieEnt, pev_origin, Floatrigin);
engfunc(EngFunc_SetModel, munitieEnt, munitieModel);
set_pev(munitieEnt,pev_solid,SOLID_BBOX);
entity_set_vector(munitieEnt, EV_VEC_angles, v_angle)
new Float:vRetVector[3]
entity_get_vector(id, EV_VEC_v_angle, vRetVector)
if( ((vRetVector[1]>=45.0) && (vRetVector[1]<=135.0)) || ((vRetVector[1]>=-135.0) && (vRetVector[1]<=-45.0)) )
{
engfunc(EngFunc_SetSize, munitieEnt, Float:{-30.0, -20.0, -90.0}, Float:{30.0, 20.0, 90.0} )
}
else
{
engfunc(EngFunc_SetSize, munitieEnt, Float:{-20.0, -30.0, -90.0}, Float:{20.0, 30.0, 90.0} )
}
}
}
}
}
public close_box(param[2])
{
new munitieEnt = param[0];
if(!pev_valid(munitieEnt))
return FMRES_IGNORED;
set_pev(munitieEnt, pev_sequence, 4);
set_pev(munitieEnt, pev_framerate, 1.0);
}
public fw_touch(id,munitieEnt)
{
if(!pev_valid(munitieEnt))
return FMRES_IGNORED;
new classname[32]
pev(munitieEnt,pev_classname,classname,31)
if(!equal(classname, "munitie"))
return FMRES_IGNORED;
if(is_user_connected(id) && is_user_alive(id))
{
new team = get_user_team(id);
if(team == 1)
return FMRES_IGNORED;
set_pev(munitieEnt, pev_sequence, 1);
set_pev(munitieEnt, pev_framerate, 1.0);
emit_sound( id, CHAN_AUTO, open_box, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
new weapon = get_user_weapon(id)
switch(weapon)
{
case CSW_M4A1,CSW_SG552,CSW_FAMAS,CSW_GALIL,CSW_SG550,CSW_AUG: fm_give_item(id, "ammo_556nato");
case CSW_XM1014,CSW_M3: fm_give_item(id, "ammo_buckshot");
case CSW_MAC10,CSW_UMP45: fm_give_item(id, "ammo_45acp");
case CSW_MP5NAVY,CSW_TMP: fm_give_item(id, "ammo_9mm");
case CSW_P90: fm_give_item(id, "ammo_57mm");
case CSW_AWP: fm_give_item(id, "ammo_338magnum");
case CSW_M249: fm_give_item(id, "ammo_556natobox");
case CSW_G3SG1,CSW_AK47: fm_give_item(id, "ammo_762nato");
default:
{
if(weapon == CSW_DEAGLE,CSW_FIVESEVEN,CSW_KNIFE,CSW_GLOCK18,CSW_ELITE,CSW_P228,CSW_USP)
{
switch(weapon)
{
case CSW_DEAGLE: fm_give_item(id, "ammo_50ae");
case CSW_P228: fm_give_item(id, "ammo_357sig");
case CSW_ELITE,CSW_GLOCK18: fm_give_item(id, "ammo_9mm");
case CSW_FIVESEVEN: fm_give_item(id, "ammo_57mm");
case CSW_USP: fm_give_item(id, "ammo_45acp");
}
new szMenuBody[256];
new keys;
new nLen = format( szMenuBody, 255, "\yweapons:^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. xm1014" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. aug" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w3. awp" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w4. m249" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w5. m3" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w6. m4a1" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w7. g3sg1" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w8. ak47" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w9. ar2" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit" );
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8 |1<<9)
show_menu( id, keys, szMenuBody, -1 );
}
}
}
new param[2];
param[0] = munitieEnt;
set_task(2.0, "close_box", 1234, param, 2);
}
return FMRES_IGNORED;
}
public menu_command(id,key)
{
switch( key )
{
case 0: {
fm_give_item(id, "weapon_xm1014")
}
case 1: {
fm_give_item(id, "weapon_aug")
}
case 2: {
fm_give_item(id, "weapon_awp")
}
case 3: {
fm_give_item(id, "weapon_m249")
}
case 4: {
fm_give_item(id, "weapon_m3")
}
case 5: {
fm_give_item(id, "weapon_m4a1")
}
case 6: {
fm_give_item(id, "weapon_g3sg1")
}
case 7: {
fm_give_item(id, "weapon_ak47")
}
case 8: {
fm_give_item(id, "weapon_p90")
}
}
}
public delet_munitie(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new body;
get_user_aiming(id, munitieEnt, body);
new classname[32]
pev(munitieEnt,pev_classname,classname,31)
if (equali(classname, "munitie"))
{
fm_remove_entity(munitieEnt);
client_print(id,print_chat,"[AMXX] removed weapon box !");
}
return FMRES_IGNORED;
}
public delet_munitie_all(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new ammo = -1;
while ((ammo = fm_find_ent_by_class(ammo, "munitie")))
engfunc(EngFunc_RemoveEntity, ammo);
client_print(id,print_chat,"[AMXX] You removed all weapon box !");
}
////////////////////////////
// weapon ar2 (hl2) //
public client_PreThink(id)
{
new weapon = get_user_weapon(id)
if(weapon == CSW_P90)
{
if(get_user_button(id) & IN_ATTACK2)
{
ar2_plasma(id);
}
}
}
public ar2_plasma(id)
{
new Float:nexTime = get_gametime();
if(nr_bullets[id] > nexTime)
{
return PLUGIN_CONTINUE;
}
else
{
new Float:StartOrigin[3], Float:Angle[3]
new PlayerOrigin[3]
get_user_origin(id, PlayerOrigin, 1)
StartOrigin[0] = float(PlayerOrigin[0])
StartOrigin[1] = float(PlayerOrigin[1])
StartOrigin[2] = float(PlayerOrigin[2])
entity_get_vector(id, EV_VEC_v_angle, Angle)
Angle[0] = Angle[0] * -1.0
new ar2_plasm = create_entity("info_target")
entity_set_string(ar2_plasm, EV_SZ_classname, "plasma_classname")
entity_set_model(ar2_plasm, "models/projectile.mdl")
entity_set_origin(ar2_plasm, StartOrigin)
entity_set_vector(ar2_plasm, EV_VEC_angles, Angle)
new Float:MinBox[3] = {-1.0, -1.0, -1.0}
new Float:MaxBox[3] = {1.0, 1.0, 1.0}
entity_set_vector(ar2_plasm, EV_VEC_mins, MinBox)
entity_set_vector(ar2_plasm, EV_VEC_maxs, MaxBox)
entity_set_int(ar2_plasm, EV_INT_solid, 2)
entity_set_int(ar2_plasm, EV_INT_movetype, 5)
entity_set_edict(ar2_plasm, EV_ENT_owner, id)
new Float:Velocity[3]
VelocityByAim(id, 1000, Velocity)
entity_set_vector(ar2_plasm, EV_VEC_velocity, Velocity)
client_cmd(id, "spk ^"%s^"",projectile_SOUND)
nr_bullets[id] = nexTime + 20.0;
}
}
public plasma_interact(ar2_plasm,other)
{
if(!pev_valid(ar2_plasm))
return FMRES_IGNORED;
new classname[32]
pev(ar2_plasm,pev_classname,classname,31)
if(!equal(classname, "plasma_classname"))
return FMRES_IGNORED;
remove_task(ar2_plasm)
new Float:fOrigin[3]
new iOrigin[3]
entity_get_vector(ar2_plasm, 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(explode);
write_byte(30);
write_byte(15);
write_byte(0);
message_end();
RadiusDamage(fOrigin, 15, 10)
remove_entity(ar2_plasm)
if(is_user_connected(other))
{
user_kill(other, 0)
}
}
public Event_CurWeapon(id)
{
new weaponID = read_data(2)
if(weaponID != CSW_P90)
return PLUGIN_CONTINUE
set_pev(id, pev_viewmodel2, VIEW_MODEL)
set_pev(id, pev_weaponmodel2, PLAYER_MODEL)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
|
|