AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [Req]Money Reward (https://forums.alliedmods.net/showthread.php?t=320771)

KillerElite 01-08-2020 10:54

[Req]Money Reward
 
Hi! I want a plugin which gives you $16.000 after 20 minutes played.

SuperrioR 01-09-2020 13:57

Re: [Req]Money Reward
 
Try this:
Plugin edited by L E V I N

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <cstrike>

const MONEY 16000
const TIME 20

new g_iUserTime33 ];

#define TASK_pentru 06091993

public plugin_init() {
    
register_plugin
    
(
    .
plugin_name="FCS TIME REWARD?"    ,
    .
version="0.1"        ,
    .
author="ASKHANARU"//lev edits
    
)
    
    
// Add your code here...
    
    
set_task1.0"task_PTRFunctions"TASK_pentru__"b");
}

public 
client_putinserver(id)    g_iUserTime[id]=0
public client_disconnect(id)    g_iUserTime[id]=0

public task_PTRFunctions( )
{
    static 
iPlayers32 ],iPlayersNum;
    
get_playersiPlayersiPlayersNum"ch" );
    if( !
iPlayersNum )    return;

    static 
idi;
    for( 
0iPlayersNumi++ )
    {
        
id iPlayers];

        
g_iUserTimeid ]++;
        static 
iTime;
        
iTime TIME;

        if( 
g_iUserTimeid ] >= iTime 60 )
        {
            
g_iUserTimeid ] -= iTime 60;

            
cs_set_user_money(id,cs_get_user_money(id)+MONEY,1)
        }
    }



OciXCrom 01-09-2020 14:13

Re: [Req]Money Reward
 
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)
    }



Adryyy 01-10-2020 13:12

Re: [Req]Money Reward
 
Quote:

Originally Posted by OciXCrom (Post 2679550)
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?

OciXCrom 01-10-2020 13:33

Re: [Req]Money Reward
 
Quote:

Originally Posted by Adryyy (Post 2679672)
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?

I think I made my self clear why and when it won't work. Are you not able to read?
I don't see you explaining which part of my code is useless, so if you're gonna scream at someone, at least give reasons for it.

Quote:

why to don't save the trees?
This is not up to me. Many trees are being cut down and burned due to forest fires and... well people. You get the point.

https://i.pinimg.com/originals/31/08...32538d0c9e.jpg

Napoleon_be 01-14-2020 12:43

Re: [Req]Money Reward
 
Quote:

Originally Posted by OciXCrom (Post 2679675)
I think I made my self clear why and when it won't work. Are you not able to read?
I don't see you explaining which part of my code is useless, so if you're gonna scream at someone, at least give reasons for it.



This is not up to me. Many trees are being cut down and burned due to forest fires and... well people. You get the point.

https://i.pinimg.com/originals/31/08...32538d0c9e.jpg

Lolled so hard at this one

Shitty 01-14-2020 21:27

Re: [Req]Money Reward
 
Just give the guy what he need and dont make a memes in his thread. Also, I laughed at this sentence
Quote:

Originally Posted by Adryyy (Post 2679672)
why to don't save the trees?


OciXCrom 01-15-2020 07:42

Re: [Req]Money Reward
 
I already did, plus included the meme so he gets double benefits. Unfortunately, he doesn't seem interested in checking the thread he posted.


All times are GMT -4. The time now is 17:37.

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