Raised This Month: $ Target: $400
 0% 

Remove ammo problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xcalibar
Junior Member
Join Date: Apr 2006
Old 04-11-2006 , 16:23  
Reply With Quote #1

@VEN appologies, i didn't notice your reply before i posted, thanks for your input you where right i was doing it all wrong


Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <engine> #include <cstrike> #define PLUGIN "Test rip ammo" #define VERSION "1.1 rc5" #define AUTHOR "TEST" #define free 10 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     set_task(float(free),"list_users",_,_,_,"b") } public list_users(id){ new Player[32], PlayerCount get_players(Player, PlayerCount, "ach") for (new i = 0; i <= PlayerCount; i++) { if ( is_user_connected(Player[i]) ) { new clip, ammo new weapon = get_user_weapon(Player[i], clip, ammo), wpn[32],iWPNidx = -1 cs_set_user_bpammo(Player[i], weapon, 0) get_weaponname(weapon,wpn,31) while ((iWPNidx = find_ent_by_class(iWPNidx, wpn)) != 0)         {             if (Player[i] == entity_get_edict(iWPNidx, EV_ENT_owner))             {                 cs_set_weapon_ammo(iWPNidx,0)             }         } //Display a hud message telling them they have no ammo for there current weapon set_hudmessage(255, 255, 255, 0.11, 0.31, 0, 6.0, 5.0) show_hudmessage(Player[i], "Oh no! The grim reaper has killed all your ammo ;P") } } }


thanks for pointing me in the right direction

Xcalibar
xcalibar is offline
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 01-23-2010 , 16:54   Re: Remove ammo problem
Reply With Quote #2

And to resurect this from ancient history , i cant get the code above to work if i want to remove ammo from clip in specific weapon, also i tried like this but i failed.

PHP Code:
        new clip,ammo,weapon get_user_weapon(idclipammo
        
cs_set_user_bpammo(idweapon0

        new 
weapon_id find_ent_by_owner(-1"weapon_scout"id); 
        if(
weapon_id
        {  
                         
cs_set_weapon_ammo(weapon_id,0
        } 
__________________

Jack86 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-23-2010 , 18:09   Re: Remove ammo problem
Reply With Quote #3

Code:
#define PISTOL_WEAPONS_BIT (1<<CSW_GLOCK18|1<<CSW_USP|1<<CSW_DEAGLE|1<<CSW_P228|1<<CSW_FIVESEVEN|1<<CSW_ELITE) #define SHOTGUN_WEAPONS_BIT (1<<CSW_M3|1<<CSW_XM1014) #define SUBMACHINE_WEAPONS_BIT (1<<CSW_TMP|1<<CSW_MAC10|1<<CSW_MP5NAVY|1<<CSW_UMP45|1<<CSW_P90) #define RIFLE_WEAPONS_BIT (1<<CSW_FAMAS|1<<CSW_GALIL|1<<CSW_AK47|1<<CSW_SCOUT|1<<CSW_M4A1|1<<CSW_SG550|1<<CSW_SG552|1<<CSW_AUG|1<<CSW_AWP|1<<CSW_G3SG1) #define MACHINE_WEAPONS_BIT (1<<CSW_M249) #define GRENADE_WEAPONS_BIT (1<<CSW_HEGRENADE|1<<CSW_FLASHBANG|1<<CSW_SMOKEGRENADE) #define PRIMARY_WEAPONS_BIT (SHOTGUN_WEAPONS_BIT|SUBMACHINE_WEAPONS_BIT|RIFLE_WEAPONS_BIT|MACHINE_WEAPONS_BIT) #define SECONDARY_WEAPONS_BIT   (PISTOL_WEAPONS_BIT) const m_rpgPlayerItems = 367; const m_pNext = 42; const m_iId = 43; cs_set_user_ammo( const iPlayer, const iWeaponID, const iClipAmmo, const iBackPackAmmo ) {     new iSlot;     if( ( 1 << iWeaponID ) & PRIMARY_WEAPONS_BIT )         iSlot = 1;     else if( ( 1 << iWeaponID ) & SECONDARY_WEAPONS_BIT )         iSlot = 2;     else if( ( 1 << iWeaponID ) & GRENADE_WEAPONS_BIT )     {         cs_set_user_bpammo( iPlayer, iWeaponID, iBackPackAmmo );         return 1;     }     else         return 0;         cs_set_user_bpammo( iPlayer, iWeaponID, iBackPackAmmo );         new iEntity = get_pdata_cbase( iPlayer, m_rpgPlayerItems+iSlot );     if( iEntity > 0 )     {         new iEntityWeaponID;         do         {             iEntityWeaponID = get_pdata_int( iEntity, m_iId, 4 );             if( iEntityWeaponID == iWeaponID )             {                 cs_set_weapon_ammo( iEntity, iClipAmmo );                 return 2;             }         }         while( ( iEntity = get_pdata_cbase( iEntity, m_pNext, 4 ) ) > 0 );     }         return 1; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 01-23-2010 at 23:30.
Exolent[jNr] is offline
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 01-23-2010 , 21:57   Re: Remove ammo problem
Reply With Quote #4

Thx for this, although

#define GRENADE_WEAPONS_BIT
is empty i dont need it. I still cant get 0 ammo in clip, am i doing something wrong in finding weapon index or there is some other issue ?

Also i have a problem with some other part of code unrelated to this, maybe someone could help, this compiles fine but it crashes server with stack error

PHP Code:
public playerDeath()
{
    new 
id read_data(2)
    new 
cause[32]
    
read_data(4,cause,31)
    
    if(
containi(cause,"worldspawn")!= -|| containi(cause,"triger_hurt")!= -1)
    {
        
spawn(id)
    
set_task(0.5,"spawn_again",id)
    }
}

public 
spawn_again(id)
{
    
spawn(id)
    
strip_user_weapons(id)
    
give_item(id,"weapon_knife")

__________________


Last edited by Jack86; 01-23-2010 at 22:07.
Jack86 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-23-2010 , 23:31   Re: Remove ammo problem
Reply With Quote #5

I forgot to finish GRENADE_WEAPONS_BIT before I posted lol.
If you set 0 clip ammo with more backpack ammo, it may automatically make the player reload.

Also, if you are making this for Counter-Strike, you can use this to respawn a player:
Code:
ExecuteHamB( Ham_CS_RoundRespawn, iPlayer );
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 01-26-2010 , 20:53   Re: Remove ammo problem
Reply With Quote #6

I think u didnt understood me, want to give a weapon to player that will be without any ammo in clip or in backpack, and whatever i do there's always default amount of ammo in clip for that weapon.

EDIT: I solved this, if anyone else wants this,the method i used is from gungame with get_weapon_ent stock
__________________


Last edited by Jack86; 01-28-2010 at 08:09.
Jack86 is offline
Reply



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 16:38.


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