Veteran Member
Join Date: Feb 2012
Location: GuateAmala
|
06-15-2020
, 21:40
Give reward if the player has tag
|
#1
|
Hi all, well what I want to do is that when a player has a special tag he will give him a reward but I only want it to work in regular players since I give the vip a reward separately, I have this code that when someone writes /get gets the reward, the problem is that when a player writes it and has the tag it gives the normal reward, I mean it gives the reward to the player who only has the name without tag, the vip reward works fine. These are the rewards that I give: 10 ammo packs to players who only have the name, 15 ammo packs to those who have the tag and 20 ammo packs to those who have the vip flag, as I said before I just want it to work in normal players, my question is why it doesn't work? Could someone tell me what is the problem? .. Thanks in advance
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <zp50_ammopacks>
#define PLUGIN "Rewards"
#define VERSION "1.0"
#define AUTHOR "kha"
enum
{
DEFAULT,
RED,
BLUE,
GRAY,
GREEN
}
new Trie:used_command
enum _:REWARD_TAGS_STRUCT
{
TAG_NAME[32],
TAG_REWARD
}
new const REWARD_TAGS[][REWARD_TAGS_STRUCT] =
{
/* TAG | REWARD */
{ "ZP*", 15 },
{ "ZP |", 15 },
{ "[ZP]", 15 },
{ "-ZP-", 15 },
{ "ZP #", 15 },
{ "|ZP|", 15 }
}
new g_user_name[33][32]
new g_user_authid[33][35]
#define VIP_ONE ADMIN_LEVEL_C
#define VIP_TWO ADMIN_LEVEL_H
#define VIP_THREE ADMIN_LEVEL_D
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /get", "block_use")
used_command = TrieCreate()
}
public block_use(id)
{
for (new i = 0; i < sizeof(REWARD_TAGS); i++)
{
get_user_name(id, g_user_name[id], 31)
get_user_authid(id, g_user_authid[id], charsmax(g_user_authid[]))
if(TrieKeyExists(used_command, g_user_authid[id]))
{
printf(id, DEFAULT, "^x04 ZP | ^x01This command can only be used once time per map!")
break
}
else
{
if(containi(g_user_name[id], REWARD_TAGS[i][TAG_NAME]) != -1)
{
zp_ammopacks_set(id, zp_ammopacks_get(id) + REWARD_TAGS[i][TAG_REWARD])
printf(id, DEFAULT, "^x04 ZP | ^x01You have just received %i ammo packs for having %s tag in your name.", REWARD_TAGS[i][TAG_REWARD], REWARD_TAGS[i][TAG_NAME])
TrieSetCell(used_command, g_user_authid[id], 1)
return PLUGIN_HANDLED
}
if(access(id, VIP_ONE) || access(id, VIP_TWO) || access(id, VIP_THREE))
{
zp_ammopacks_set(id, zp_ammopacks_get(id) + 20)
printf(id, DEFAULT, "^x04 ZP | ^x01You have just received 20 ammo packs for being^x04 VIP^x01, get another in next map.")
TrieSetCell(used_command, g_user_authid[id], 1)
return PLUGIN_HANDLED
}
else
{
zp_ammopacks_set(id, zp_ammopacks_get(id) + 10)
printf(id, DEFAULT, "^x04 ZP | ^x01You have just received 10 ammo packs, get another in next map.")
TrieSetCell(used_command, g_user_authid[id], 1)
return PLUGIN_HANDLED
}
}
}
return PLUGIN_HANDLED
}
public plugin_end()
{
TrieDestroy(used_command)
}
stock printf(id, color, const msg[], any:...)
{
static Buffer[192], MsgSayText, MsgTeamInfo, Team[32]
if(!MsgSayText)
{
MsgTeamInfo = get_user_msgid("TeamInfo")
MsgSayText = get_user_msgid("SayText")
}
vformat(Buffer[1], charsmax(Buffer) - 1, msg, 4)
static const Teams[2][10] =
{
"TERRORIST",
"CT"
}
switch (color)
{
case DEFAULT:
{
Buffer[0] = 0x01
printf_do(id, id ? id : 33, Buffer, MsgSayText)
}
case GREEN:
{
Buffer[0] = 0x04
printf_do(id, id ? id : 33, Buffer, MsgSayText)
}
case GRAY:
{
Buffer[0] = 0x03
printf_do(id, 33, Buffer, MsgSayText)
}
case RED, BLUE:
{
Buffer[0] = 0x03
if (id)
{
if (get_user_team(id, Team, charsmax(Team)) == color)
{
printf_do(id, id, Buffer, MsgSayText)
}
else
{
printf_do(id, id, Teams[color-1], MsgTeamInfo)
printf_do(id, id, Buffer, MsgSayText)
printf_do(id, id, Team, MsgTeamInfo)
}
}
else
{
static Num
get_players(Team, Num, "e", Teams[color-1])
if (Num)
{
printf_do(id, Team[0], Buffer, MsgSayText)
}
else
{
get_players(Team, Num, "h");
if (!Num)
{
return
}
Num = Team[0]
get_user_team(Num, Team, charsmax(Team))
printf_do(Num, Num, Teams[color-1], MsgTeamInfo)
printf_do(id, Num, Buffer, MsgSayText)
printf_do(Num, Num, Team, MsgTeamInfo)
}
}
}
}
}
printf_do(id, sender, const data[], MsgID)
{
message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, MsgID, _, id)
write_byte(sender)
write_string(data)
message_end()
}
|
|