AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [HELP] Infinite ammo? (https://forums.alliedmods.net/showthread.php?t=307941)

kratoss1812 05-31-2018 14:08

[HELP] Infinite ammo?
 
I need help for infinite ammo. I want to make a module for R1ko VIP sistem
Code:

public void OnPluginStart()
{
        HookEvent("weapon_fire", ClientWeaponReload);
}

public Action ClientWeaponReload(Handle event, const char[] name, bool bIsVIP)
{
        int iClient = GetClientOfUserId(GetEventInt(event, "userid"));
       
        int weapon = GetEntPropEnt(iClient, Prop_Data, "m_hActiveWeapon");
        char classname[32];
        GetEdictClassname(weapon, classname, sizeof(classname));

        if(IsPlayerAlive(iClient) && bIsVIP &&  VIP_IsClientFeatureUse(iClient, BULLETS))
        {
                if(weapon > 0 && (weapon == GetPlayerWeaponSlot(iClient, CS_SLOT_PRIMARY) || weapon == GetPlayerWeaponSlot(iClient, CS_SLOT_SECONDARY)))
                {
                        if (StrContains(classname, "weapon_", false))
                        {
                                SetEntProp(weapon, Prop_Send, "m_iClip1", 32);
                                SetEntProp(weapon, Prop_Send, "m_iClip2", 32);       
                        }
                }
        }
}

This What I tryed, but I failed, can anyone help me, please?

Code:

        int weapon = GetEntPropEnt(iClient, Prop_Data, "m_hActiveWeapon");
Is this right?

Code:

if (StrContains(classname, "weapon_", false))
Here I tryed to give infinite ammo just for weapons, without bugs like infinte nades, defuses, c4s etc

Psyk0tik 05-31-2018 14:20

Re: [HELP] Infinite ammo?
 
Not sure if it'll help but you may want to make sure that the StrContains doesn't return -1.

Code:

if (StrContains(classname, "weapon_", false) != -1)

kratoss1812 05-31-2018 14:47

Re: [HELP] Infinite ammo?
 
Quote:

Originally Posted by Crasher_3637 (Post 2594688)
Not sure if it'll help but you may want to make sure that the StrContains doesn't return -1.

Code:

if (StrContains(classname, "weapon_", false) != -1)

it was not that

MasterMind420 05-31-2018 14:53

Re: [HELP] Infinite ammo?
 
Weapon fire is unreliable for this. What u want to do is use a repeating timer or ongameframe. Check the clip and the reserve ammo. When clip reaches 1 and reserve reaches 0 reload the reserve and or clip as well. What game is this for?

kratoss1812 05-31-2018 14:56

Re: [HELP] Infinite ammo?
 
Quote:

Originally Posted by MasterMind420 (Post 2594698)
Weapon fire is unreliable for this. What u want to do is use a repeating timer or ongameframe. Check the clip and the reserve ammo. When clip reaches 1 and reserve reaches 0 reload the reserve and or clip as well.

so.. I should do this?
Code:

public void OnGameFrame()
{
        CreateTimer(1.0, Bullets);
}

or
Code:

public void OnGameFrame()
{
        code
}


MasterMind420 05-31-2018 15:03

Re: [HELP] Infinite ammo?
 
Quote:

Originally Posted by kratoss1812 (Post 2594699)
so.. I should do this?
Code:

public void OnGameFrame()
{
        CreateTimer(1.0, Bullets);
}

or
Code:

public void OnGameFrame()
{
        code
}


Use just ongameframe...if it doesnt work with your code i'll see about modifying it. But there could be several problems with your code...especially making sure the vip bools are working correctly. Printtochat in a few parts of your code just to see how far it gets before it breaks, if thats the case

kratoss1812 05-31-2018 15:21

Re: [HELP] Infinite ammo?
 
Quote:

Originally Posted by MasterMind420 (Post 2594701)
Use just ongameframe...if it doesnt work with your code i'll see about modifying it. But there could be several problems with your code...especially making sure the vip bools are working correctly. Printtochat in a few parts of your code just to see how far it gets before it breaks, if thats the case

I will try, thank you

Santi. 06-11-2018 23:26

Re: [HELP] Infinite ammo?
 
Idk the game you're working for but CS:GO has the event "EventWeaponFire".. So you can hook it, get the weapon he's firing and give to it clip+1 or +3 if the weapon is on burst mode.

Events here: https://wiki.alliedmods.net/Counter-...fensive_Events.

mug1wara 06-12-2018 05:33

Re: [HELP] Infinite ammo?
 
Why not FakeClientCommand(iClient, "sv_infinite_ammo 1"); I don't see why you shouldn't use it.

Papero 06-12-2018 06:04

Re: [HELP] Infinite ammo?
 
Quote:

Originally Posted by mug1wara (Post 2596493)
Why not FakeClientCommand(iClient, "sv_infinite_ammo 1"); I don't see why you shouldn't use it.

Is it possible to send console commands with FakeClientCommand and also cheats flagged cmds without sv_cheats 1? also that is a server replied cvar not client.


All times are GMT -4. The time now is 16:17.

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