Post by ShaunCraft15 on Dec 26, 2021 16:51:44 GMT
Hello EveryOne This is my plugin i made this it's so easy
it if any one use "say /lucky" will be randomly if lucky or unlucky
Lucky: Win AP
Unlucky: Lose AP
i Fix Some Bugs in my plugin if any player have 0 ap and he lose ap
Here My Code And Sorry For My bad english:
i update my code now!!
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
//Use // If u Don't Use Zombie Plague 5.0
//#define ZP50
#if defined ZP50
#include <zp50_ammopacks>
#include <zp50_colorchat>
#else
#define PREFIX "^x01[^x04ZP^x01] "
#include <zombieplague>
#endif
#define PLUGIN "Lucky System Like [SG] (SilentGamerz) (Test)"
#define VERSION "1.0Beta"
#define AUTHOR "ShaunCraft"
new Lucky[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /lucky", "lucky")
}
public lucky(id)
{
if(Lucky[id])
{
#if defined ZP50
zp_colored_print(id, "Try ^04Again ^01After Map ^03Changes ^01!!!")
#else
zp_color_print(id, "Try ^04Again ^01After Map ^03Changes ^01!!!")
#endif
}
else
{
new WinOrLose = random(2)
new LoseAP = random_num(12, 22)
new WinAP = random_num(21, 33)
switch(WinOrLose)
{
case 1:
{
SetAmmoPacks(id, LoseAP, 2)
//This is To Remove AmmoPacks down To 0 And Set Only 0
if(GetCurrentAmmoPacks(id) <= 0 ) RemoveNegativeAP(id) //If Any Player Have 0 And Lose down to 0 as example -6 AmmoPacks
}
case 2: SetAmmoPacks(id, WinAP, 1)
}
Lucky[id] = true
}
}
//This is Again By Me
GetCurrentAmmoPacks(id)
{
#if defined ZP50
zp_ammopacks_get(id)
#else
zp_get_user_ammo_packs(id)
#endif
return 1
}
//This is Again And Again By Me
RemoveNegativeAP(id)
{
#if defined ZP50
zp_ammopacks_set(id, 0)
#else
zp_set_user_ammo_packs(id, 0)
#endif
return 1
}
//This is By Me :)
SetAmmoPacks(id, ap, type)
{
#if defined ZP50
new currentap = zp_ammopacks_get(id)
#else
new currentap = zp_get_user_ammo_packs(id)
#endif
switch(type)
{
case 1:
{
#if defined ZP50
zp_ammopacks_set(id, currentap + ap)
zp_colored_print(id, "You Are ^04Lucky ^01By Wining ^04%i ^01AmmoPacks!!!", ap)
#else
zp_set_user_ammo_packs(id, currentap + ap)
zp_color_print(id, "You Are ^04Lucky ^01By Wining ^04%i ^01AmmoPacks!!!", ap)
#endif
}
case 2:
{
#if defined ZP50
zp_ammopacks_set(id, currentap - ap)
zp_colored_print(id, "You Are Not ^03Lucky ^01By Losing ^04%i ^01AmmoPacks!!!", ap)
#else
zp_set_user_ammo_packs(id, currentap - ap)
zp_color_print(id, "You Are Not ^03Lucky ^01By Losing ^04%i ^01AmmoPacks!!!", ap)
#endif
}
}
return 1
}
//Color Chat From Zombie Plague 5.0 For Zombie Plague 4.3
stock zp_color_print(target, const message[], any:...)
{
static buffer[512], msg_SayText = 0
if( !msg_SayText ) msg_SayText = get_user_msgid("SayText")
// Send to everyone
if (!target)
{
static player, maxplayers, argscount
maxplayers = get_maxplayers()
argscount = numargs()
for (player = 1; player <= maxplayers; player++)
{
// Not connected
if (!is_user_connected(player))
continue;
// Remember changed arguments
static arg_index, changed_args[20], changedcount // [20] = max LANG_PLAYER occurencies
changedcount = 0
// Replace LANG_PLAYER with player id
for (arg_index = 2; arg_index < argscount; arg_index++)
{
if (getarg(arg_index) == LANG_PLAYER && arg_index + 1 < argscount)
{
// Check if next param string is a registered language translation
static lang_key[64], arg_subindex
arg_subindex = 0
while ((lang_key[arg_subindex] = getarg(arg_index + 1, arg_subindex++))) { /* keep looping */ }
if (GetLangTransKey(lang_key) != TransKey_Bad)
{
setarg(arg_index, 0, player)
changed_args[changedcount++] = arg_index
arg_index++ // skip next argument since we know it's a translation key
}
}
}
// Format message for player (+add ZP prefix)
vformat(buffer, charsmax(buffer), message, 3)
format(buffer, charsmax(buffer), "%s%s", PREFIX , buffer)
// Send it
message_begin(MSG_ONE_UNRELIABLE, msg_SayText, _, player)
write_byte(player)
write_string(buffer)
message_end()
// Replace back player id's with LANG_PLAYER
for (arg_index = 0; arg_index < changedcount; arg_index++)
setarg(changed_args[arg_index], 0, LANG_PLAYER)
}
}
// Send to specific target
else
{
// Format message for player (+add ZP prefix)
vformat(buffer, charsmax(buffer), message, 3)
format(buffer, charsmax(buffer), "%s%s", PREFIX , buffer)
// Send it
message_begin(MSG_ONE, msg_SayText, _, target)
write_byte(target)
write_string(buffer)
message_end()
}
}