Raised This Month: $ Target: $400
 0% 

[Req]Money Reward


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Adryyy
Member
Join Date: Oct 2011
Old 01-10-2020 , 13:12   Re: [Req]Money Reward
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
The plugin above won't work after mapchange or if the player was kicked or disconnected for a short time.

Use this:

PHP Code:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <nvault>

#if !defined client_disconnected
    #define client_disconnected client_disconnect
#endif

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32
#endif

#if !defined MAX_NAME_LENGTH
    
const MAX_NAME_LENGTH 32
#endif

#if !defined MAX_AUTHID_LENGTH
    
const MAX_AUTHID_LENGTH 64
#endif

const MAX_NUM_LENGTH 8
const Float:TIME_FREQ 60.0

// Reset the player's time if he isn't in the server longer than this many seconds
const Float:MAX_OUT_TIME 300.0

enum _
:TimeRewards Minutes[MAX_NUM_LENGTH], XP }

// Add as many rewards as you like in this list
new const g_eTimeRewards[][TimeRewards] =
{
    
/* "<minutes required>" <money reward> */
    
"20"16000 }
}

new 
Trie:g_tTimeRewards
new g_szAuthId[MAX_PLAYERS 1][MAX_AUTHID_LENGTH], g_iPlayedTime[MAX_PLAYERS 1], g_iVault

public plugin_init()
{
    
register_plugin("Simple Time Rewards""1.0""OciXCrom")
    
g_iVault nvault_open("CRXSimpleTimeRewards")
    
g_tTimeRewards TrieCreate()

    for(new 
isizeof(g_eTimeRewards); i++)
    {
        
TrieSetCell(g_tTimeRewardsg_eTimeRewards[i][Minutes], g_eTimeRewards[i][XP])
    }

    
CC_SetPrefix("&x04[Time Rewards]")
}

public 
plugin_end()
{
    
nvault_close(g_iVault)
    
TrieDestroy(g_tTimeRewards)
}

public 
client_connect(id)
{
    new 
szPlayedTime[MAX_NUM_LENGTH], iTimeStamp
    get_user_authid
(idg_szAuthId[id], charsmax(g_szAuthId[]))
    
nvault_lookup(g_iVaultg_szAuthId[id], szPlayedTimecharsmax(szPlayedTime), iTimeStamp)

    
g_iPlayedTime[id] = get_systime() - iTimeStamp MAX_OUT_TIME str_to_num(szPlayedTime)
    
set_task(TIME_FREQ"increase_played_time"id, .flags "b")
}

public 
client_disconnected(id)
{
    new 
szPlayedTime[MAX_NUM_LENGTH]
    
num_to_str(g_iPlayedTime[id], szPlayedTimecharsmax(szPlayedTime))
    
nvault_set(g_iVaultg_szAuthId[id], szPlayedTime)
    
remove_task(id)
}

public 
increase_played_time(id)
{
    new 
szPlayedTime[MAX_NUM_LENGTH], iMoney
    num_to_str
(++g_iPlayedTime[id], szPlayedTimecharsmax(szPlayedTime))

    if(
TrieGetCell(g_tTimeRewardsszPlayedTimeiMoney))
    {
        new 
szName[MAX_NAME_LENGTH]
        
get_user_name(idszNamecharsmax(szName))
        
CC_SendMessage(0"&x03%s &x01received &x04%i$ for playing &x04%i &x01minutes."szNameiMoneyg_iPlayedTime[id])
        
cs_set_user_money(idcs_get_user_money(id) + iMoney)
    }

why will not work? if i use that plugin from 4 years and i don't have problems?
your code is too useless...you call some things for nothing, why to don't save the trees?

Last edited by Adryyy; 01-10-2020 at 13:13. Reason: filters...
Adryyy is offline
Send a message via Yahoo to Adryyy Send a message via Skype™ to Adryyy
 


Thread Tools
Display Modes

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 01:31.


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