Raised This Month: $51 Target: $400
 12% 

m_iClip1 resets after reload? Single shot plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kashinoda
Member
Join Date: Dec 2017
Old 06-09-2019 , 16:01   m_iClip1 resets after reload? Single shot plugin
Reply With Quote #1

I have a simple plugin that gives everyone an AK with a magazine size of 1, however after the first shot and reload it resets to 30.

Any ideas what I need to change?

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <smlib>

public void OnPluginStart()
{
    
RegAdminCmd("t"CMD_WPADMFLAG_GENERIC"");
}

public 
Action CMD_WP(int clientint args)
{
    for (
int iClient 1iClient <= MaxClientsiClient++)
    {
        if (
IsClientConnected(iClient) && IsClientInGame(iClient))
        {
            for (
int iSlot 0iSlot 2iSlot++)
            {
                
int iEntity;
                while ((
iEntity GetPlayerWeaponSlot(iClientiSlot)) != -1)
                {
                    
RemovePlayerItem(iClientiEntity);
                    
AcceptEntityInput(iEntity"Kill");
                }
            }

            
GivePlayerItem(iClient"weapon_ak47"0);
            
SetEntProp(iClientProp_Data"m_ArmorValue"1001);
 
            
int item GetPlayerWeaponSlot(iClient0);
            
SetEntProp(itemProp_Send"m_iClip1"1); 
        }
    }

__________________
Kashinoda is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 06-09-2019 , 18:58   Re: m_iClip1 resets after reload? Single shot plugin
Reply With Quote #2

If you want a single bullet without a possible reload you can do this:

PHP Code:
SetEntProp(itemProp_Send"m_iClip2"0); 
If you want to reload into 1 bullet as well you can set this:

PHP Code:
SetEntProp(itemProp_Send"m_iClip2"1); 
If you want to reload more times except for 1 you can consistently set the weapons secondary clip to 1 on a timer.
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Kashinoda
Member
Join Date: Dec 2017
Old 06-09-2019 , 22:10   Re: m_iClip1 resets after reload? Single shot plugin
Reply With Quote #3

I thought m_iClip2 was for secondary guns specifically? I've tried it and it didn't seem to do anything. Unless I'm missing something.

I've made it work using a different approach, might be overly complicated. When client makes a gun selection:

PHP Code:
if (iOneTapEnabled == 1)
{
    
Client_GiveWeaponAndAmmo(iClientsWeapons[iSelectedWeapon][0], _0_1);

When 'weapon_fire' is hooked:

PHP Code:
public void EventOTap(Event event, const char[] namebool dontBroadcast)
{
    if (
iOneTapEnabled == 1)
    {
        
int iUserID GetEventInt(event"userid");
        
int iClient GetClientOfUserId(iUserID);        
        
CreateTimer(0.2GiveAmmoiClient);       
    }
}

public 
Action GiveAmmo(Handle timerany client)
{      
    for (
int iSlot 0iSlot 2iSlot++)
    {
        
int iEntity;
        if ((
iEntity GetPlayerWeaponSlot(clientiSlot)) != -1)
        {
            
char sWeapon[64];
            
GetEntityClassname(iEntitysWeaponsizeof(sWeapon));   
            
Client_SetWeaponPlayerAmmo(clientsWeapon1);
            
Client_SetWeaponClipAmmo(clientsWeapon0);
        }
    }

__________________

Last edited by Kashinoda; 06-09-2019 at 22:11.
Kashinoda 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 14:09.


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