AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help register_event (https://forums.alliedmods.net/showthread.php?t=327456)

1M1e 09-19-2020 18:06

help register_event
 
hi

can some one tell me how to restart the plugin when the new round start?

i tried to add

Code:

register_event("HLTV", "event_round_start", "a", "1=0", "2=0")

public event_round_start()
{
        return PLUGIN_HANDLED
}

but still did not work

can some one help me?

this is all code
Code:

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

new g_counter 

new g_SyncRestartTimer
new g_SyncGameStart

new Float:RoundStartTime

new g_Time_Interval;
const MAX_PLAYERS = 32;

new g_iRespawn[MAX_PLAYERS+1], g_TeamInfoCounter[MAX_PLAYERS+1], CsTeams:g_iPlayerTeam[MAX_PLAYERS+1];
new g_pCvarRespawnTime, g_pCvarRespawnDelay, g_pCvarMaxHealth;

public plugin_init()
{
        register_plugin("Dr.Respawn", "1.2", "Vicious Vixen");
        RegisterHam(Ham_Killed, "player", "fwdPlayerKilledPost", 1);
        RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawnPost", 1);
        register_event("TeamInfo", "eTeamInfo", "a");
        register_logevent( "LogEventRoundStart", 2, "1=Round_Start" )
        g_pCvarRespawnTime = register_cvar("amx_respawn_tickets", "0");
        g_pCvarRespawnDelay = register_cvar("amx_respawn_delay", "1");
        g_pCvarMaxHealth = register_cvar("amx_max_health", "100");
        g_Time_Interval = register_cvar("amx_max_time", "40");
        set_msg_block( get_user_msgid( "ClCorpse" ), BLOCK_SET );
       
        g_SyncRestartTimer = CreateHudSyncObj()
        g_SyncGameStart = CreateHudSyncObj()
       
        register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
       
}

public LogEventRoundStart()
{
        RoundStartTime = get_gametime()
       
        new iPlayers[32]
        new iNum
       
        get_players( iPlayers, iNum )
       
        for( new i = 0; i < iNum; i++ )
        {
                g_iRespawn[iPlayers[i]] = true
        }
        set_task(1.0,"TimeCounter",123456,_,_,"a",get_pcvar_num(g_Time_Interval))
        set_task(get_pcvar_float(g_Time_Interval),"Runda_Terminata",789123)
}

public Runda_Terminata()
{
        if(RoundStartTime)
        {
                set_hudmessage( 255, 0, 0, 0.09, 0.00, 1, 0.5, 1.0, 0.5, 15.0, -1)
                ShowSyncHudMsg( 0, g_SyncGameStart, "Respawn mode is disabled!")
        }
}

public fwdPlayerKilledPost(iVictim, iKiller, iShoudlGib)
{
        if(g_iRespawn[iVictim]++ < get_pcvar_num(g_pCvarRespawnTime) || get_pcvar_num(g_pCvarRespawnTime) == 0)
        {
                set_task(get_pcvar_float(g_pCvarRespawnDelay), "taskRespawnPlayer", iVictim);
        }
        return HAM_IGNORED;
}

public fwdPlayerSpawnPost(iClient)
{
        if(is_user_alive(iClient))
        {
                set_pev(iClient, pev_health, get_pcvar_float(g_pCvarMaxHealth));
        }
}

public taskRespawnPlayer(id)
{
        if(is_user_connected(id) && RoundStartTime + get_pcvar_num(g_Time_Interval) >= get_gametime() && g_iRespawn[id] && !is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
                ExecuteHamB(Ham_CS_RoundRespawn, id)
                g_iRespawn[id] = false
                return PLUGIN_HANDLED;
        }
        return PLUGIN_HANDLED;


public eTeamInfo()
{
        new iClient = read_data(1);
        new szTeam[2];
        read_data(2, szTeam, charsmax(szTeam));
        switch(szTeam[0])
        {
                case 'T':
                {
                        remove_task(iClient);
                        g_iPlayerTeam[iClient] = CS_TEAM_T;
                }
                case 'C':
                {
                        if(g_TeamInfoCounter[iClient] == 2 || g_iPlayerTeam[iClient] == CS_TEAM_SPECTATOR)
                        {
                                set_task(get_pcvar_float(g_pCvarRespawnDelay), "taskRespawnPlayer",  iClient);
                        }
                        g_iPlayerTeam[iClient] = CS_TEAM_CT;
                }
                case 'S':
                {
                        remove_task(iClient);
                        g_iPlayerTeam[iClient] = CS_TEAM_SPECTATOR;
                }
        }
}

public TimeCounter()
{
        g_counter++
       
        new Float:iRestartTime = get_pcvar_float(g_Time_Interval) - g_counter
        new Float:fSec
        fSec = iRestartTime
       
        set_hudmessage( 255, 0, 0, 0.09, 0.0, 1, 0.0, 1.0, 0.0, 0.0, -1)
        ShowSyncHudMsg( 0, g_SyncRestartTimer, "%d Sec Remaining To Disable The Respawn Mod", floatround(fSec))
       
        if(get_pcvar_num(g_Time_Interval) - g_counter < 11 && get_pcvar_num(g_Time_Interval) - g_counter !=0)
        {
                static szNum[32]
                num_to_word(get_pcvar_num(g_Time_Interval) - g_counter, szNum, 31)
        }
        if(g_counter == get_pcvar_num(g_Time_Interval))
        {
                g_counter = 0
        }
       
}

public event_round_start()
{
        return PLUGIN_HANDLED
}


Black Rose 09-19-2020 18:29

Re: help register_event
 
Quote:

Originally Posted by 1M1e (Post 2718226)
reset the plugin

What does this mean?

Supremache 09-19-2020 18:43

Re: help register_event
 
1. You can use bool:"Player Var"[32] for make this plugin working one time per round.
2. Try to cansel the codes before "RoundStartTime" come, something like:

Code:
register_event("HLTV", "ev_RoundStart", "a", "1=0", "2=0") public ev_RoundStart() {     if(!RoundStartTime)     {         remove_task(g_counter)                 new iPlayers[32]         new iNum                 get_players( iPlayers, iNum )                 for( new i = 0; i < iNum; i++ )         {             g_iRespawn[iPlayers[i]] = false         }     } }

1M1e 09-19-2020 19:33

Re: help register_event
 
Quote:

Originally Posted by Black Rose (Post 2718230)
What does this mean?

sorry i meant restart :)

1M1e 09-19-2020 19:43

Re: help register_event
 
Quote:

Originally Posted by Supremache (Post 2718231)
1. You can use bool:"Player Var"[32] for make this plugin working one time per round.
2. Try to cansel the codes before "RoundStartTime" come, something like:

Code:
register_event("HLTV", "ev_RoundStart", "a", "1=0", "2=0") public ev_RoundStart() {     if(!RoundStartTime)     {         remove_task(g_counter)                 new iPlayers[32]         new iNum                 get_players( iPlayers, iNum )                 for( new i = 0; i < iNum; i++ )         {             g_iRespawn[iPlayers[i]] = false         }     } }

sill dose not work the hudmessage still show
i want when the round end and start new round the hudmessage will remove

Code:

        set_hudmessage( 255, 0, 0, 0.09, 0.0, 1, 0.0, 1.0, 0.0, 0.0, -1)
        ShowSyncHudMsg( 0, g_SyncRestartTimer, "%d Sec Remaining To Disable The Respawn Mod", floatround(fSec))


Supremache 09-19-2020 19:49

Re: help register_event
 
Quote:

Originally Posted by 1M1e (Post 2718234)
sill dose not work the hudmessage still show
i want when the round end and start new round the hudmessage will remove

Code:

        set_hudmessage( 255, 0, 0, 0.09, 0.0, 1, 0.0, 1.0, 0.0, 0.0, -1)
        ShowSyncHudMsg( 0, g_SyncRestartTimer, "%d Sec Remaining To Disable The Respawn Mod", floatround(fSec))


It will never be removed because in this plugin use the permanent hud, edit it from ShowSyncHudMsg to show_hudmessage

From:
Code:
set_hudmessage( 255, 0, 0, 0.09, 0.0, 1, 0.0, 1.0, 0.0, 0.0, -1)     ShowSyncHudMsg( 0, g_SyncRestartTimer, "%d Sec Remaining To Disable The Respawn Mod", floatround(fSec))

To:

Code:
set_hudmessage( 255, 0, 0, 0.09, 0.0, 1, 0.0, 1.0, 0.0, 0.0, -1)     show_hudmessage( 0, g_SyncRestartTimer, "%d Sec Remaining To Disable The Respawn Mod", floatround(fSec))

1M1e 09-19-2020 19:54

Re: help register_event
 
can't compile

Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Warning: Loose indentation on line 128
Warning: Loose indentation on line 129
Error: Argument type mismatch (argument 2) on line 129
Warning: Loose indentation on line 131
Warning: Symbol is assigned a value that is never used: "g_SyncRestartTimer" on line 160

1 Error.
Could not locate output file D:\Counter Strike Server\cstrike\addons\amxmodx\plugins\respawn.dr.amx (compile failed).


Supremache 09-19-2020 20:00

Re: help register_event
 
Quote:

Originally Posted by 1M1e (Post 2718236)
can't compile

Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Warning: Loose indentation on line 128
Warning: Loose indentation on line 129
Error: Argument type mismatch (argument 2) on line 129
Warning: Loose indentation on line 131
Warning: Symbol is assigned a value that is never used: "g_SyncRestartTimer" on line 160

1 Error.
Could not locate output file D:\Counter Strike Server\cstrike\addons\amxmodx\plugins\respawn.dr.amx (compile failed).


Oops, Small wrong:
PHP Code:

set_hudmessage255000.090.010.01.00.00.0, -1)
    
show_hudmessage0"%d Sec Remaining To Disable The Respawn Mod"floatround(fSec)) 


1M1e 09-19-2020 20:03

Re: help register_event
 
still doesn't work :(

Supremache 09-19-2020 20:32

Re: help register_event
 
Quote:

Originally Posted by 1M1e (Post 2718238)
still doesn't work :(

It's not like countdown timer!! Try this:

Code:
public TimeCounter()  {     g_counter--         new Float:iRestartTime = get_pcvar_float(g_Time_Interval) - g_counter     new Float:fSec     fSec = iRestartTime     if (g_counter >= 0) {         set_hudmessage( 255, 0, 0, 0.09, 0.0, 1, 0.0, 1.0, 0.0, 0.0, -1)         show_hudmessage( 0, "%d Sec Remaining To Disable The Respawn Mod", floatround(fSec))     }         if (0< g_counter < 11 && get_pcvar_num(g_Time_Interval) - g_counter !=0)     {         static szNum[32]         num_to_word(get_pcvar_num(g_Time_Interval) - g_counter, szNum, 31)     }     if(g_counter == get_pcvar_num(g_Time_Interval))     {         g_counter = 0     } }


All times are GMT -4. The time now is 08:57.

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