Raised This Month: $ Target: $400
 0% 

Armor drop plug-in problem.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sQn
Member
Join Date: May 2007
Location: Poland, FtF Server :)
Old 11-07-2007 , 16:34   Armor drop plug-in problem.
Reply With Quote #1

Hi. In order to at bringing up (coming up) vest listen sound tr_kelvar.wav

Code
PHP Code:
/*
 * Title:
 *  CS Armor Drop (on death)
 *
 * Summary:
 *  When a player dies, if they have armor, they will drop their armor on the ground next to their corpse.
 *   A player can then walk over it and pick it up, letting them get a "percentage" of the armor left behind.
 *  Also, the player will recieve the same armor type as what they picked up.
 *  All armor will be deleted when round ends. Or on specified time (see cvars).
 *
 * Cvars:  
 *   armor_pct - (Default 20%) This is percentage of armor that will be received when its picked up.
 *   armor_max - (Default 100) This is the max amount of armor a user can get from picking up.  
 *   armor_min - (Default 15)  Minimum armor needed, for player to drop when killed.
 *   armor_removetime - (Default 2min) Time before armor is removed from map (unless round ends).
 *
 *
 * Requires : AMXX 1.60
 * Modules : Engine, FakeMeta
 * Tested : Win32 (Linux untested)
 *
 * Author:  OneEyed
 * Version: 1.1
 *
 * Thanks : ccnncc99, sXy-Schreck, phear of rice, and Aunt Friggin' Connie, 
 *   For helping me test and fix this plugin!
 *
 *
 * - Change Log:
 *  -v1.1 
 *  - Fixed to work on AMXX 1.60
 *  - Added "Armor Drop" CVAR for queries to pick up.
 */
#include <amxmodx>
#include <engine>
#include <fakemeta>
//---------------These values are default, they are added to the CVAR's---------------------
//---------------Change if you want these to be defaulted to the CVAR on SERVER RESTART-----
//----------------------------------------------------------------------
//This is percentage, if its 25, only 25% of dropped armor will be given.
#define ARMOR_TAX "50"
//----------------------------------------------------------------------
// MAX armor allowed, default = 100 (Set higher, if you want players to go over 100 armor.)
#define MAXARMOR "100"
//----------------------------------------------------------------------
// Minimum armor needed for armor to drop when player dies.
#define MINARMOR "35"
//----------------------------------------------------------------------
// Time before Armor is removed from the map in seconds (unless round ends) default=2mins
#define REMOVE_TIME "180"
//----------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------
//-----------------------------------DO NOT EDIT BELOW THIS LINE-----------------------------------------------
//-------------------------------------------------------------------------------------------------------------
#define KEVLAR   1
#define VESTHELM  2
#define ARMORTYPE_OFFSET 112
#define TITLE "Armor Drop"
#define VERSION "1.0"
#define AUTHOR "OneEyed"
new g_ArmorType[33], Float:g_ArmorAmount[33], fArmor[33]
//Change this if you want a custom kevlar model
new armormodel[] = "models/new/w_kevlar.mdl"
new armorsound[] = "sound/items/tr_kevlar.wav"
new Float:multiplier
//-------------------------------------------------------------------------------------------------------------
public plugin_precache()
{
 
precache_model(armormodel)
 
precache_sound(armorsound)
 
}
//-------------------------------------------------------------------------------------------------------------
public plugin_init() {
 
register_plugin(TITLEVERSIONAUTHOR)
 
register_cvar(TITLE,VERSION,FCVAR_SERVER)
 
 if(!
cvar_exists("armor_pct"))
  
register_cvar("armor_pct",ARMOR_TAX)
 if(!
cvar_exists("armor_max"))
  
register_cvar("armor_max",MINARMOR)
 if(!
cvar_exists("armor_min"))
  
register_cvar("armor_min",MINARMOR)
 if(!
cvar_exists("armor_removetime"))
  
register_cvar("armor_removetime",REMOVE_TIME)
  
 
register_touch("FakeArmor","player","grabArmor")
 
 
register_event("DeathMsg","createArmor","a")
 
register_event"SendAudio""EndRound""a""2=%!MRAD_terwin""2=%!MRAD_ctwin""2=%!MRAD_rounddraw" )
}
//-------------------------------------------------------------------------------------------------------------
//-----------Delayed it to be right at the end, (doesnt work if i try to erase it on Round Start)--------------
public EndRound()
 
set_task(5.0,"removeArmor",1111)
public 
removeArmor() {
 new 
tempid = -1
 
while ( ( tempid find_ent_by_class(tempid"FakeArmor") ) > 0)
  if(
is_valid_ent(tempid)) {
   
remove_entity(tempid)
   
remove_task(tempid)
  }
 return 
PLUGIN_CONTINUE
}
//-------------------------------------------------------------------------------------------------------------
// Set task to this to remove the armor after specified amount of time. (armor_removetime)
public removeThisArmor(id)
 if(
is_valid_ent(id))
  
remove_entity(id)
//-------------------------------------------------------------------------------------------------------------
public grabArmor(pToucherpTouched) {
 if(
is_user_alive(pTouched) && is_user_connected(pTouched) && entity_get_float(pTouched,EV_FL_armorvalue) < float(get_cvar_num("armor_max"))) {
  new 
owner entity_get_int(pToucherEV_INT_iuser1)
  if(
is_valid_ent(fArmor[owner])) {
   
get_armor_values(pTouched)
   
multiplier float(get_cvar_num("armor_pct")) * 0.01
   
   
//Retrieve armor values left on the dropped kevlar
   
new armortype entity_get_int(fArmor[owner], EV_INT_iuser3)
   new 
armoramt entity_get_int(fArmor[owner], EV_INT_iuser4)
   
   
//Set armor accordingly to how player has theirs, and what type they grab.
   
if(g_ArmorType[pTouched] == 0
    
csset_user_armor(pTouchedarmoramt*multiplier, (armortype==1?KEVLAR:VESTHELM)), emit_sound(0CHAN_AUTOarmorsound1.0ATTN_NORM0PITCH_NORM
   else if(
g_ArmorType[pTouched] == && armortype == 1
    
csset_user_armor(pTouchedentity_get_float(pTouched,EV_FL_armorvalue)+(armoramt*multiplier), KEVLAR), emit_sound(0CHAN_AUTOarmorsound1.0ATTN_NORM0PITCH_NORM
   else if((
g_ArmorType[pTouched] == && armortype == 2) || g_ArmorType[pTouched] == 2
    
csset_user_armor(pTouchedentity_get_float(pTouched,EV_FL_armorvalue)+(armoramt*multiplier), VESTHELM), emit_sound(0CHAN_AUTOarmorsound1.0ATTN_NORM0PITCH_NORM
   
   
// If their armor goes over MAXARMOR set it to MAXARMOR
   
if(entity_get_float(pTouched,EV_FL_armorvalue) > float(get_cvar_num("armor_max")))
    
entity_set_float(pTouched,EV_FL_armorvaluefloat(get_cvar_num("armor_max")))
   
g_ArmorType[pTouched] = armortype
   remove_entity
(fArmor[owner])
   
remove_task(fArmor[owner])
  }
 }
 return 
PLUGIN_HANDLED
}
//-------------------------------------------------------------------------------------------------------------
public createArmor(id) {
 new 
victim read_data(2//grab user ID who died
 
 
get_armor_values(victim)
 
 if(
g_ArmorType[victim] <= || g_ArmorAmount[victim] <= float(get_cvar_num("armor_min")))
  return 
PLUGIN_CONTINUE
 
new origin[3]
 new 
Float:fOrigin[3]
 
get_user_origin(victim,origin)
 for(new 
a=0;a<3;a++)
  
fOrigin[a]=float(origin[a])
 
fArmor[victim] = create_entity("info_target")
 if(
fArmor[victim]) {
  
entity_set_string(fArmor[victim],EV_SZ_classname,"FakeArmor")
  
entity_set_model(fArmor[victim], armormodel)
  
  new 
Float:MinBox[3]
  new 
Float:MaxBox[3]
  
MinBox[0] = -6.0
  MinBox
[1] = -8.0
  MinBox
[2] = -1.5
  MaxBox
[0] = 6.0
  MaxBox
[1] = 8.0
  MaxBox
[2] = 1.5
  
  entity_set_vector
(fArmor[victim], EV_VEC_minsMinBox)
  
entity_set_vector(fArmor[victim], EV_VEC_maxsMaxBox)
  
  
entity_set_int(fArmor[victim], EV_INT_solidSOLID_BBOX
  
entity_set_int(fArmor[victim], EV_INT_movetypeMOVETYPE_TOSS)
  
  
// Sets iuser1 to victim ID
  
entity_set_int(fArmor[victim], EV_INT_iuser1victim)
  
// Sets iuser3 to Armor Type (kevlar of vest+helm)
  
entity_set_int(fArmor[victim], EV_INT_iuser3g_ArmorType[victim])
  
// Sets iuser4 to Armor Value (amount victim had when he died)
  
entity_set_int(fArmor[victim], EV_INT_iuser4floatround(g_ArmorAmount[victim]))
  
entity_set_origin(fArmor[victim], fOrigin)
  
set_task(float(get_cvar_num("armor_removetime")),"removeThisArmor",fArmor[victim])
 }
 return 
PLUGIN_HANDLED
}
//-------------------------------------------------------------------------------------------------------------
public get_armor_values(id) {
 if(
entity_get_float(id,EV_FL_armorvalue) <= 0.0)
  
g_ArmorType[id] = 0
 
else {
  
g_ArmorAmount[id] = entity_get_float(id,EV_FL_armorvalue)
  
g_ArmorType[id] = get_pdata_int(id,ARMORTYPE_OFFSET)
 } 
}
//-------------------------------------------------------------------------------------------------------------
//Cstrike.inc has this function, but its broken, so i made my own that works =).
public csset_user_armor(idFloat:amounttype) {
 
entity_set_float(id,EV_FL_armorvalueamount)
 
set_pdata_int(id,ARMORTYPE_OFFSET,type
}
//------------------------------------------------------------------------------------------------------------- 
__________________

80.52.244.150:27016
sQn is offline
sQn
Member
Join Date: May 2007
Location: Poland, FtF Server :)
Old 11-07-2007 , 16:35   Re: Armor drop plug-in problem.
Reply With Quote #2

I easy compine this plug-in
__________________

80.52.244.150:27016
sQn is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 11-07-2007 , 17:53   Re: Armor drop plug-in problem.
Reply With Quote #3

Probably
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
sQn
Member
Join Date: May 2007
Location: Poland, FtF Server :)
Old 11-08-2007 , 06:09   Re: Armor drop plug-in problem.
Reply With Quote #4

Fix my plug-in and send me fixed code.
__________________

80.52.244.150:27016
sQn is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 11-08-2007 , 09:22   Re: Armor drop plug-in problem.
Reply With Quote #5

sQn.

No one knows what you said in the first two posts.
You should say what is wrong with the plugin, and paste the errors you are getting.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
sQn
Member
Join Date: May 2007
Location: Poland, FtF Server :)
Old 11-08-2007 , 11:34   Re: Armor drop plug-in problem.
Reply With Quote #6

I wont listen sound tr_kelvar.wav when bringing up armour.This plug-in doesn't work [I don't listen sound when i bring up armour].
__________________

80.52.244.150:27016
sQn is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-08-2007 , 12:54   Re: Armor drop plug-in problem.
Reply With Quote #7

Try this :
PHP Code:
/*
 * Title:
 *  CS Armor Drop (on death)
 *
 * Summary:
 *  When a player dies, if they have armor, they will drop their armor on the ground next to their corpse.
 *   A player can then walk over it and pick it up, letting them get a "percentage" of the armor left behind.
 *  Also, the player will recieve the same armor type as what they picked up.
 *  All armor will be deleted when round ends. Or on specified time (see cvars).
 *
 * Cvars:  
 *   armor_pct - (Default 20%) This is percentage of armor that will be received when its picked up.
 *   armor_max - (Default 100) This is the max amount of armor a user can get from picking up.  
 *   armor_min - (Default 15)  Minimum armor needed, for player to drop when killed.
 *   armor_removetime - (Default 2min) Time before armor is removed from map (unless round ends).
 *
 *
 * Requires : AMXX 1.60
 * Modules : Engine, FakeMeta
 * Tested : Win32 (Linux untested)
 *
 * Author:  OneEyed
 * Version: 1.1
 *
 * Thanks : ccnncc99, sXy-Schreck, phear of rice, and Aunt Friggin' Connie, 
 *   For helping me test and fix this plugin!
 *
 *
 * - Change Log:
 *  -v1.1 
 *  - Fixed to work on AMXX 1.60
 *  - Added "Armor Drop" CVAR for queries to pick up.
 */
#include <amxmodx>
#include <engine>
#include <fakemeta>
//---------------These values are default, they are added to the CVAR's---------------------
//---------------Change if you want these to be defaulted to the CVAR on SERVER RESTART-----
//----------------------------------------------------------------------
//This is percentage, if its 25, only 25% of dropped armor will be given.
#define ARMOR_TAX "50"
//----------------------------------------------------------------------
// MAX armor allowed, default = 100 (Set higher, if you want players to go over 100 armor.)
#define MAXARMOR "100"
//----------------------------------------------------------------------
// Minimum armor needed for armor to drop when player dies.
#define MINARMOR "35"
//----------------------------------------------------------------------
// Time before Armor is removed from the map in seconds (unless round ends) default=2mins
#define REMOVE_TIME "180"
//----------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------
//-----------------------------------DO NOT EDIT BELOW THIS LINE-----------------------------------------------
//-------------------------------------------------------------------------------------------------------------
#define KEVLAR   1
#define VESTHELM  2
#define ARMORTYPE_OFFSET 112
#define TITLE "Armor Drop"
#define VERSION "1.0"
#define AUTHOR "OneEyed"
new g_ArmorType[33], Float:g_ArmorAmount[33], fArmor[33]
//Change this if you want a custom kevlar model
new const armormodel[] = "models/new/w_kevlar.mdl"
new const armorsound[] = "items/tr_kevlar.wav"
new Float:multiplier
//-------------------------------------------------------------------------------------------------------------
public plugin_precache()
{
 
precache_model(armormodel)
 
precache_sound(armorsound)
 
}
//-------------------------------------------------------------------------------------------------------------
public plugin_init() {
 
register_plugin(TITLEVERSIONAUTHOR)
 
register_cvar(TITLE,VERSION,FCVAR_SERVER)
 
 if(!
cvar_exists("armor_pct"))
  
register_cvar("armor_pct",ARMOR_TAX)
 if(!
cvar_exists("armor_max"))
  
register_cvar("armor_max",MINARMOR)
 if(!
cvar_exists("armor_min"))
  
register_cvar("armor_min",MINARMOR)
 if(!
cvar_exists("armor_removetime"))
  
register_cvar("armor_removetime",REMOVE_TIME)
  
 
register_touch("FakeArmor","player","grabArmor")
 
 
register_event("DeathMsg","createArmor","a")
 
register_event"SendAudio""EndRound""a""2=%!MRAD_terwin""2=%!MRAD_ctwin""2=%!MRAD_rounddraw" )
}
//-------------------------------------------------------------------------------------------------------------
//-----------Delayed it to be right at the end, (doesnt work if i try to erase it on Round Start)--------------
public EndRound()
 
set_task(5.0,"removeArmor",1111)
public 
removeArmor() {
 new 
tempid = -1
 
while ( ( tempid find_ent_by_class(tempid"FakeArmor") ) > 0)
  if(
is_valid_ent(tempid)) {
   
remove_entity(tempid)
   
remove_task(tempid)
  }
 return 
PLUGIN_CONTINUE
}
//-------------------------------------------------------------------------------------------------------------
// Set task to this to remove the armor after specified amount of time. (armor_removetime)
public removeThisArmor(id)
 if(
is_valid_ent(id))
  
remove_entity(id)
//-------------------------------------------------------------------------------------------------------------
public grabArmor(pToucherpTouched) {
 if(
is_user_alive(pTouched) && is_user_connected(pTouched) && entity_get_float(pTouched,EV_FL_armorvalue) < float(get_cvar_num("armor_max"))) {
  new 
owner entity_get_int(pToucherEV_INT_iuser1)
  if(
is_valid_ent(fArmor[owner])) {
   
get_armor_values(pTouched)
   
multiplier float(get_cvar_num("armor_pct")) * 0.01
   
   
//Retrieve armor values left on the dropped kevlar
   
new armortype entity_get_int(fArmor[owner], EV_INT_iuser3)
   new 
armoramt entity_get_int(fArmor[owner], EV_INT_iuser4)
   
   
//Set armor accordingly to how player has theirs, and what type they grab.
   
if(g_ArmorType[pTouched] == 0)
   {
    
csset_user_armor(pTouchedarmoramt*multiplier, (armortype==1?KEVLAR:VESTHELM))
    
emit_sound(pTouchedCHAN_ITEMarmorsound1.0ATTN_NORM0PITCH_NORM
   }
   else if(
g_ArmorType[pTouched] == && armortype == 1)
   { 
    
csset_user_armor(pTouchedentity_get_float(pTouched,EV_FL_armorvalue)+(armoramt*multiplier), KEVLAR)
    
emit_sound(pTouchedCHAN_ITEMarmorsound1.0ATTN_NORM0PITCH_NORM
   }
   else if((
g_ArmorType[pTouched] == && armortype == 2) || g_ArmorType[pTouched] == 2
   {
    
csset_user_armor(pTouchedentity_get_float(pTouched,EV_FL_armorvalue)+(armoramt*multiplier), VESTHELM)
    
emit_sound(pTouchedCHAN_ITEMarmorsound1.0ATTN_NORM0PITCH_NORM
   }   
   
// If their armor goes over MAXARMOR set it to MAXARMOR
   
if(entity_get_float(pTouched,EV_FL_armorvalue) > float(get_cvar_num("armor_max")))
    
entity_set_float(pTouched,EV_FL_armorvaluefloat(get_cvar_num("armor_max")))
   
g_ArmorType[pTouched] = armortype
   remove_entity
(fArmor[owner])
   
remove_task(fArmor[owner])
  }
 }
 return 
PLUGIN_HANDLED
}
//-------------------------------------------------------------------------------------------------------------
public createArmor(id) {
 new 
victim read_data(2//grab user ID who died
 
 
get_armor_values(victim)
 
 if(
g_ArmorType[victim] <= || g_ArmorAmount[victim] <= float(get_cvar_num("armor_min")))
  return 
PLUGIN_CONTINUE
 
new origin[3]
 new 
Float:fOrigin[3]
 
get_user_origin(victim,origin)
 for(new 
a=0;a<3;a++)
  
fOrigin[a]=float(origin[a])
 
fArmor[victim] = create_entity("info_target")
 if(
fArmor[victim]) {
  
entity_set_string(fArmor[victim],EV_SZ_classname,"FakeArmor")
  
entity_set_model(fArmor[victim], armormodel)
  
  new 
Float:MinBox[3]
  new 
Float:MaxBox[3]
  
MinBox[0] = -6.0
  MinBox
[1] = -8.0
  MinBox
[2] = -1.5
  MaxBox
[0] = 6.0
  MaxBox
[1] = 8.0
  MaxBox
[2] = 1.5
  
  entity_set_vector
(fArmor[victim], EV_VEC_minsMinBox)
  
entity_set_vector(fArmor[victim], EV_VEC_maxsMaxBox)
  
  
entity_set_int(fArmor[victim], EV_INT_solidSOLID_BBOX
  
entity_set_int(fArmor[victim], EV_INT_movetypeMOVETYPE_TOSS)
  
  
// Sets iuser1 to victim ID
  
entity_set_int(fArmor[victim], EV_INT_iuser1victim)
  
// Sets iuser3 to Armor Type (kevlar of vest+helm)
  
entity_set_int(fArmor[victim], EV_INT_iuser3g_ArmorType[victim])
  
// Sets iuser4 to Armor Value (amount victim had when he died)
  
entity_set_int(fArmor[victim], EV_INT_iuser4floatround(g_ArmorAmount[victim]))
  
entity_set_origin(fArmor[victim], fOrigin)
  
set_task(float(get_cvar_num("armor_removetime")),"removeThisArmor",fArmor[victim])
 }
 return 
PLUGIN_HANDLED
}
//-------------------------------------------------------------------------------------------------------------
public get_armor_values(id) {
 if(
entity_get_float(id,EV_FL_armorvalue) <= 0.0)
  
g_ArmorType[id] = 0
 
else {
  
g_ArmorAmount[id] = entity_get_float(id,EV_FL_armorvalue)
  
g_ArmorType[id] = get_pdata_int(id,ARMORTYPE_OFFSET)
 } 
}
//-------------------------------------------------------------------------------------------------------------
//Cstrike.inc has this function, but its broken, so i made my own that works =).
public csset_user_armor(idFloat:amounttype) {
 
entity_set_float(id,EV_FL_armorvalueamount)
 
set_pdata_int(id,ARMORTYPE_OFFSET,type
}
//------------------------------------------------------------------------------------------------------------- 

Last edited by ConnorMcLeod; 11-08-2007 at 18:02.
ConnorMcLeod is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-08-2007 , 13:40   Re: Armor drop plug-in problem.
Reply With Quote #8

emit_sound(id, CHAN_ITEM, "items/ammopickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
[ --<-@ ] Black Rose is offline
sQn
Member
Join Date: May 2007
Location: Poland, FtF Server :)
Old 11-08-2007 , 15:13   Re: Armor drop plug-in problem.
Reply With Quote #9

This doesn't work.I don't listen sound.
__________________

80.52.244.150:27016
sQn is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-08-2007 , 18:01   Re: Armor drop plug-in problem.
Reply With Quote #10

You're right !
I've just change armorsound to be a constant, also removed sound/ from the path that was the error.
Please test again.

Last edited by ConnorMcLeod; 11-08-2007 at 18:04.
ConnorMcLeod is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode