[ZP] Donate Ammo Packs

Descarcari de pluginuri si discutii despre acestea.

Moderators: Moderatori ajutători, Scripteri TheXForce

Post Reply
User avatar
Rainq
Fost administrator
Fost administrator
Posts: 381
Joined: Mon Jan 18, 2021 7:25 am
Status: Citesc forumul TheXForce.RO...!
Detinator Steam: Da
SteamID: mrainq
Gaming experience: Nu spun..
Reputatie: Fost administrator
Nume anterior: Light
Fost detinator zm.thexforce.ro
Fost detinator dr.thexforce.ro
Location: Bucureşti
Has thanked: 2 times
Been thanked: 1 time
Contact:

[ZP] Donate Ammo Packs

Post by Rainq »

Descriere: Pluginul simplu de /donate

Descarcare:

Code: Select all

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <zombieplague>

#define PLUGIN "[ZP] Donate Ammo Packs"
#define VERSION "1.0"
#define AUTHOR "r1laX , PomanoB"

new g_UserTotalAmmo[33]
new g_CvarAllowDonate
new SayText


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	g_CvarAllowDonate = register_cvar("zp_stats_allow_donate", "1")
	
	register_clcmd("say", "handleSay")
	register_clcmd("say_team", "handleSay")
	
	register_event("HLTV", "RoundStart", "a", "1=0", "2=0")

	SayText = get_user_msgid("SayText")

}

public RoundStart()
{
	if (get_pcvar_num(g_CvarAllowDonate))
		set_task(2.2, "MsgOnRoundStart")
		
}

public MsgOnRoundStart()
{
	if(get_pcvar_num(g_CvarAllowDonate))
		client_printcolor(0, "!g[ZP] !yTo donate others Ammo Packs, type !t/donate")
		
}

public handleSay(id)
{
	new args[64]
	
	read_args(args, charsmax(args))
	remove_quotes(args)
	
	new arg1[16]
	new arg2[32]
	
	argbreak(args, arg1, charsmax(arg1), arg2, charsmax(arg2))
	if (get_pcvar_num(g_CvarAllowDonate) && equal(arg1,"/donate", 7))
		donate(id, arg2)
	
}

public donate(id, arg[])
{
	new to[32], count[10]
	argbreak(arg, to, 31, count, 9)
	
	if (!to[0] || !count[0])
	{
		client_printcolor(id, "!g[ZP] !yUsage: say /donate <name> <amount>")
		return
	}
	new ammo_sender = zp_get_user_ammo_packs(id)
	new ammo
	if (equal(count, "all"))
		ammo = ammo_sender
	else
		ammo = str_to_num(count)
	if (ammo <= 0)
	{
		client_printcolor(id, "!g[ZP] !yWrong ammo quantity!")
		return
	}
	ammo_sender -= ammo
	if (ammo_sender < 0)
	{
		ammo+=ammo_sender
		ammo_sender = 0
		
	}
	new reciever = cmd_target(id, to, (CMDTARGET_ALLOW_SELF))
	if (!reciever || reciever == id)
	{
		client_printcolor(id, "!g[ZP] !yPlayer !t%s !yhas not been found on the server!", to)
		return
	}
	
	zp_set_user_ammo_packs(reciever, zp_get_user_ammo_packs(reciever) + ammo)
	g_UserTotalAmmo[reciever] += ammo
	zp_set_user_ammo_packs(id, ammo_sender)
	new aName[32], vName[32]
	
	get_user_name(id, aName, 31)
	get_user_name(reciever, vName, 31)
	
	static str_donated [ 16 ];
	AddCommas ( ammo, str_donated, charsmax ( str_donated ) );
	
	client_printcolor ( 0, "!g[ZP] !yPlayer !t%s !ydonated !g%s !yammo packs to !t%s", aName, str_donated, vName );
	
}

stock client_printcolor(const id, const input[], any:...)
{
	new count = 1, players[32]
	static msg[191]
	vformat(msg, 190, input, 3)
	
	replace_all(msg, 190, "!g", "^4") // Green Color
	replace_all(msg, 190, "!y", "^1") // Default Color
	replace_all(msg, 190, "!t", "^3") // Team Color
	
	if (id) players[0] = id; else get_players(players, count, "ch") 
	{
		for ( new i = 0; i < count; i++ )
		{
			if ( is_user_connected(players[i]) )
			{
				message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i])
				write_byte(players[i]);
				write_string(msg);
				message_end();
			}
		}
	}
}

AddCommas( iNum , szOutput[] , iLen ){
   static szTmp[ 15 ] , iOutputPos , iNumPos , iNumLen;
   szTmp[0]='^0',iOutputPos=iNumPos=iNumLen=0;
   if ( iNum < 0 ){
      szOutput[ iOutputPos++ ] = '-';
      iNum = abs( iNum );
   }
   iNumLen = num_to_str( iNum , szTmp , charsmax( szTmp ) );
   if ( iNumLen <= 3 )iOutputPos += copy( szOutput[ iOutputPos ] , iLen , szTmp );

   else{
      while ( ( iNumPos < iNumLen ) && ( iOutputPos < iLen ) ){
         szOutput[ iOutputPos++ ] = szTmp[ iNumPos++ ];
         if( ( iNumLen - iNumPos ) && !( ( iNumLen - iNumPos ) % 3 ) )szOutput[ iOutputPos++ ] = ',';
      }
      szOutput[ iOutputPos ] = EOS;
   }
   return iOutputPos;
}
Nume: Donate Ammo Packs
Versiune: 1.0
Link oficial: https://forums.alliedmods.net/showthread.php?t=124078

Instalare:
1. Fisierul zombimod_donate.sma il puneti in addons/amxmodx/scripting
2. Fisierul zombimod_donate.amxx il puneti in addons/amxmodx/plugins
3. Intrati in fisierul addons/amxmodx/configs/plugins.ini si adaugati la urma:

Code: Select all

zombimod_donate.amxx
4. Alti pasi necesari....

Cvar-uri (se adauga in fisierul amxmodx\configs\amxx.cfg):

Code: Select all

zp_stats_allow_donate 1 activare / 0 dezactivare
Imagini: -
Image
Post Reply

Return to “Pluginuri”