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

Give reward if the player has tag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 06-15-2020 , 21:40   Give reward if the player has tag
Reply With Quote #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(PLUGINVERSIONAUTHOR)

         
register_clcmd("say /get""block_use")
    
used_command TrieCreate()
}

public 
block_use(id
{
         for (new 
0sizeof(REWARD_TAGS); i++)
         {
             
get_user_name(idg_user_name[id], 31)
                  
get_user_authid(idg_user_authid[id], charsmax(g_user_authid[]))
     
                  if(
TrieKeyExists(used_commandg_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(idzp_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_commandg_user_authid[id], 1)
                                    return 
PLUGIN_HANDLED
                           
}
                  if(
access(idVIP_ONE) || access(idVIP_TWO) || access(idVIP_THREE))
                 {
                                    
zp_ammopacks_set(idzp_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_commandg_user_authid[id], 1)    
                     return 
PLUGIN_HANDLED
                 
}
                 else
                 {
                     
zp_ammopacks_set(idzp_ammopacks_get(id) + 10)
                                    
printf(id, DEFAULT, "^x04 ZP | ^x01You have just received 10 ammo packs, get another in next map.")
                
TrieSetCell(used_commandg_user_authid[id], 1)
                return 
PLUGIN_HANDLED
                 
}
             }
    }
    
    return 
PLUGIN_HANDLED
}  

public 
plugin_end()
{
         
TrieDestroy(used_command)


stock printf(idcolor, const msg[], any:...) 
{   
         static 
Buffer[192], MsgSayTextMsgTeamInfoTeam[32]
    
         if(!
MsgSayText
    {       
                  
MsgTeamInfo get_user_msgid("TeamInfo")       
                  
MsgSayText get_user_msgid("SayText")      
         }
        
         
vformat(Buffer[1], charsmax(Buffer) - 1msg4)
    
         static const 
Teams[2][10] = 
    {
                  
"TERRORIST",
                  
"CT"
         
}

         switch (
color
    {       
                  case DEFAULT: 
        {           
                           
Buffer[0] = 0x01
                           printf_do
(idid id 33BufferMsgSayText)
                  }       
                  case 
GREEN
        {           
                           
Buffer[0] = 0x04            
                           printf_do
(idid id 33BufferMsgSayText)           
                  }       
                  case 
GRAY
        {          
                           
Buffer[0] = 0x03           
                           printf_do
(id33BufferMsgSayText)           
                  }       
                  case 
REDBLUE
        {           
                           
Buffer[0] = 0x03          
                           
if (id
            {              
                                    if (
get_user_team(idTeamcharsmax(Team)) == color
                     {                   
                                             
printf_do(ididBufferMsgSayText)                    
                                     }
                                    else 
                     {                  
                                             
printf_do(ididTeams[color-1], MsgTeamInfo)                   
                                             
printf_do(ididBufferMsgSayText)                    
                                             
printf_do(ididTeamMsgTeamInfo)
                }
                           }
                           else 
                 {           
                                    static 
Num         
                                    get_players
(TeamNum"e"Teams[color-1])
                
                                    if (
Num
                     {                    
                                             
printf_do(idTeam[0], BufferMsgSayText)
                                    }
                                    else 
                     {                  
                                             
get_players(TeamNum"h");
                    
                                             if (!
Num
                    {                       
                                                      return                       
                                              }
                    
                                             
Num Team[0]                  
                                             
get_user_team(NumTeamcharsmax(Team))
                    
                                             
printf_do(NumNumTeams[color-1], MsgTeamInfo)       
                                             
printf_do(idNumBufferMsgSayText)        
                                             
printf_do(NumNumTeamMsgTeamInfo)                   
                                    }               
                           }           
                  }       
         }
}

printf_do(idsender, const data[], MsgID
{   
         
message_begin(id MSG_ONE_UNRELIABLE MSG_BROADCASTMsgID_id)         
         
write_byte(sender)        
         
write_string(data)         
         
message_end()   

wicho is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 06-16-2020 , 03:26   Re: Give reward if the player has tag
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> #define printf client_print_color #define PLUGIN "Rewards" #define VERSION "1.0" #define AUTHOR "kha" native zp_ammopacks_set(id, ammopacks) native zp_ammopacks_get(id) new static DEFAULT = 1 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[MAX_PLAYERS+1][32] new g_user_authid[MAX_PLAYERS+1][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 client_authorized(id)     get_user_authid(id, g_user_authid[id], charsmax(g_user_authid[])); public block_use(id){     if(TrieKeyExists(used_command, g_user_authid[id])){         printf(id, DEFAULT, "^x04 ZP | ^x01This command can only be used once time per map!")         return PLUGIN_HANDLED;     }         new much = 10;     if(access(id, VIP_ONE) || access(id, VIP_TWO) || access(id, VIP_THREE))         much = 20;             else {         get_user_name(id, g_user_name[id], charsmax(g_user_name[]));         for (new i = 0; i < sizeof(REWARD_TAGS); i++){             if(containi(g_user_name[id], REWARD_TAGS[i][TAG_NAME]) != -1){                 much = REWARD_TAGS[i][TAG_REWARD];                 break;             }         }     }         zp_ammopacks_set(id, zp_ammopacks_get(id) + much);     printf(id, DEFAULT, "^x04 ZP | ^x01You have just received %d ammo packs, get another in next map.", much);     TrieSetCell(used_command, g_user_authid[id], DEFAULT);     return PLUGIN_HANDLED; }
__________________
Relaxing is offline
Reply



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 10:45.


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