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

[Plugin] Terrorist got deagle with 1 bullet


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
secret304
New Member
Join Date: Feb 2019
Old 02-18-2019 , 09:56   [Plugin] Terrorist got deagle with 1 bullet
Reply With Quote #1

Hi, please help with the plugin. I need a plugin that gives a terrorist a random weapon with 1 bullet every 30 seconds for a mod. Deadly run, and if there is a weapon in the terrorist’s hand, it simply disappears when a new one is given in 30 seconds (sorry for my English)
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>

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

public plugin_init()
{
	register_plugin("RandWeapon T", "0.7", "Noovey")

	register_event("HLTV", "evNewRound", "a", "1=0", "2=0")
}

public evNewRound()
	set_task(20.0, "myfunc", id + 1010, _, _, "b")
}

public randPlayer()
{
 	new players[32], count
	get_players(players, count, "ae", "TERRORIST")

	new player = players[random(count)]

	if(!player)
		return PLUGIN_HANDLED

	randWeapon(player)

	return PLUGIN_HANDLED
}

public randWeapon(id)
{
	new weapon
	switch(random_num(1, 6))
	{
		case 1 : weapon = fm_give_item(id, "weapon_scout")
		case 2 : weapon = fm_give_item(id, "weapon_m4a1")
		case 3 : weapon = fm_give_item(id, "weapon_ak47")
		case 4 : weapon = fm_give_item(id, "weapon_deagle")
		case 5 : weapon = fm_give_item(id, "weapon_galil")
		case 6 : weapon = fm_give_item(id, "weapon_awp")
		case 6 : weapon = fm_give_item(id, "weapon_famas")
	}

	fm_set_weapon_ammo(weapon, 1)

	return PLUGIN_HANDLED
}

stock fm_give_item(index, const item[]) 
{
	if (!equal(item, "weapon_", 7) || equal(item, "ammo_", 5) || equal(item, "item_", 5))
		return 0

	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
	if (!pev_valid(ent))
		return 0

	new Float:origin[3]
	pev(index, pev_origin, origin)
	set_pev(ent, pev_origin, origin)
	set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
	dllfunc(DLLFunc_Spawn, ent)

	new save = pev(ent, pev_solid)
	dllfunc(DLLFunc_Touch, ent, index)
	if (pev(ent, pev_solid) != save)
		return ent

	engfunc(EngFunc_RemoveEntity, ent)

	return -1
}

stock fm_set_weapon_ammo(entity, amount) 
        set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS)
secret304 is offline
Reply


Thread Tools
Display Modes

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 08:21.


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