Raised This Month: $32 Target: $400
 8% 

transfer plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
giumbalau
Member
Join Date: Jan 2021
Old 06-15-2021 , 14:46   transfer plugin
Reply With Quote #1

I was trying to limit the commands because the players are abusing of them but i am doing something wrong can anyone fix it ?

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike > 

new g_movelimit

public plugin_init()
{
       
register_plugin("Players transfer""1.9.0.5271""")

       
register_clcmd("say /spec","spec")
       
register_clcmd("say_team /spec","spec")
       
register_clcmd("say /ct","ct")
       
register_clcmd("say_team /ct","ct")
       
register_clcmd("say /t","t")
       
register_clcmd("say_team /t","t")

       
g_movelimit register_cvar("move_limit""3")
}
 
public 
spec(id)
{     
       if(
get_pcvar_num(g_movelimit))
       {
       
color_chat(id"^4%s^3 This command can be used only^4 3 times per map")
       return 
PLUGIN_HANDLED
       
}    
 
       
cs_set_user_team(id,CS_TEAM_SPECTATOR)

       if(
is_user_alive(id))
       
user_silentkill(id)

       return 
PLUGIN_HANDLED     
}

public 
ct(id)
{
       
cs_set_user_team(id,CS_TEAM_CT)
       
user_silentkill(id)

       return 
PLUGIN_HANDLED
}

public 
t(id)
{
       
cs_set_user_team(id,CS_TEAM_T)
       
user_silentkill(id)

       return 
PLUGIN_HANDLED
}

stock color_chat(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);
    
    
replace_all(msg190"!g""^4"); // Green Color
    
replace_all(msg190"!y""^1"); // Default Color
    
replace_all(msg190"!team""^3"); // Team Color
    
replace_all(msg190"!team2""^0"); // Team2 Color
        
    
if (idplayers[0] = id; else get_players(playerscount"ch");
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }

giumbalau is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 06-15-2021 , 14:53   Re: transfer plugin
Reply With Quote #2

In a very basic way you would do this, or you can save the amount of player team changes in a Trie that is cleared at every map change, good luck.

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike > 

new g_movelimit
new iTransferTimes[33]

public 
plugin_init()
{
       
register_plugin("Players transfer""1.9.0.5271""")

       
register_clcmd("say /spec","spec")
       
register_clcmd("say_team /spec","spec")
       
register_clcmd("say /ct","ct")
       
register_clcmd("say_team /ct","ct")
       
register_clcmd("say /t","t")
       
register_clcmd("say_team /t","t")

       
g_movelimit register_cvar("move_limit""3")
}

public 
client_connect(id)
{
        
iTransferTimes[id] = 0
}

public 
spec(id)
{     
        
iTransferTimes[id] += 1
       
if(iTransferTimes[id] >= get_pcvar_num(g_movelimit))
       {
        
color_chat(id"^4%s^3 This command can be used only^4 3 times per map")
        return 
PLUGIN_HANDLED
       
}    
 
       
cs_set_user_team(id,CS_TEAM_SPECTATOR)

       if(
is_user_alive(id))
       
user_silentkill(id)

       return 
PLUGIN_HANDLED     
}

public 
ct(id)
{
       
cs_set_user_team(id,CS_TEAM_CT)
       
user_silentkill(id)

       return 
PLUGIN_HANDLED
}

public 
t(id)
{
       
cs_set_user_team(id,CS_TEAM_T)
       
user_silentkill(id)

       return 
PLUGIN_HANDLED
}

stock color_chat(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);
    
    
replace_all(msg190"!g""^4"); // Green Color
    
replace_all(msg190"!y""^1"); // Default Color
    
replace_all(msg190"!team""^3"); // Team Color
    
replace_all(msg190"!team2""^0"); // Team2 Color
        
    
if (idplayers[0] = id; else get_players(playerscount"ch");
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 06-15-2021 at 14:54.
iceeedr is offline
Send a message via Skype™ to iceeedr
giumbalau
Member
Join Date: Jan 2021
Old 06-15-2021 , 15:11   Re: transfer plugin
Reply With Quote #3

Quote:
Originally Posted by iceeedr View Post
In a very basic way you would do this, or you can save the amount of player team changes in a Trie that is cleared at every map change, good luck.

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike > 

new g_movelimit
new iTransferTimes[33]

public 
plugin_init()
{
       
register_plugin("Players transfer""1.9.0.5271""")

       
register_clcmd("say /spec","spec")
       
register_clcmd("say_team /spec","spec")
       
register_clcmd("say /ct","ct")
       
register_clcmd("say_team /ct","ct")
       
register_clcmd("say /t","t")
       
register_clcmd("say_team /t","t")

       
g_movelimit register_cvar("move_limit""3")
}

public 
client_connect(id)
{
        
iTransferTimes[id] = 0
}

public 
spec(id)
{     
        
iTransferTimes[id] += 1
       
if(iTransferTimes[id] >= get_pcvar_num(g_movelimit))
       {
        
color_chat(id"^4%s^3 This command can be used only^4 3 times per map")
        return 
PLUGIN_HANDLED
       
}    
 
       
cs_set_user_team(id,CS_TEAM_SPECTATOR)

       if(
is_user_alive(id))
       
user_silentkill(id)

       return 
PLUGIN_HANDLED     
}

public 
ct(id)
{
       
cs_set_user_team(id,CS_TEAM_CT)
       
user_silentkill(id)

       return 
PLUGIN_HANDLED
}

public 
t(id)
{
       
cs_set_user_team(id,CS_TEAM_T)
       
user_silentkill(id)

       return 
PLUGIN_HANDLED
}

stock color_chat(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);
    
    
replace_all(msg190"!g""^4"); // Green Color
    
replace_all(msg190"!y""^1"); // Default Color
    
replace_all(msg190"!team""^3"); // Team Color
    
replace_all(msg190"!team2""^0"); // Team2 Color
        
    
if (idplayers[0] = id; else get_players(playerscount"ch");
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }

Thank you very much
giumbalau is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-15-2021 , 22:20   Re: transfer plugin
Reply With Quote #4

Here is an example that shows both the method iceeedr posted but also a method for limiting the frequency of use by forcing players to wait a specific amount of time between subsequent uses:

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_plugin("Limit Command Use Example""0.0""Author")
    
    
register_concmd("myTimeLimitedCommand""cmdLimitByTime")
    
register_concmd("myUseLimitCommandPerMap""cmdUseLimitPerMapCommand")
}


/*
*   Limit use by the time elapsed since last use
*/

new lastTimestamp[MAX_PLAYERS+1]

public 
cmdLimitByTime(id)
{
    new 
nowTimestamp get_systime()

    if( 
nowTimestamp lastTimestamp[id] > 60 )
    {
        
// 60 seconds has elapsed since last use
        
        /*
        *   Run Command Code Here
        */

        // Update the saved timestamp in lastTimestamp
        
lastTimestamp[id] = nowTimestamp
    
}
    else
    {
        
// 60 seconds has NOT yet elapsed since last use

        /*
        *   Notify user that they cannot use command until 60 seconds has elapsed since last use
        */
    
}
}


/*
*   Limit use by number of times command has been used on this map
*/

new useCount[MAX_PLAYERS+1]

public 
cmdUseLimitPerMapCommand(id)
{
    if( 
useCount[id] < )
    {
        
// Command has been used fewer than 3 times this map
        
        /*
        *   Run Command Code Here
        */
        
        // Increment the stored use count for this command
        
useCount[id]++
    }
    else
    {
        
// Command has already been used 3 times
        
        /*
        *   Notify user that they can no longer use this command on this map
        */
    
}

__________________
fysiks 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 12:22.


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