Raised This Month: $ Target: $400
 0% 

transfer plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 19:54.


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