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

Clantag benefits


Post New Thread Reply   
 
Thread Tools Display Modes
Obyboby
Veteran Member
Join Date: Sep 2013
Old 09-13-2017 , 11:19   Re: Clantag benefits
Reply With Quote #31

Quote:
Originally Posted by sim242 View Post
Been looking for something to do at home when I'm bored. I can sort that for you when I get home ^^ I should be home around 5pm (for reference the current time for me is 1:12pm UK time).

If no one has sorted it by the time I'm home I'll get it done
Thanks dude!! Looking forward to it.
__________________
Obyboby is offline
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 09-13-2017 , 13:38   Re: Clantag benefits
Reply With Quote #32

PHP Code:
#include <sourcemod>    
#include <cstrike>     
#include <sdktools>   
#include <multicolors>   

#define PLUGIN_TAG "nudonudo"   

public void OnPluginStart()   
{   
    
HookEvent("round_start"Event_RoundStart);   
}   

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast)   
{   
    
//Ignore warmup   
    
if (GameRules_GetProp("m_bWarmupPeriod") == 1)   
        return;   
      
    new 
rounds
    
rounds CS_GetTeamScore(3) + CS_GetTeamScore(2);  

    
//If rounds are < than 2 return    
    
if (rounds 1)   
        return;   
           
    for (
int i 1<= MaxClientsi++)   
    if (
IsValidClient(i))   
        
CheckTag(i);   
}   

void CheckTag(int client)   
{     
    
//If clients team is T or CT
    
if (GetClientTeam(client) > 1)
    {
        
//Clear Variables   
        
char sTag[256];   
       
        
//Get Client Clan Tag   
        
CS_GetClientClanTag(clientsTagsizeof(sTag));
        
        
//If Client Clan Tag Contains input from PLUGIN_TAG    
        
if (StrEqual(sTagPLUGIN_TAG))   
        {   
            
SetEntProp(clientProp_Send"m_iAccount"GetClientCash(client) + 200);   
            
CPrintToChat(client"You got $100 bonus for using our clantag, thank you!");   
        }   
        else   
        {   
            
CPrintToChat(client"Use our tag nudonudo for an in-game bonus!");   
        }
    }
}   

int GetClientCash(int client)   
{   
    return 
GetEntProp(clientProp_Send"m_iAccount");   
}   

stock bool IsValidClient(int client)   
{   
    return (
<= client <= MaxClients && IsClientInGame(client));   

That'll sort spectators being included. As for your translations I see no reference to a translation file anywhere in the code so I don't understand what you mean with translations.
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
Obyboby
Veteran Member
Join Date: Sep 2013
Old 09-13-2017 , 14:01   Re: Clantag benefits
Reply With Quote #33

Quote:
Originally Posted by sim242 View Post
That'll sort spectators being included. As for your translations I see no reference to a translation file anywhere in the code so I don't understand what you mean with translations.

I included that on the script I compiled for my server.
Might as well include your update and then post it back including the translations

EDIT:

Ok, implemented your code. Thanks!

Here's the full code I'm currently using, which includes pretty much every update you guys posted here, and I included a simple translation file myself (thanks Papero for your help!)

Main code:

PHP Code:
#include <sourcemod> 
#include <cstrike>  
#include <sdktools>
#include <multicolors>

#define PLUGIN_TAG "nudonudo"

public void OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
    
LoadTranslations("ez_tagbenefits.phrases.txt"); 
}

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
//Ignore warmup   
    
if (GameRules_GetProp("m_bWarmupPeriod") == 1)   
        return;   
      
    new 
rounds
    
rounds CS_GetTeamScore(3) + CS_GetTeamScore(2);  

    
//If rounds are < than 2 return    
    
if (rounds 1)   
        return;   
           
    for (
int i 1<= MaxClientsi++)   
    if (
IsValidClient(i))   
        
CheckTag(i);  
}

void CheckTag(int client)
{
    
//If clients team is T or CT
    
if (GetClientTeam(client) > 1)
    {
        
//Clear Variables
        
char sTag[256];
    
        
//Get Client Clan Tag
        
CS_GetClientClanTag(clientsTagsizeof(sTag));
    
        
//If Client Clan Tag Contains input from PLUGIN_TAG 
        
if (StrEqual(sTagPLUGIN_TAG))
        {
            
SetEntProp(clientProp_Send"m_iAccount"GetClientCash(client) + 150);
            
CPrintToChat(client"%t""mex_1");
        }
        else
        {
            
CPrintToChat(client"%t""mex_2");
        }
    }
}

int GetClientCash(int client)
{
    return 
GetEntProp(clientProp_Send"m_iAccount");
}

stock bool IsValidClient(int client)
{
    return (
<= client <= MaxClients && IsClientInGame(client));

And the translation file:

PHP Code:
"Phrases"
{
"mex_1"
{
"en" "You got {Green}$150 bonus{Default} for using our clantag, thank you!"
"it" "Hai ricevuto {Green}$150{Default} di bonus per avere la nostra clantag, grazie!"
}
"mex_2"
{
"en" "Use our tag {Green}nudonudo{Default} for an in-game BONUS!"
"it" "Usa la tag {Green}nudonudo{Default} per un BONUS in-game!"
}


So yeah, I'm trying to figure out why, usually at the beginning of the map, the text is displayed in english (language I'm running CS:GO) and some other times I see it in italian lol.


TODO LIST:

(and I'd like to learn this on my own, but any other suggestion and help is always appreciated):

- CFG file to set bonus type (perhaps include other things other than a cash bonus? Armor, extra health, etc, but not really important, just an idea I got right now)
- CFG to toggle giving out bonus on first round for each side

Another bug we need to fix:

On team change (from T to CT or vice versa) the plugin will still display the message "you got blah blah bonus " etc etc, but the player doesn't get any bonus instead. It's just the message being displayed.
This should be fixed and we should make it possible to toggle the bonus on these rounds (first round for each side) and add it to the CFG.
Going to learn about CFG's right now :p

EDIT2: seems like there is an issue. The bonus is not awarded at the SECOND round. (third if warmup is included). It should only skip the FIRST round.
__________________

Last edited by Obyboby; 09-13-2017 at 20:59.
Obyboby is offline
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 09-14-2017 , 06:57   Re: Clantag benefits
Reply With Quote #34

Based on the code and the translation file I can't see any obvious reason you'd be seeing Italian instead of English.
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
Obyboby
Veteran Member
Join Date: Sep 2013
Old 09-14-2017 , 06:58   Re: Clantag benefits
Reply With Quote #35

Quote:
Originally Posted by sim242 View Post
Based on the code and the translation file I can't see any obvious reason you'd be seeing Italian instead of English.
It's probably just the server that had failed to detect my country and displayed the default message, then switched to my own lang when it was found. Nothing special.
We can safely work on the rest of the ToDo now
__________________
Obyboby is offline
Obyboby
Veteran Member
Join Date: Sep 2013
Old 09-17-2017 , 09:34   Re: Clantag benefits
Reply With Quote #36

Papero told me how to check for half time and skip the first round after warmup:

PHP Code:
#include <sourcemod> 
#include <cstrike>  
#include <sdktools>
#include <multicolors>

#define PLUGIN_TAG "nudonudo"

public void OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
    
LoadTranslations("ez_tagbenefits.phrases.txt"); 
}

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
//Ignore warmup   
    
if (GameRules_GetProp("m_bWarmupPeriod") == 1)   
        return;   
      
    new 
rounds
    
rounds CS_GetTeamScore(3) + CS_GetTeamScore(2);  

    
//If rounds are < then 2 return    
    
ConVar cv_MaxRounds FindConVar("mp_maxrounds");
    
int iHalfRound cv_MaxRounds.IntValue 1;
    if (
rounds 1)  
        return;   
    if (
iHalfRound == rounds)
        return;
        
    for (
int i 1<= MaxClientsi++)   
    if (
IsValidClient(i))   
        
CheckTag(i);  
}

void CheckTag(int client)
{
    
//If clients team is T or CT
    
if (GetClientTeam(client) > 1)
    {
        
//Clear Variables
        
char sTag[256];
    
        
//Get Client Clan Tag
        
CS_GetClientClanTag(clientsTagsizeof(sTag));
    
        
//If Client Clan Tag Contains input from PLUGIN_TAG 
        
if (StrEqual(sTagPLUGIN_TAG))
        {
            
SetEntProp(clientProp_Send"m_iAccount"GetClientCash(client) + 150);
            
CPrintToChat(client"%t""mex_1");
        }
        else
        {
            
CPrintToChat(client"%t""mex_2");
        }
    }
}

int GetClientCash(int client)
{
    return 
GetEntProp(clientProp_Send"m_iAccount");
}

stock bool IsValidClient(int client)
{
    return (
<= client <= MaxClients && IsClientInGame(client));


Only one issue.
After halftime, the bonus is not awarded, yeah, that's perfect, BUT the message "you got blah blah reward" is still being displayed. It's so annoying

How should I change my code to avoid that?
__________________
Obyboby 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 06:13.


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