Raised This Month: $ Target: $400
 0% 

[CS:GO] Remove Ammo?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bally
Senior Member
Join Date: Aug 2015
Old 09-20-2015 , 16:09   [CS:GO] Remove Ammo?
Reply With Quote #1

Hi guys, I've been looking into netprops but uh I can't seem to figure this out. I want to remove someone's clip and reserve ammo on a weapon, but I've been only lucky with the clip.. Any thoughts/help? Thanks

My code:

PHP Code:
stock SetReserveAmmo(clientammo)
{
    new 
weapon GetEntPropEnt(clientProp_Data"m_hActiveWeapon");
    if(
weapon 1) return;
    
    new 
ammotype GetEntProp(weaponProp_Send"m_iPrimaryAmmoType");
    if(
ammotype == -1) return;
    
    
SetEntProp(clientProp_Send"m_iAmmo"ammo_ammotype);
    
PrintToChatAll("ammo: %i"ammo); // it does parse 0...


public 
Action:SomeFunction(clientargs)
{
new 
Primary GetPlayerWeaponSlot(client0);
//new Secondary = GetPlayerWeaponSlot(client, 1);
new String:pc[32] = "null";
//new String:sc[32] = "null";
GetEdictClassname(Primarypcsizeof(pc));
Client_SetWeaponClipAmmo(clientpc00);
SetReserveAmmo(client0);

AND yes I also tried smlibs one, again doesn't seem to work!! welpp
__________________
Perhaps my lack of faith was my undoing,

Last edited by bally; 09-20-2015 at 16:13.
bally is offline
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 09-21-2015 , 04:08   Re: [CS:GO] Remove Ammo?
Reply With Quote #2

From dr.api's drapi_ammo.

PHP Code:
/***********************************************************/
/**************** SET AMMO PLAYER WEAPON *******************/
/***********************************************************/
stock int Client_SetWeaponPlayerAmmoEx(int clientint weaponint primaryAmmo=-1int secondaryAmmo=-1)
{
    
int offset_ammo FindDataMapOffs(client"m_iAmmo");

    if (
primaryAmmo != -1
    {
        
int offset offset_ammo + (Weapon_GetPrimaryAmmoType(weapon) * 4);
        
SetEntData(clientoffsetprimaryAmmo4true);
    }

    if (
secondaryAmmo != -1
    {
        
int offset offset_ammo + (Weapon_GetSecondaryAmmoType(weapon) * 4);
        
SetEntData(clientoffsetsecondaryAmmo4true);
    }
}

/***********************************************************/
/***************** GET PRIMARY AMMO TYPE *******************/
/***********************************************************/
stock int Weapon_GetPrimaryAmmoType(int weapon)
{
    return 
GetEntProp(weaponProp_Data"m_iPrimaryAmmoType");
}

/***********************************************************/
/**************** GET SECONDARY AMMO TYPE ******************/
/***********************************************************/
stock int Weapon_GetSecondaryAmmoType(int weapon)
{
    return 
GetEntProp(weaponProp_Data"m_iSecondaryAmmoType");
}

/***********************************************************/
/******************** GET PRIMARY AMMO *********************/
/***********************************************************/
stock int GetPrimaryAmmo(int clientint weapon)
{
    
int ammotype Weapon_GetPrimaryAmmoType(weapon);
    if(
ammotype == -1
    {
        return -
1;
    }
    
    return 
GetEntProp(clientProp_Send"m_iAmmo"_ammotype);

lingzhidiyu is offline
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 09-21-2015 , 04:17   Re: [CS:GO] Remove Ammo?
Reply With Quote #3

And your stock is fine.
lingzhidiyu is offline
bally
Senior Member
Join Date: Aug 2015
Old 09-21-2015 , 09:05   Re: [CS:GO] Remove Ammo?
Reply With Quote #4

I'm calling the function like this Client_SetWeaponPlayerAmmoEx(client, Primary, 0, 0);
It's not working unfortunately.

Primary = GetPlayerWeaponSlot(client, 0);

I also get a big bunch of errors such as:

L 09/21/2015 - 15:07:24: [SM] Native "GetEntProp" reported: Property "m_iPrimaryAmmoType" not found (entity 0/worldspawn)
L 09/21/2015 - 15:07:24: [SM] Displaying call stack trace for plugin "remove_ammo.smx":
L 09/21/2015 - 15:07:24: [SM] [0] Line 73, D:\csgos\csgo\addons\sourcemod\scripting\remo ve_ammo.sp::Weapon_GetPrimaryAmmoType()
L 09/21/2015 - 15:07:24: [SM] [1] Line 57, D:\csgos\csgo\addons\sourcemod\scripting\remo ve_ammo.sp::Client_SetWeaponPlayerAmmoEx()
L 09/21/2015 - 15:07:24: [SM] [2] Line 48, D:\csgos\csgo\addons\sourcemod\scripting\remo ve_ammo.sp::RemoveAmmoBro()
L 09/21/2015 - 15:07:24: [SM] [3] Line 41, D:\csgos\csgo\addons\sourcemod\scripting\remo ve_ammo.sp::SpawnEvent()
L 09/21/2015 - 15:07:24: [SM] Native "GetEntProp" reported: Property "m_iPrimaryAmmoType" not found (entity 0/worldspawn)
L 09/21/2015 - 15:07:24: [SM] Displaying call stack trace for plugin "remove_ammo.smx":
__________________
Perhaps my lack of faith was my undoing,

Last edited by bally; 09-21-2015 at 10:07.
bally is offline
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 09-21-2015 , 10:05   Re: [CS:GO] Remove Ammo?
Reply With Quote #5

PHP Code:
public Action:SomeFunction(clientargs)
{
    new 
Primary GetPlayerWeaponSlot(clientCS_SLOT_PRIMARY);
    new 
Secondary GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY);

    if (
Primary != -1)
    {
        
Weapon_SetPrimaryClip(Primary0);
        
SetReserveAmmo(clientPrimary0);
    }

    if (
Secondary != -1)
    {
        
Weapon_SetPrimaryClip(Secondary0);
        
SetReserveAmmo(clientSecondary0);
    }
}  

stock SetReserveAmmo(clientweaponammo)
{
    new 
ammotype GetEntProp(weaponProp_Send"m_iPrimaryAmmoType");
    if(
ammotype == -1) return;
    
    
SetEntProp(clientProp_Send"m_iAmmo"ammo_ammotype);


Last edited by lingzhidiyu; 09-21-2015 at 10:07.
lingzhidiyu is offline
bally
Senior Member
Join Date: Aug 2015
Old 09-21-2015 , 10:20   Re: [CS:GO] Remove Ammo?
Reply With Quote #6

Quote:
Originally Posted by lingzhidiyu View Post
PHP Code:
public Action:SomeFunction(clientargs)
{
    new 
Primary GetPlayerWeaponSlot(clientCS_SLOT_PRIMARY);
    new 
Secondary GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY);

    if (
Primary != -1)
    {
        
Weapon_SetPrimaryClip(Primary0);
        
SetReserveAmmo(clientPrimary0);
    }

    if (
Secondary != -1)
    {
        
Weapon_SetPrimaryClip(Secondary0);
        
SetReserveAmmo(clientSecondary0);
    }
}  

stock SetReserveAmmo(clientweaponammo)
{
    new 
ammotype GetEntProp(weaponProp_Send"m_iPrimaryAmmoType");
    if(
ammotype == -1) return;
    
    
SetEntProp(clientProp_Send"m_iAmmo"ammo_ammotype);

Hi, thanks for your fast reply, however It seems it doesn't completely work, the clip on the weapon is emptied, however the ammo that's left is not.. any help? so it seems that only the smlib function works :/
__________________
Perhaps my lack of faith was my undoing,

Last edited by bally; 09-21-2015 at 10:24.
bally is offline
Graffiti
AlliedModders Donor
Join Date: Aug 2013
Location: Russia
Old 09-21-2015 , 10:35   Re: [CS:GO] Remove Ammo?
Reply With Quote #7

SetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
SetEntProp(weapon, Prop_Send, "m_iClip1", 0);
__________________
Russian TTT CSGO

Graffiti is offline
bally
Senior Member
Join Date: Aug 2015
Old 09-21-2015 , 11:28   Re: [CS:GO] Remove Ammo?
Reply With Quote #8

Quote:
Originally Posted by Graffiti View Post
SetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
SetEntProp(weapon, Prop_Send, "m_iClip1", 0);
thats it sir! thanks ^^
__________________
Perhaps my lack of faith was my undoing,
bally 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 18:49.


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