AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Touch armoury_entity (https://forums.alliedmods.net/showthread.php?t=177821)

wwzw 02-07-2012 06:08

Touch armoury_entity
 
I want to use the Touch armoury_entity to give players more weapons and grenades.
PHP Code:

RegisterHam(Ham_Touch,      "armoury_entity",   "Ham_Touch_entity_Pre",  0);
 
public 
Ham_Touch_entity_Pre(ient,id)
{
 if (
id || id max_player || (!is_user_alive(id)) || ient <= max_player || (!pev_valid(ient))) return HAM_IGNORED;
 static 
wname[64];
 
pev(ient,pev_model,wname,63)
//I would like to get more information:
//Weapon's ID, the number of bullets, the number of bullets in the clip within.
//The number of grenades (some maps a model there are three grenades).
//Body armor values
 


Please help me! Thanks!

ConnorMcLeod 02-07-2012 14:13

Re: Touch armoury_entity
 
armoury has always a max weapon clip, it's not like weaponbox.

You can retrieve weapon type using cs_get_armoury_type : http://www.amxmodx.org/funcwiki.php?go=func&id=1226

wwzw 02-07-2012 21:04

Re: Touch armoury_entity
 
cs_get_armoury_type can get the weapon's ID.
Armoury has always a max weapon clip.


Generally to the two cartridges? M3 in fy_iceworld to 24 bullets.
Map inside the grenade a model to the three hand grenades, some maps is one.

Also: If I use engfunc (EngFunc_RemoveEntity, ient).
The next round, these items will not happen again.

ConnorMcLeod 02-08-2012 01:15

Re: Touch armoury_entity
 
I think backpackammo is given when you pickup an armoury_entity but no number is stored into the armoury, whatever the map, when you pickup up an m3, same amount of clip and ammo are given.

Don't remove entities, set pev_effect to EF_NODRAW (that's what's happening when you pickup the weapon).

wwzw 02-08-2012 02:29

Re: Touch armoury_entity
 
Quote:

Originally Posted by ConnorMcLeod (Post 1646402)
I think backpackammo is given when you pickup an armoury_entity but no number is stored into the armoury, whatever the map, when you pickup up an m3, same amount of clip and ammo are given.

Don't remove entities, set pev_effect to EF_NODRAW (that's what's happening when you pickup the weapon).

Thank you very much!
I tested the code is successful:

PHP Code:

public Ham_Touch_entity_Pre(ent,id)
{
 if (
id || id max_player || (!is_user_alive(id)) || ent <= max_player || (!pev_valid(ent)))
  return 
HAM_IGNORED;
 if (
pev(ent,pev_effects) == EF_NODRAW) return HAM_IGNORED;
 new 
wid cs_get_armoury_type(ent);
 
 
//Give player weapon...
 
 
set_pev(ent,pev_effects,EF_NODRAW);
 return 
HAM_SUPERCEDE;
 



ConnorMcLeod 02-08-2012 02:45

Re: Touch armoury_entity
 
Btw, ent <= max_player check is not needed, you have registerer the armoury classname.

wwzw 02-08-2012 03:14

Re: Touch armoury_entity
 
Oh!I have learned.Thanks again!

wwzw 02-08-2012 03:41

Re: Touch armoury_entity
 
Continue to consult:
These two methods: Which one is better?
register_touch( "armoury_entity" , "player" , "fw_ArmouryTouch" );
RegisterHam(Ham_Touch, "armoury_entity", "Ham_Touch_entity_Pre", 0);
//register_forward(FM_Touch,"FM_Touch_hook") //In this way seems more trouble

About touch weaponbox (From: GHW_Weap_Pickup.sma)
How to find the weapon's id?(Only by model name?)
How to find the weapon's bpammo?


ConnorMcLeod 02-08-2012 10:38

Re: Touch armoury_entity
 
In this specific case i think it's the same, i would use ham.

engine way prevents you from checking entity touched in plugin, but as you only check for players, player range check (> 0 and < maxplayers) is enough.

Ef_Deas 07-25-2014 05:52

Re: Touch armoury_entity
 
I'm having trouble with setting nodraw effect

PHP Code:

public HAM_Armoury_Touch_Pre(iArmouryidUser)    // The function is called when user touches Armoury entity
{
    if(
is_user_alive(idUser)                                    // User should be alive
    
&& is_valid_ent(iArmoury)                                   // The entity should be valid,         
    
&& engfunc(EngFunc_EntIsOnFlooriArmoury)                  // lying on the ground
    
&& !(entity_get_int(iArmouryEV_INT_effects) & EF_NODRAW)) // and it shouldn't be picked up already
    
{    
        new 
iWeapon cs_get_armoury_type(iArmoury)             // Get the Weapon CSW_ id
        
give_user_weapon(idUseriWeapon)                       // give the weapon (my func)
        
entity_set_int(iArmouryEV_INT_effectsEF_NODRAW);    // Make it disappear until next round
      
        
say("Trace")                                            // Let's see if we got here
    
}


Using this code I pick up weapon with trace message. The armour entity disappears. Then I can throw the weapon away and pick up the original "invisible" weapon again normally, without trace message.
So how do I make it disappear until next round properly?


All times are GMT -4. The time now is 00:21.

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