Raised This Month: $51 Target: $400
 12% 

Will this work? Set money on round end plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
csykosoma
Member
Join Date: Dec 2011
Old 06-26-2018 , 16:40   Will this work? Set money on round end plugin
Reply With Quote #1

Trying to make plugin that
checks on round end if(is the user is dead && is on the losing team && money is less than 800)
{
sets users money to 800
}

but it is giving a tag mismatch error during compiling on these two lines
Code:
if ((fm_get_user_team(i) == CS_TEAM_CT) && !is_user_alive(i) && (cs_get_user_money(i) < 800))
and I have no idea if I'm doing anything else wrong with this code.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>


#define TIMETOWAIT 4.7

#define fm_get_user_team(%1) get_pdata_int(%1, 114)


new g_iMaxPlayers

public plugin_init()
{
    
register_logevent("LogEvent_CTs_Win"6"0=Team""1=CT""3=CTs_Win")
    
register_logevent("LogEvent_Ts_Win"3"0=Team""1=CT""3=CTs_Win")
    
g_iMaxPlayers get_maxplayers()
}

public 
LogEvent_CTs_win()
{
    
set_task(TIMETOWAIT"GiveTmoney")
}

public 
LogEvent_Ts_win()
{
    
set_task(TIMETOWAIT"GiveCTmoney")
}

public 
GiveTmoney()
{
    for (new 
1<= g_iMaxPlayersi++)
    {
        if(!
is_user_connected(i))
            continue;
        
        if ((
fm_get_user_team(i) == CS_TEAM_T) && !is_user_alive(i) && (cs_get_user_money(i) < 800))
            
cs_set_user_money(i800)    
        
    }
}

public 
GiveCTmoney()
{
    for (new 
1<= g_iMaxPlayersi++)
    {
        if(!
is_user_connected(i))
            continue;
        
        if ((
fm_get_user_team(i) == CS_TEAM_CT) && !is_user_alive(i) && (cs_get_user_money(i) < 800))
            
cs_set_user_money(i800)    
        
    }

csykosoma is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 06-26-2018 , 17:01   Re: Will this work? Set money on round end plugin
Reply With Quote #2

PHP Code:
if ((fm_get_user_team(i) == CS_TEAM_T) && !is_user_alive(i) && (cs_get_user_money(i) < 800))

------>

if ((
cs_get_user_team(i) == CS_TEAM_T) && !is_user_alive(i) && (cs_get_user_money(i) < 800)) 
iceeedr is offline
Send a message via Skype™ to iceeedr
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-26-2018 , 18:06   Re: Will this work? Set money on round end plugin
Reply With Quote #3

You are hooking teams win incorrectly, use get_players then loop through players array indexes.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
csykosoma
Member
Join Date: Dec 2011
Old 06-27-2018 , 01:17   Re: Will this work? Set money on round end plugin
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
You are hooking teams win incorrectly, use get_players then loop through players array indexes.
Is this what you mean? I'm having trouble understanding how to use get_players, this doesn't compile.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>


#define TIMETOWAIT 4.7



new g_iMaxPlayers

public plugin_init()
{
    
register_logevent("LogEvent_CTs_Win"6"0=Team""1=CT""3=CTs_Win")
    
register_logevent("LogEvent_Ts_Win"3"0=Team""1=CT""3=CTs_Win")
    
g_iMaxPlayers get_maxplayers()
}

public 
LogEvent_CTs_win()
{
    
set_task(TIMETOWAIT"GiveTmoney")
}

public 
LogEvent_Ts_win()
{
    
set_task(TIMETOWAIT"GiveCTmoney")
}

public 
GiveTmoney()
{
    new 
players[32] , num;
    
get_players(playersnum "be""T")
    
    for (new 
1<= numi++)
        
cs_set_user_money(players(i), 800)    
    
    
}

public 
GiveCTmoney()
{
    new 
players[32] , num;
    
get_players(playersnum "be""CT")
    
    for (new 
1<= numi++)
        
cs_set_user_money(players(i), 800)    
    
    

csykosoma is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 06-27-2018 , 01:51   Re: Will this work? Set money on round end plugin
Reply With Quote #5

Untested .
PHP Code:
#include <amxmodx>
#include <cstrike>

public plugin_init()
{
    
register_plugin("Round End Money""1.0""DiGiTaL")
    
    
register_event"SendAudio","event_twin","a","2=%!MRAD_terwin");
    
register_event"SendAudio","event_ctwin","a","2=%!MRAD_ctwin");
}

public 
event_ctwin() WinnerTeam(2)
public 
event_twin() WinnerTeam(1)

public 
WinnerTeam(teamWon)
{
    new 
players[32], num
    get_players
(playersnum"b")
    for(new 
inumi++)
    {
        
players[i]
        if(
get_user_team(x) == teamWon && cs_get_user_money(x) < 800
            
cs_set_user_money(x800)
    }


Last edited by instinctpt1; 06-27-2018 at 05:10. Reason: updated
instinctpt1 is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-27-2018 , 02:30   Re: Will this work? Set money on round end plugin
Reply With Quote #6

I don't understand why do you check !is_user_alive()?
There's no need to do.
__________________
CrAzY MaN is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-27-2018 , 05:00   Re: Will this work? Set money on round end plugin
Reply With Quote #7

Quote:
Originally Posted by CrAzY MaN View Post
I don't understand why do you check !is_user_alive()?
There's no need to do.
Read 1st post

Also use flag b in get players and remove the check if is user dead
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 06-27-2018 , 05:14   Re: Will this work? Set money on round end plugin
Reply With Quote #8

Quote:
Originally Posted by CrAzY MaN View Post
I don't understand why do you check !is_user_alive()?
There's no need to do.
He told.. to do that
yeah @natsheh i was so offmind .. i just went acc to wht he said in description xD

Last edited by instinctpt1; 06-27-2018 at 05:15.
instinctpt1 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-27-2018 , 08:56   Re: Will this work? Set money on round end plugin
Reply With Quote #9

Quote:
Originally Posted by instinctpt1 View Post
He told.. to do that
yeah @natsheh i was so offmind .. i just went acc to wht he said in description xD
Here you go fully optimized.
PHP Code:
public event_ctwin() WinnerTeam("CT")
public 
event_twin() WinnerTeam("TERRORIST")

public 
WinnerTeam(const teamWon[])
{
    new 
players[32], num;
    
get_players(playersnum"be"teamWon)
    for(new 
ixnumi++)
    {
        
players[i]
        if(
cs_get_user_money(x) < 800
            
cs_set_user_money(x800)
    }

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
csykosoma
Member
Join Date: Dec 2011
Old 06-27-2018 , 11:50   Re: Will this work? Set money on round end plugin
Reply With Quote #10

thank you will be testing this soon and will edit this comment
csykosoma 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 22:53.


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