Raised This Month: $32 Target: $400
 8% 

Eventscript Code to Sourcemod Code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BlackPanda
Junior Member
Join Date: Apr 2020
Old 04-29-2020 , 07:04   Eventscript Code to Sourcemod Code
Reply With Quote #1

Hello everybody,

can someone maybe help me to write the script, which comes from eventscript, as SourceMod code?


Code:
event hegrenade_detonate
{
  es_playsound event_var(userid) bp_plugin/event/he.wav 1.0
}

event flashbang_detonate
{
  es_playsound event_var(userid) bp_plugin/event/flash.wav 1.0
}

event smokegrenade_detonate
{
  es_playsound event_var(userid) bp_plugin/event/smoke.wav 1.0
}



event player_team 
{  
if (event_var(team) = 2) do 
        { 
                es_msg Playername goes to T
                es_playsound event_var(userid) bp_plugin/event/tjt.mp3 1.0 
        } 

if (event_var(team) = 3) do 
        { 
                es_msg Playername goes to CT
                es_playsound event_var(userid) bp_plugin/event/tjct.mp3 1.0 
        }  
}
Thx
BlackPanda
BlackPanda is offline
BlackPanda
Junior Member
Join Date: Apr 2020
Old 04-30-2020 , 04:35   Re: Eventscript Code to Sourcemod Code
Reply With Quote #2

hello everybody,
is able to write plugins from eventscript in sourcemod plugins to?
I would be very grateful and willing to pay for it.

Gruß
BlackPanda
BlackPanda is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 04-30-2020 , 16:29   Re: Eventscript Code to Sourcemod Code
Reply With Quote #3

Something like this:
Code:
// these are just macros to simplify working with the code
#define GRENADE_DETONATE_SOUND			"bp_plugin/event/he.wav"
#define FLASHBANG_DETONATE_SOUND		"bp_plugin/event/flash.wav"
#define SMOKE_GRENADE_DETONATE_SOUND	"bp_plugin/event/smoke.wav"
#define JOIN_T_SOUND					"bp_plugin/event/tjt.wav"
#define JOIN_CT_SOUND					"bp_plugin/event/tjct.wav"

// initialize event hooks and other stuff on plugin load (this calls only once)
public void OnPluginStart() {
	HookEvent( "hegrenade_detonate", OnGrenadeDetonate );
	HookEvent( "flashbang_detonate", OnFlashbangDetonate );
	HookEvent( "smokegrenade_detonate", OnSmokeGrenadeDetonate );
	HookEvent( "player_team", OnPlayerTeam );
}

// prepare (make our sounds public to any client) and precache our sounds (this call every map)
public void OnMapStart() {
	PrecacheSound( GRENADE_DETONATE_SOUND );
	AddFileToDownloadsTable( "sound/" ... GRENADE_DETONATE_SOUND );

	PrecacheSound( FLASHBANG_DETONATE_SOUND );
	AddFileToDownloadsTable( "sound/" ... FLASHBANG_DETONATE_SOUND );

	PrecacheSound( SMOKE_GRENADE_DETONATE_SOUND );
	AddFileToDownloadsTable( "sound/" ... SMOKE_GRENADE_DETONATE_SOUND );

	PrecacheSound( JOIN_T_SOUND );
	AddFileToDownloadsTable( "sound/" ... JOIN_T_SOUND );

	PrecacheSound( JOIN_CT_SOUND );
	AddFileToDownloadsTable( "sound/" ... JOIN_CT_SOUND );
}

// SNDVOL_NORMAL = 1.0 (you dont need actually to put this into function because it's a default value for EmitSoundToClient)
public void OnGrenadeDetonate(Event event, const char[] name, bool dontBroadcast) {
	int iClient = GetClientOfUserId( event.GetInt( "userid" ) );
	if ( iClient )
		EmitSoundToClient( iClient, GRENADE_DETONATE_SOUND, .volume = SNDVOL_NORMAL );
}
public void OnFlashbangDetonate(Event event, const char[] name, bool dontBroadcast) {
	int iClient = GetClientOfUserId( event.GetInt( "userid" ) );
	if ( iClient )
		EmitSoundToClient( iClient, FLASHBANG_DETONATE_SOUND, .volume = SNDVOL_NORMAL );
}
public void OnSmokeGrenadeDetonate(Event event, const char[] name, bool dontBroadcast) {
	int iClient = GetClientOfUserId( event.GetInt( "userid" ) );
	if ( iClient )
		EmitSoundToClient( iClient, SMOKE_GRENADE_DETONATE_SOUND, .volume = SNDVOL_NORMAL );
}

public void OnPlayerTeam(Event event, const char[] name, bool dontBroadcast) {
	int iClient = GetClientOfUserId( event.GetInt( "userid" ) );
	if ( iClient == 0 )
		return; // break our code if client is not a player or is not in game

	switch ( event.GetInt( "team" ) ) {
		case 2: {
			PrintToChatAll( "%N goes to T", iClient );
			EmitSoundToClient( iClient, JOIN_T_SOUND, .volume = SNDVOL_NORMAL );
		}
		case 3: {
			PrintToChatAll( "%N goes to CT", iClient );
			EmitSoundToClient( iClient, JOIN_CT_SOUND, .volume = SNDVOL_NORMAL );
		}
	}
}
__________________

Last edited by MAGNAT2645; 04-30-2020 at 16:42. Reason: Added precaching and etc. stuff
MAGNAT2645 is offline
BlackPanda
Junior Member
Join Date: Apr 2020
Old 05-01-2020 , 02:32   Re: Eventscript Code to Sourcemod Code
Reply With Quote #4

hi MAGNAT2645,
thanks for already bothering you that's really very nice of you! The way I see it, it seems to be exactly that :-) I tried compiling. However, there are a few errors.

Code:
Your plugin failed to compile! Read the errors below:
SourcePawn Compiler 1.10.0.6453
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2018 AlliedModders LLC

/groups/sourcemod/upload_tmp/textg6uYiI.sp(19) : error 017: undefined symbol "AddFileToDownloadsTable"
/groups/sourcemod/upload_tmp/textg6uYiI.sp(22) : error 017: undefined symbol "AddFileToDownloadsTable"
/groups/sourcemod/upload_tmp/textg6uYiI.sp(25) : error 017: undefined symbol "AddFileToDownloadsTable"
/groups/sourcemod/upload_tmp/textg6uYiI.sp(28) : error 017: undefined symbol "AddFileToDownloadsTable"
/groups/sourcemod/upload_tmp/textg6uYiI.sp(31) : error 017: undefined symbol "AddFileToDownloadsTable"
/groups/sourcemod/upload_tmp/textg6uYiI.sp(38) : error 017: undefined symbol "EmitSoundToClient"
/groups/sourcemod/upload_tmp/textg6uYiI.sp(38) : warning 217: loose indentation
/groups/sourcemod/upload_tmp/textg6uYiI.sp(38) : error 017: undefined symbol "SNDVOL_NORMAL"
/groups/sourcemod/upload_tmp/textg6uYiI.sp(38) : error 029: invalid expression, assumed zero
/groups/sourcemod/upload_tmp/textg6uYiI.sp(38) : fatal error 190: too many error messages on one line

Compilation aborted.
9 Errors.

I'm already grateful to you
BlackPanda
BlackPanda is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 05-01-2020 , 05:17   Re: Eventscript Code to Sourcemod Code
Reply With Quote #5

Add #include sourcemod line to the top of your code.
__________________
MAGNAT2645 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-01-2020 , 06:08   Re: Eventscript Code to Sourcemod Code
Reply With Quote #6

#include <sdktools>
__________________
Do not Private Message @me
Bacardi is offline
BlackPanda
Junior Member
Join Date: Apr 2020
Old 05-01-2020 , 06:45   Re: Eventscript Code to Sourcemod Code
Reply With Quote #7

Hi,
thank you very much!!! it is WORKING!!! :-)


now it would be nice if the player name and the t or ct are also written in the respective color. So either blue for ct or red for t. Doable for you?

Quote:
PrintToChatAll( "%N goes to T", iClient );
LG
BlackPanda

Last edited by BlackPanda; 05-01-2020 at 07:19.
BlackPanda is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-01-2020 , 07:21   Re: Eventscript Code to Sourcemod Code
Reply With Quote #8

I have never see this way to add strings
PHP Code:
#define GRENADE_DETONATE_SOUND            "bp_plugin/event/he.wav"
    
AddFileToDownloadsTable"sound/" ... GRENADE_DETONATE_SOUND ); 
__________________
Do not Private Message @me
Bacardi is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 05-01-2020 , 10:35   Re: Eventscript Code to Sourcemod Code
Reply With Quote #9

Quote:
Originally Posted by Bacardi View Post
I have never see this way to add strings
PHP Code:
#define GRENADE_DETONATE_SOUND            "bp_plugin/event/he.wav"
    
AddFileToDownloadsTable"sound/" ... GRENADE_DETONATE_SOUND ); 
It's just a preprocessor function like StrCat. Compiler joins multiple strings (between every three dots/ellipsis) into one.
I learned about this (and other useful things) from these Russian mini-lessons.
__________________
MAGNAT2645 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-01-2020 , 10:42   Re: Eventscript Code to Sourcemod Code
Reply With Quote #10

hmmm... bummer. Need use translation
Bacardi 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 02:18.


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