Raised This Month: $64 Target: $400
 16% 

HookEvent PlayerSpawned and RoundStart with commands


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TrullSin
Member
Join Date: Jun 2018
Old 11-10-2018 , 14:07   HookEvent PlayerSpawned and RoundStart with commands
Reply With Quote #1

Hi, Im trying to execute some commands after player spawned and round started but no results so far. No errors in sourcemod logs.

PHP Code:
#include <sourcemod>

public void OnPluginStart() 
{
    
HookEvent("player_spawned"player_spawned);
    
HookEvent("round_start"round_start);

public 
Action round_start(Event event, const char[] namebool dontBroadcast
{
    
LogMessage("Round Start Working...");
    
ServerCommand("sm_say 123");

}

public 
Action player_spawned(Event event, const char[] namebool dontBroadcast
{
    
LogMessage("Spawn Working...");
    
ServerCommand("sm_say spawned");


*edit
It is for CS:GO

Last edited by TrullSin; 11-10-2018 at 14:39.
TrullSin is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-10-2018 , 14:32   Re: HookEvent PlayerSpawned and RoundStart with commands
Reply With Quote #2

In which game ??

Try this in your console when you play...
net_dumpeventstats

*edit
dam, CS:GO cvar
__________________

Last edited by Bacardi; 11-10-2018 at 14:35.
Bacardi is offline
Rohanlogs
Senior Member
Join Date: Nov 2015
Old 11-10-2018 , 14:57   Re: HookEvent PlayerSpawned and RoundStart with commands
Reply With Quote #3

Your round start looks OK but instead of
PHP Code:
HookEvent("player_spawned"player_spawned); 
Do
PHP Code:
HookEvent("player_spawn"player_spawned); 
And to get client index in spawn use
PHP Code:
GetClientOfUserIdevent.GetInt("userid") ); 
__________________
Rohanlogs is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 11-10-2018 , 15:38   Re: HookEvent PlayerSpawned and RoundStart with commands
Reply With Quote #4

If you wish to exclude player_spawn that is due to stuff like mp_respawn_on_death_t/ct or !revive, you'll have to hook for player_spawn as usual but make another two conditions that the player didn't die this round AND that when he spawned, GetGameTime() < GameRules_GetPropFloat("m_fRoundStartTime") + GetConVarFloat(FindConVar("mp_join_grace_time ") + GetConVarFloat(FindConVar("mp_freezetime")).

IIRC, you can only get the value of freezetime in the beginning of the round and not in the spawn since it's only effective when a round starts. About mp_join_grace_time I really don't know.
__________________


Accepting private work. Contact me if you're interested.

Last edited by eyal282; 11-10-2018 at 15:42.
eyal282 is offline
Dragokas
Senior Member
Join Date: Nov 2017
Location: Ukraine
Old 11-13-2018 , 19:48   Re: HookEvent PlayerSpawned and RoundStart with commands
Reply With Quote #5

Quote:
ServerCommand("sm_say 123");
Why not PrintToChatAll ?

You need to make a little delay (using Timer) to see that round start msg, as well as a delay on player_spawn if you want to apply player specific commands.
__________________
Expert of CMD/VBS/VB6. Malware analyst.
Dragokas is offline
Reply


Thread Tools
Display Modes

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 21:29.


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