AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Money Every 5 Minutes (https://forums.alliedmods.net/showthread.php?t=331843)

Ace67 04-09-2021 19:04

Money Every 5 Minutes
 
Hello, im currently searching a plugin for get money all 5 minutes ex:
You get money for every 5 minutes played.

SHIFT0 04-09-2021 19:15

Re: Money Every 5 Minutes
 
Look like u sharing every 1hour man, you can't wait ?

Ace67 04-10-2021 14:25

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by SHIFT0 (Post 2743610)
Look like u sharing every 1hour man, you can't wait ?

?

Celena Luna 04-13-2021 23:55

Re: Money Every 5 Minutes
 
[Global Timer]
- Everyone get money every 5 minutes
Spoiler


[Unique Timer]
- The player have to stay in server for 5 minutes to get money.
- Disconnect = reset timer
Spoiler


P/S: Please reply if it work or not

Ace67 04-14-2021 12:38

Re: Money Every 5 Minutes
 
Thanks works :D

Bugsy 04-14-2021 23:57

Re: Money Every 5 Minutes
 
@Celena Luna - You do not need to check is_user_connected() on players returned by get_players() as it only returns connected players. And you want to avoid calling the same native more than once when it's guaranteed to return the same value, in this case your two cs_get_user_team() calls are redundant. You should store the value in a variable and use that in your conditions, or do it as I have below. And this is more of a style thing, but IMO there's no sense in checking negative conditions to return or continue, just execute the applicable code when the condition is met, as I have below.

PHP Code:

//Global timer
if ( CS_TEAM_T <= cs_get_user_teamPlayerList] ) <= CS_TEAM_CT )
    
cs_set_user_money(PlayerList[i], cs_get_user_money(PlayerList[i]) + GIVE_AMOUNT)

//Unique timer
if ( CS_TEAM_T <= cs_get_user_teamid ) <= CS_TEAM_CT )
    
cs_set_user_money(idcs_get_user_money(id) + GIVE_AMOUNT


Celena Luna 04-15-2021 03:11

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by Bugsy (Post 2744099)
@Celena Luna - You do not need to check is_user_connected() on players returned by get_players() as it only returns connected players. And you want to avoid calling the same native more than once when it's guaranteed to return the same value, in this case your two cs_get_user_team() calls are redundant. You should store the value in a variable and use that in your conditions, or do it as I have below.

I was wrote in hurry so I forget about these.

Ace67 04-15-2021 10:52

Re: Money Every 5 Minutes
 
Edited

Ace67 04-18-2021 00:17

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by Celena Luna (Post 2744114)
I was wrote in hurry so I forget about these.

Sup, can you edit for max money 16k ?

Bugsy 04-18-2021 00:20

Re: Money Every 5 Minutes
 
Replace:

cs_get_user_money(id) + GIVE_AMOUNT
with
min( cs_get_user_money(id) + GIVE_AMOUNT , 16000 )

And

cs_get_user_money(PlayerList[i]) + GIVE_AMOUNT
with
min( cs_get_user_money(PlayerList[i]) + GIVE_AMOUNT , 16000 )

Ace67 04-18-2021 01:03

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by Bugsy (Post 2744392)
Replace:

cs_get_user_money(id) + GIVE_AMOUNT
with
min( cs_get_user_money(id) + GIVE_AMOUNT , 16000 )

And

cs_get_user_money(PlayerList[i]) + GIVE_AMOUNT
with
min( cs_get_user_money(PlayerList[i]) + GIVE_AMOUNT , 16000 )

the min give error, so i have do this

Code:

public Give_Money()
{
    static PlayerList[32], PlayerNum; PlayerNum = 0
    static id
    static CsTeams:iTeam;
    get_players(PlayerList, PlayerNum, "h")
    for(new i=0; i<PlayerNum;i++)
    {
        id = PlayerList[i];
        iTeam = cs_get_user_team(id)
        if(iTeam == CS_TEAM_SPECTATOR || iTeam == CS_TEAM_UNASSIGNED)
            continue

        cs_set_user_money(id, cs_get_user_money(id) + GIVE_AMOUNT , 16000 )
    }
}


Bugsy 04-18-2021 01:50

Re: Money Every 5 Minutes
 
I thought you were using the code I posted here. I showed you what you had to replace in each of these 2 snips.

Ace67 04-18-2021 14:07

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by Bugsy (Post 2744403)
I thought you were using the code I posted here. I showed you what you had to replace in each of these 2 snips.


Code:

// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\cstrike\addons\amxmodx\scripting\money5min.sma(67 -- 69) : error 001: expected token: ",", but found "}"
Code:

public Give_Money()
{
    static PlayerList[32], PlayerNum; PlayerNum = 0
    static id
    static CsTeams:iTeam;
    get_players(PlayerList, PlayerNum, "h")
    for(new i=0; i<PlayerNum;i++)
    {
        id = PlayerList[i];
        iTeam = cs_get_user_team(id)
        if(iTeam == CS_TEAM_SPECTATOR || iTeam == CS_TEAM_UNASSIGNED)
            continue

        cs_set_user_money(id, min (cs_get_user_money (id) + GIVE_AMOUNT, 16000)
    }
}


Bugsy 04-18-2021 17:41

Re: Money Every 5 Minutes
 
PHP Code:

public Give_Money()
{
    new 
PlayerList32 ], id PlayerNum

    
get_playersPlayerList PlayerNum "h" );

    for ( new 
PlayerNum i++ )
    {
        
id PlayerList];

        if ( 
CS_TEAM_T <= cs_get_user_teamid ) <= CS_TEAM_CT )
        {
                
cs_set_user_moneyid mincs_get_user_moneyid ) + GIVE_AMOUNT16000 ) );
        }
    }



Ace67 04-18-2021 18:50

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by Bugsy (Post 2744459)
PHP Code:

public Give_Money()
{
    new 
PlayerList32 ], id PlayerNum

    
get_playersPlayerList PlayerNum "h" );

    for ( new 
PlayerNum i++ )
    {
        
id PlayerList];

        if ( 
CS_TEAM_T <= cs_get_user_teamid ) <= CS_TEAM_CT )
        {
                
cs_set_user_moneyid mincs_get_user_moneyid ) + GIVE_AMOUNT16000 ) );
        }
    }



Thanks works.

Ace67 05-16-2021 10:01

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by Bugsy (Post 2744459)
PHP Code:

public Give_Money()
{
    new 
PlayerList32 ], id PlayerNum

    
get_playersPlayerList PlayerNum "h" );

    for ( new 
PlayerNum i++ )
    {
        
id PlayerList];

        if ( 
CS_TEAM_T <= cs_get_user_teamid ) <= CS_TEAM_CT )
        {
                
cs_set_user_moneyid mincs_get_user_moneyid ) + GIVE_AMOUNT16000 ) );
        }
    }





Hey @Bugsy, can you edit for this lines 16k max money, thx.

Code:

public client_disconnect(id) remove_task(id+TASK_GETMONEY)

public Give_Money(taskid)
{
    new id = taskid -TASK_GETMONEY;
    static CsTeams:iTeam;

    if(iTeam == CS_TEAM_SPECTATOR || iTeam == CS_TEAM_UNASSIGNED)
            return

    cs_set_user_money(id, cs_get_user_money(id) + GIVE_AMOUNT)
}


Bugsy 05-16-2021 11:12

Re: Money Every 5 Minutes
 
cs_set_user_money(id, min( cs_get_user_money(id) + GIVE_AMOUNT , 16000 ) )

Ace67 05-16-2021 11:24

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by Bugsy (Post 2746979)
cs_set_user_money(id, min( cs_get_user_money(id) + GIVE_AMOUNT , 16000 ) )

i don't get the money after 5mins.

Celena Luna 05-17-2021 03:53

Re: Money Every 5 Minutes
 
[Global Timer]
Spoiler


[Unique Timer]
Spoiler

I edited based on my post

P/S: Please reply if it work or not

@Bugsy: Sorry, I got infected by Dias's style who usually check the negative condition. :3
Though, I would use positive condition if the positive condition is less than negative

Ace67 05-17-2021 13:35

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by Celena Luna (Post 2747033)
[Global Timer]
Spoiler


[Unique Timer]
Spoiler

I edited based on my post

P/S: Please reply if it work or not

@Bugsy: Sorry, I got infected by Dias's style who usually check the negative condition. :3
Though, I would use positive condition if the positive condition is less than negative

With unique timer, we don't get the money.

Bugsy 05-17-2021 21:31

Re: Money Every 5 Minutes
 
In unique timer, replace Give_Money() with:
PHP Code:

public Give_Money(taskid)
{
    new 
id taskid TASK_GETMONEY;
    new 
CsTeams:csTeam cs_get_user_teamid );

    if ( 
CS_TEAM_T <= csTeam <= CS_TEAM_CT )
    {
        
cs_set_user_money(idmin(cs_get_user_money(id) + GIVE_AMOUNT16000))
    }



Celena Luna 05-17-2021 21:33

Re: Money Every 5 Minutes
 
Go with traditional way I guess (?)

[Unique Timer]
Spoiler


Edit: @OP Use Bugsy's code as he said below first.
Edit2: Thank @+ARUKARI- for pointing that out. IDK how I missed that.
@Bugsy I will be careful next time. I already fixed it in my code

+ARUKARI- 05-18-2021 00:18

Re: Money Every 5 Minutes
 
@Celena
You're forgetting this.
PHP Code:

CsTeams:iTeam =  cs_get_user_teamid ); 


Bugsy 05-18-2021 00:26

Re: Money Every 5 Minutes
 
Yes, Celena please test your code before posting if you are not that experienced. This is going to turn into a multi-page thread because of simple code mistakes.

@OP, use Celena Luna's Unique Timer from here and replace the Give_Money() function with what I posted here

+ARUKARI- 05-18-2021 03:14

Re: Money Every 5 Minutes
 
If using regamedll, you can also get 16000(more then) from mp_maxmoney.

Ace67 05-18-2021 05:54

Re: Money Every 5 Minutes
 
Quote:

Originally Posted by Bugsy (Post 2747134)
In unique timer, replace Give_Money() with:
PHP Code:

public Give_Money(taskid)
{
    new 
id taskid TASK_GETMONEY;
    new 
CsTeams:csTeam cs_get_user_teamid );

    if ( 
CS_TEAM_T <= csTeam <= CS_TEAM_CT )
    {
        
cs_set_user_money(idmin(cs_get_user_money(id) + GIVE_AMOUNT16000))
    }



Thanks works ;)


All times are GMT -4. The time now is 04:52.

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