AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Will this work? Set money on round end plugin (https://forums.alliedmods.net/showthread.php?t=308594)

csykosoma 06-26-2018 16:40

Will this work? Set money on round end plugin
 
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)    
        
    }



iceeedr 06-26-2018 17:01

Re: Will this work? Set money on round end plugin
 
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)) 


Natsheh 06-26-2018 18:06

Re: Will this work? Set money on round end plugin
 
You are hooking teams win incorrectly, use get_players then loop through players array indexes.

csykosoma 06-27-2018 01:17

Re: Will this work? Set money on round end plugin
 
Quote:

Originally Posted by Natsheh (Post 2599426)
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)    
    
    



instinctpt1 06-27-2018 01:51

Re: Will this work? Set money on round end plugin
 
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)
    }



CrAzY MaN 06-27-2018 02:30

Re: Will this work? Set money on round end plugin
 
I don't understand why do you check !is_user_alive()?
There's no need to do.

Natsheh 06-27-2018 05:00

Re: Will this work? Set money on round end plugin
 
Quote:

Originally Posted by CrAzY MaN (Post 2599475)
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

instinctpt1 06-27-2018 05:14

Re: Will this work? Set money on round end plugin
 
Quote:

Originally Posted by CrAzY MaN (Post 2599475)
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

Natsheh 06-27-2018 08:56

Re: Will this work? Set money on round end plugin
 
Quote:

Originally Posted by instinctpt1 (Post 2599486)
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)
    }



csykosoma 06-27-2018 11:50

Re: Will this work? Set money on round end plugin
 
thank you will be testing this soon and will edit this comment


All times are GMT -4. The time now is 00:27.

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