AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Unlimited-Clips (https://forums.alliedmods.net/showthread.php?t=94589)

-Acid- 06-12-2009 23:04

Unlimited-Clips
 
Okay i was looking for a plugin that gives unlimited clips on connect to a player, didnt find out so i decided to create one, but i wanna make sure if the code is good, and well it work at all?? so heres my code......
PHP Code:

/* This plugin will set user clip to unlimited on connect to server. */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "Unlimited-Clips"
#define VERSION "1.0"
#define AUTHOR "-Acid-"

#if cellbits == 32
const OFFSET_CLIPAMMO 51
#else
const OFFSET_CLIPAMMO 65
#endif
const OFFSET_LINUX_WEAPONS 4


new const MAXCLIP[] = { -113, -11017, -1303013020253035251220,
10301008303020273030, -150 }

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
}
public 
message_cur_weapon(msg_idmsg_destmsg_entity)
{
    
    
    
    if (!
is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
        return;
    
    static 
weaponclip
    weapon 
get_msg_arg_int(2
    
clip get_msg_arg_int(3
    
    
    if (
MAXCLIP[weapon] > 2
    {
        
set_msg_arg_int(3get_msg_argtype(3), MAXCLIP[weapon])
        
        if (
clip 2
        {
            
            static 
wname[32], weapon_ent
            get_weaponname
(weaponwnamesizeof wname 1)
            
weapon_ent fm_find_ent_by_owner(-1wnamemsg_entity)
            
            
            
fm_set_weapon_ammo(weapon_entMAXCLIP[weapon])
        }
    }
}

stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) {}
    
    return 
entity;
}


stock fm_set_weapon_ammo(entityamount)
{
    
set_pdata_int(entityOFFSET_CLIPAMMOamountOFFSET_LINUX_WEAPONS);


So what do u think?? Well it work??.
Thanks in advance!!!:)

Bugsy 06-13-2009 17:12

Re: Unlimited-Clips
 
Here you go

I added 1 to the max clip ammo just so the clip ammo will always appear full instead of -1. ie. Using glock should always say 12 but without +1 it will always say 11. I'm not sure if the +1 will cause errors or not, it didn't while I tested. If you don't care about the clip ammo always being -1 of max then just remove the +1.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "Unlimited Clip Ammo"
#define VERSION "1.0"
#define AUTHOR "bugsy"

#if cellbits == 32
const OFFSET_CLIPAMMO 51
#else
const OFFSET_CLIPAMMO 65
#endif

const OFFSET_LINUX_WEAPONS 4

new const g_MaxClipAmmo[] = 
{
    
0,
    
13//CSW_P228
    
0,
    
10//CSW_SCOUT
    
0,  //CSW_HEGRENADE
    
7,  //CSW_XM1014
    
0,  //CSW_C4
    
30,//CSW_MAC10
    
30//CSW_AUG
    
0,  //CSW_SMOKEGRENADE
    
15,//CSW_ELITE
    
20,//CSW_FIVESEVEN
    
25,//CSW_UMP45
    
30//CSW_SG550
    
35//CSW_GALIL
    
25//CSW_FAMAS
    
12,//CSW_USP
    
20,//CSW_GLOCK18
    
10//CSW_AWP
    
30,//CSW_MP5NAVY
    
100,//CSW_M249
    
8,  //CSW_M3
    
30//CSW_M4A1
    
30,//CSW_TMP
    
20//CSW_G3SG1
    
0,  //CSW_FLASHBANG
    
7,  //CSW_DEAGLE
    
30//CSW_SG552
    
30//CSW_AK47
    
0,  //CSW_KNIFE
    
50//CSW_P90
}

public 
plugin_init() 
{
    
register_pluginPLUGIN VERSION AUTHOR );
    
register_event"CurWeapon" "fw_CurWeapon" "b" "1=1" );
}

public 
fw_CurWeaponid )
{
    static 
szWeapon[32], iWeaponiWeaponEntity;
    
    
iWeapon read_data);
    
    
get_weaponnameiWeapon szWeapon sizeof szWeapon );
    
iWeaponEntity fm_find_ent_by_owner( -szWeapon id );
    
    
fm_set_weapon_ammoiWeaponEntity g_MaxClipAmmoiWeapon ] + );
}

public 
fm_find_ent_by_ownerentity , const classname[] , owner )
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) {}
    
    return 
entity;
}

public 
fm_set_weapon_ammo(entityamount)
{
    
set_pdata_int(entityOFFSET_CLIPAMMOamountOFFSET_LINUX_WEAPONS);



-Acid- 06-13-2009 18:10

Re: Unlimited-Clips
 
Okay cool, is this still my original code, u just fix some errors?

Bugsy 06-13-2009 18:13

Re: Unlimited-Clips
 
I used your fm functions so I wouldn't have to dig through my inc's. Everything else is new

-Acid- 06-13-2009 18:18

Re: Unlimited-Clips
 
Okay so u wouldent mind if i post this in new submission with my name on it?

Bugsy 06-13-2009 18:28

Re: Unlimited-Clips
 
I don't care, just give credit please. Are you sure this doesn't already exist?

http://forums.alliedmods.net/showthread.php?t=26991 ??

-Acid- 06-13-2009 18:54

Re: Unlimited-Clips
 
Yea but that one u need to be using amx_ammo <nick,#userid> <0|1>
everytime a player connects, and this one doesnt.


All times are GMT -4. The time now is 13:52.

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