AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Team flash error (https://forums.alliedmods.net/showthread.php?t=143291)

edgaras85 11-17-2010 15:26

Team flash error
 
Quote:

L 11/17/2010 - 22:06:13: [CSTRIKE] Player out of range (0)
L 11/17/2010 - 22:06:13: [AMXX] Displaying debug trace (plugin "teamflash_punish.amxx")
L 11/17/2010 - 22:06:13: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 11/17/2010 - 22:06:13: [AMXX] [0] float.inc::operator==(Float:,Float:) (line 126)
L 11/17/2010 - 22:06:13: [AMXX] [1] phpAJ9HhL.sma::Event_ScreenFade (line 180)
PHP Code:

/*    Formatright © 2010, ConnorMcLeod

Team Flash Punish is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Team Flash Punish; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

new const VERSION[] = "1.1.0"

const MAX_PLAYERS 32

new g_iMaxPlayers
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

const MAX_ENTSARRAYS_SIZE 64

new g_bitGonnaExplode[MAX_ENTSARRAYS_SIZE]
#define SetGrenadeExplode(%1)        g_bitGonnaExplode[%1>>5] |=  1<<(%1 & 31)
#define ClearGrenadeExplode(%1)    g_bitGonnaExplode[%1>>5] &= ~( 1 << (%1 & 31) )
#define WillGrenadeExplode(%1)    g_bitGonnaExplode[%1>>5] &   1<<(%1 & 31)

const XTRA_OFS_PLAYER 5

enum 
( <<= ) {
    
CountSemiFlash 1,
    
CountFullFlash,
    
CountDeadFlasher
}

enum ( <<= ) {
    
PunishHealth 1,
    
PunishMoney
}

new 
Float:g_flCurrentGameTimeg_iCurrentFlasher

new g_iFlashTeamCount[MAX_PLAYERS+1]

new 
g_pcvarTeamFlashg_pcvarMaxg_pcvarHealthg_pcvarPunishg_pcvarMoney

new g_iHudTextArgsg_iTextMsg

public plugin_init()
{
    
register_plugin("Team Flash Punish"VERSION"ConnorMcLeod")
    
    
g_pcvarTeamFlash register_cvar("tfp_count""2")    // Additive values 0: don't count, 1:count semi flash, 2:count full flash, 4:count dead flasher
    
g_pcvarMax register_cvar("tfp_max_count""6")        // disallow flashbang after X count
    
g_pcvarPunish register_cvar("tfp_punish""1")        // Additive values 0: don't punish, 1:health, 2:money
    
g_pcvarHealth register_cvar("tfp_health_amount""14")    // health reduction
    
g_pcvarMoney register_cvar("tfp_money_amount""200")    // cash taken
    
    
register_event("ScreenFade""Event_ScreenFade""be""4=255""5=255""6=255""7=200""7=255")
    
    
RegisterHam(Ham_Think"grenade""Ham__CGrenade_Think__Pre")
    
    
RegisterHam(Ham_Touch"armoury_entity""CArmouryEntity_Touch")
    
RegisterHam(Ham_Touch"weaponbox""CWeaponBox_Touch")
    
    
register_clcmd("menuselect 3""ClientCommand_MenuSelect_3")
    
    
g_iMaxPlayers get_maxplayers()
    
g_iHudTextArgs get_user_msgid("HudTextArgs")
    
g_iTextMsg get_user_msgid("TextMsg")
}

public 
client_putinserver(id)
{
    
g_iFlashTeamCount[id] = 0
}

CantBuyFlashBang(id)
{
    if( 
CantHaveFlashbangsAnymore(id) && cs_get_user_buyzone(id) )
        {
        
message_begin(MSG_ONEg_iTextMsg, .player=id)
        {
            
write_byte(4)
            
write_string("#Weapon_Not_Available")
        }
        
message_end()
        return 
PLUGIN_HANDLED
    
}    
    return 
PLUGIN_CONTINUE
}

CantHaveFlashbangsAnymore(id)
{
    new 
iMax get_pcvar_num(g_pcvarMax)
    return (
iMax && g_iFlashTeamCount[id] >= iMax)
}

public 
ClientCommand_MenuSelect_3id )
{
    const 
m_iMenuIndex 205
    
const EQUIP_MENU 10
    
if(    is_user_alive(id)
    &&    
get_pdata_int(idm_iMenuIndexXTRA_OFS_PLAYER) == EQUIP_MENU
    
&&    cs_get_user_buyzone(id)
    &&    
cs_get_user_money(id) >= 200 )
    {
        return 
CantBuyFlashBang(id)
    }
    return 
PLUGIN_CONTINUE
}

public 
client_commandid )
{
    new 
szCommand[7]
    const 
FLASH_BUYALIAS_STRLEN 5
    
if( read_argv(0szCommandcharsmax(szCommand)) == FLASH_BUYALIAS_STRLEN && equal(szCommand"flash") )
        {
        return 
CantBuyFlashBang(id)
    }
    return 
PLUGIN_CONTINUE
}

public 
Cs_InternalCommandidszCommand[] )
{
    if( 
equal(szCommand"flash") )
        {
        return 
CantBuyFlashBang(id)
    }
    return 
PLUGIN_CONTINUE
}

public 
Ham__CGrenade_Think__PreiEnt )
{
    static 
Float:flGameTimeFloat:flDmgTimeiOwner
    flGameTime 
get_gametime()
    
pev(iEntpev_dmgtimeflDmgTime)
    const 
XTRA_OFS_GRENADE 5
    
if(    flDmgTime <= flGameTime
    
    
// VEN's way on how to detect grenade type
    // http://forums.alliedmods.net/showthread.php?p=401189#post401189
    
&&    get_pdata_int(iEnt114XTRA_OFS_GRENADE) == // has a bit when is HE or SMOKE
    
&&    !(get_pdata_int(iEnt96XTRA_OFS_GRENADE) & (1<<8)) // has this bit when is c4
    
    
&&    IsPlayer( (iOwner pev(iEntpev_owner)) )    ) // if no owner (3rd 'after dmgtime' frame), grenade gonna be removed from world
    
{
        if( ~
WillGrenadeExplode(iEnt) ) // grenade gonna explode on next think
            
{
            
SetGrenadeExplodeiEnt )
        }
        else
        {
            
ClearGrenadeExplodeiEnt )
            
g_flCurrentGameTime flGameTime

            
if(is_user_connected(iOwner) && is_user_alive(iOwner))
            {
                
g_iCurrentFlasher iOwner
            
}
        }
    }
}

public 
Event_ScreenFade(id)
{
    if(
is_user_connected(id) && is_user_alive(id))
    {
        new 
Float:flGameTime get_gametime()
        if( 
id != g_iCurrentFlasher && g_flCurrentGameTime == flGameTime && cs_get_user_team(id) == cs_get_user_team(g_iCurrentFlasher)    )
        {        
            new 
bool:bFullFlashed = ( read_data(7) == 255 )
            new 
bAlive is_user_alive(g_iCurrentFlasher)
            
            new 
iCountType get_pcvar_num(g_pcvarTeamFlash)
            if( 
iCountType && (iCountType CountDeadFlasher || bAlive) )
                {
                if(    (
iCountType CountFullFlash && bFullFlashed == bFullFlashed)
                ||    
iCountType CountSemiFlash    )
                {
                    
g_iFlashTeamCount[g_iCurrentFlasher]++
                    new 
iPunish get_pcvar_num(g_pcvarPunish)
                    if( 
iPunish PunishHealth && bAlive )
                        {
                        new 
Float:flHealth
                        pev
(g_iCurrentFlasherpev_healthflHealth)
                        
flHealth -= get_pcvar_float(g_pcvarHealth)
                        if( 
flHealth 1.0 )
                            {
                            
flHealth 1.0
                        
}
                        
set_pev(g_iCurrentFlasherpev_healthflHealth)
                    }
                    if( 
iPunish PunishMoney )
                        {
                        new 
iMoney max(cs_get_user_money(g_iCurrentFlasher) - get_pcvar_num(g_pcvarMoney), 0)
                        
cs_set_user_money(g_iCurrentFlasheriMoney1)
                    }
                }
            }
            
            const 
m_flNextHudTextArgsGameTime 198
            
if( get_pdata_float(idm_flNextHudTextArgsGameTimeXTRA_OFS_PLAYER) < flGameTime )
                {
                
set_pdata_float(idm_flNextHudTextArgsGameTimeflGameTime 5.0XTRA_OFS_PLAYER)
                
                
message_begin(MSG_ONEg_iHudTextArgs, .player=g_iCurrentFlasher)
                {
                    
write_string("#Hint_try_not_to_injure_teammates")
                    
write_byte(1)
                    
write_byte(0)
                }
                
message_end()
            }
        }
    }
}
public 
CArmouryEntity_Touch(iArmouryid)
{
    const 
XTRA_OFS_ARMOURY 4
    
const m_iItem 34
    
const CSA_FLASHBANG 14
    
if( IsPlayer(id) && get_pdata_int(iArmourym_iItemXTRA_OFS_ARMOURY) == CSA_FLASHBANG && CantHaveFlashbangsAnymore(id) )
        {
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED
}

public 
CWeaponBox_Touch(iWeaponBoxid)
{
    if( 
IsPlayer(id) )
        {
        const 
XTRA_OFS_WEAPONBOX 4
        
const m_rgpPlayerItems_slot4 38
        
new iWeapon get_pdata_cbase(iWeaponBoxm_rgpPlayerItems_slot4XTRA_OFS_WEAPONBOX)
        if( 
iWeapon && cs_get_weapon_id(iWeapon) == CSW_FLASHBANG && CantHaveFlashbangsAnymore(id) )
            {
            return 
HAM_SUPERCEDE
        
}
    }
    return 
HAM_IGNORED



Exolent[jNr] 11-17-2010 15:30

Re: Team flash error
 
Check if g_iCurrentFlasher is connected.

edgaras85 11-18-2010 07:17

Re: Team flash error
 
I check...

PHP Code:

if(is_user_connected(iOwner) && is_user_alive(iOwner))
            {
                
g_iCurrentFlasher iOwner
            


PHP Code:

if(is_user_connected(id) && is_user_alive(id))
    {
        new 
Float:flGameTime get_gametime()
        if( 
id != g_iCurrentFlasher && g_flCurrentGameTime == flGameTime && cs_get_user_team(id) == cs_get_user_team(g_iCurrentFlasher)    )
        { 


Exolent[jNr] 11-18-2010 15:54

Re: Team flash error
 
Quote:

Originally Posted by edgaras85 (Post 1351775)
I check...

PHP Code:

if(is_user_connected(iOwner) && is_user_alive(iOwner))
            {
                
g_iCurrentFlasher iOwner
            


PHP Code:

if(is_user_connected(id) && is_user_alive(id))
    {
        new 
Float:flGameTime get_gametime()
        if( 
id != g_iCurrentFlasher && g_flCurrentGameTime == flGameTime && cs_get_user_team(id) == cs_get_user_team(g_iCurrentFlasher)    )
        { 


You have to check if g_iCurrentFlasher is connected in the ScreenFade event.


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

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