Raised This Month: $ Target: $400
 0% 

[PROBLEM SOLVED] - Converting from engine to fakemeta


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 05-08-2006 , 18:38   [PROBLEM SOLVED] - Converting from engine to fakemeta
Reply With Quote #1

I am converting (or attempting to anyhow) my plugin Anti-Silent Plant from using engine and fakemeta to only using fakemeta because VEN said it would be better this way. I need someone who fully understands fakemeta to tell me if the following has been done correctly.

Original code using fakemeta and engine:
Code:
/*  AMXModX Script * *   Title:    Anti-Silent Plant (antisilentplant) *   Author:   SubStream * *   Current Version:   1.1 *   Release Date:      2006-05-07 * *   For support on this plugin, please visit the following URL: *   fcos URL = <a href="http://forums.alliedmods.net/showthread.php?t=28133" target="_blank" rel="nofollow noopener">http://forums.alliedmods.net/showthread.php?t=28133</a> * *   Anti-Silent Plant - Prevents a silent plant from occuring. *   Copyright (C) 2006  SubStream * *   This program 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; either version 2 *   of the License, or (at your option) any later version. * *   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 this program; if not, write to the Free Software *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. * *   Author Contact Email: <a href="mailto:[email protected]">[email protected]</a> */ #include <amxmodx> #include <amxmisc> #include <engine> #include <fakemeta> new const gs_PLUGIN[]   = "Anti-Silent Plant" new const gs_VERSION[]  = "1.1" new const gs_AUTHOR[]   = "SubStream" new gs_C4_MODEL[] = "models/w_c4.mdl" new bool: gb_CheckSound new bool: gb_EntsReadyForUse new Float: gf_c4origin[3] new Float: gf_entorigin[3] new g_c4entity new g_entillusionary new gi_soundnum new g_sounds[5][] = {     "weapons/c4_beep1.wav",     "weapons/c4_beep2.wav",     "weapons/c4_beep3.wav",     "weapons/c4_beep4.wav",     "weapons/c4_beep5.wav" } public plugin_init () {     register_plugin ( gs_PLUGIN, gs_VERSION, gs_AUTHOR )         if ( find_ent_by_class ( -1, "func_bomb_target" ) )     {         register_logevent ( "fn_triggerplanted" , 3, "1=triggered", "2=Planted_The_Bomb" )         register_logevent ( "fn_triggerroundstart" , 2, "1=Round_Start" )         register_forward ( FM_EmitSound, "fn_soundcheck" )     } } public fn_triggerplanted () {     gb_CheckSound = true } public fn_triggerroundstart () {     gb_CheckSound = false     gb_EntsReadyForUse = false         if ( is_valid_ent ( g_entillusionary ) )     {         remove_entity ( g_entillusionary )     } } public fn_soundcheck ( entity, channel, const s_SOUND[] ) {     if ( gb_CheckSound == true )     {         for ( gi_soundnum = 0; gi_soundnum < 5; gi_soundnum++ )         {             if ( containi ( s_SOUND, g_sounds[gi_soundnum] ) != -1 )             {                 if ( gb_EntsReadyForUse == true )                 {                     fn_emitsound ()                 }                                 else                 {                     fn_createentity ()                 }             }         }     }         else     {         return PLUGIN_CONTINUE     }         return PLUGIN_CONTINUE } public fn_createentity () {     g_c4entity = find_ent_by_model ( -1, "grenade", gs_C4_MODEL )     entity_get_vector ( g_c4entity, EV_VEC_origin, gf_c4origin )         g_entillusionary = create_entity ( "func_illusionary" )     gf_entorigin = gf_c4origin     entity_set_origin ( g_entillusionary, gf_entorigin )         gb_EntsReadyForUse = true         fn_emitsound () } public fn_emitsound () {     emit_sound ( g_entillusionary, CHAN_AUTO, g_sounds[gi_soundnum], 1.0, ATTN_NORM, 0, PITCH_NORM ) }
Code Using ONLY fakemeta
Code:
/*  AMXModX Script * *   Title:    Anti-Silent Plant (antisilentplant) *   Author:   SubStream * *   Current Version:   1.1 *   Release Date:      2006-05-07 * *   For support on this plugin, please visit the following URL: *   fcos URL = <a href="http://forums.alliedmods.net/showthread.php?t=28133" target="_blank" rel="nofollow noopener">http://forums.alliedmods.net/showthread.php?t=28133</a> * *   Anti-Silent Plant - Prevents a silent plant from occuring. *   Copyright (C) 2006  SubStream * *   This program 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; either version 2 *   of the License, or (at your option) any later version. * *   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 this program; if not, write to the Free Software *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. * *   Author Contact Email: <a href="mailto:[email protected]">[email protected]</a> */ #include <amxmodx> #include <amxmisc> #include <fakemeta> new const gs_PLUGIN[]   = "Anti-Silent Plant" new const gs_VERSION[]  = "1.1" new const gs_AUTHOR[]   = "SubStream" new gs_C4_MODEL[] = "models/w_c4.mdl" new bool: gb_CheckSound new bool: gb_EntReadyForUse new Float: gf_c4origin[3] new Float: gf_entorigin[3] new g_c4entity new g_entillusionary new gi_soundnum new g_sounds[5][] = {     "weapons/c4_beep1.wav",     "weapons/c4_beep2.wav",     "weapons/c4_beep3.wav",     "weapons/c4_beep4.wav",     "weapons/c4_beep5.wav" } public plugin_init () {     register_plugin ( gs_PLUGIN, gs_VERSION, gs_AUTHOR )         if ( engfunc ( EngFunc_FindEntityByString, -1, "classname", "func_bomb_target" ) )     {         register_logevent ( "fn_triggerplanted" , 3, "1=triggered", "2=Planted_The_Bomb" )         register_logevent ( "fn_triggerroundstart" , 2, "1=Round_Start" )         register_forward ( FM_EmitSound, "fn_soundcheck" )     } } public fn_triggerplanted () {     gb_CheckSound = true } public fn_triggerroundstart () {     gb_CheckSound = false     if ( gb_EntReadyForUse == true )     {         engfunc ( EngFunc_RemoveEntity, g_entillusionary )         gb_EntReadyForUse = false     } } public fn_soundcheck ( entity, channel, const s_SOUND[] ) {     if ( gb_CheckSound == true )     {         for ( gi_soundnum = 0; gi_soundnum < 5; gi_soundnum++ )         {             if ( containi ( s_SOUND, g_sounds[gi_soundnum] ) != -1 )             {                 if ( gb_EntReadyForUse == true )                 {                     fn_emitsound ()                 }                                 else                 {                     fn_createentity ()                 }             }         }     }         else     {         return PLUGIN_CONTINUE     }         return PLUGIN_CONTINUE } public fn_createentity () {     g_c4entity = engfunc ( EngFunc_FindEntityByString, -1, "model", gs_C4_MODEL )     pev ( g_c4entity, pev_origin, gf_c4origin )         g_entillusionary = engfunc ( EngFunc_CreateNamedEntity, "func_illusionary" )     gf_entorigin = gf_c4origin     engfunc ( EngFunc_SetOrigin, g_entillusionary, gf_entorigin )         gb_EntReadyForUse = true         fn_emitsound () } public fn_emitsound () {     emit_sound ( g_entillusionary, CHAN_AUTO, g_sounds[gi_soundnum], 1.0, ATTN_NORM, 0, PITCH_NORM ) }
I replaced line 76
Code:
if ( find_ent_by_class ( -1, "func_bomb_target" ) )
with line 75
Code:
if ( engfunc ( EngFunc_FindEntityByString, -1, "classname", "func_bomb_target" ) )
I replaced lines 92-96
Code:
gb_EntsReadyForUse = false         if ( is_valid_ent ( g_entillusionary ) )     {         remove_entity ( g_entillusionary )
with lines 92-96
Code:
if ( gb_EntReadyForUse == true )     {         engfunc ( EngFunc_RemoveEntity, g_entillusionary )         gb_EntReadyForUse = false     }
I replaced lines 129-136
Code:
public fn_createentity () {     g_c4entity = find_ent_by_model ( -1, "grenade", gs_C4_MODEL )     entity_get_vector ( g_c4entity, EV_VEC_origin, gf_c4origin )         g_entillusionary = create_entity ( "func_illusionary" )     gf_entorigin = gf_c4origin     entity_set_origin ( g_entillusionary, gf_entorigin )
with lines 128-135
Code:
public fn_createentity () {     g_c4entity = engfunc ( EngFunc_FindEntityByString, -1, "model", gs_C4_MODEL )     pev ( g_c4entity, pev_origin, gf_c4origin )         g_entillusionary = engfunc ( EngFunc_CreateNamedEntity, "func_illusionary" )     gf_entorigin = gf_c4origin     engfunc ( EngFunc_SetOrigin, g_entillusionary, gf_entorigin )
These are the changes I made to make the plugin work with fakemeta. I am new to using engfunc and pev.

Now here is the problem when used: When I plant the bomb, I hear the beeping noise anywhere I go. The entity with classname func_illusionairy is supposed to be created in the same origin as the c4 and beep when the c4 beeps and be removed at the beginning of the next round if it was created the round before. The version using engine and fakemeta together works perfectly fine. The rewrite of it only using fakemeta is not working fine. That is the version that I hear the beeping noise from anywhere I go. Does anyone know where I went wrong in using fakemeta??? Please point me in the right direction.

Edit: TY to Fatal and VEN for helping me solve this problem. Fixed code posted at the Anti-Silent Plant plugin page.
SubStream is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-08-2006 , 19:18  
Reply With Quote #2

Try using this:

http://www.amxmodx.org/funcwiki.php?go=func&id=952

EF_EmitSound
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 05-08-2006 , 19:21  
Reply With Quote #3

would that make any difference since emit_sound is from the amxmodx core module??? Also.. I hear the sound at the time but for some reason I hear it everywhere I go.
SubStream is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 05-08-2006 , 19:22  
Reply With Quote #4

I want to know why you would go through the effort of converting from engine to FM.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 05-08-2006 , 19:24  
Reply With Quote #5

go check out the anti-silent plant forum. VEN suggested I do it and he knows more than me so I thought it was a good idea since he said so. He said I could use only fakemeta and do the same job. I personally am only getting a headache so far.

What is your suggestions Suzuka? Does switching from engine and fakemeta to only fakemeta matter that much?
SubStream is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 05-08-2006 , 20:30  
Reply With Quote #6

Generally speaking, given the choice of using engine or not using engine, it's better not to use it because if it's enabled, it'll raise your CPU usage all by itself.

Having said that, I'd reckon that most people have engine enabled already anyway and thus, using engine in your plugin wouldn't matter.

It really just boils down to principle unless there becomes a massive push to convert the majority of plugins that use engine to use fakemeta instead.
__________________
Brad is offline
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 05-08-2006 , 20:33  
Reply With Quote #7

do you have any insight Brad on how I might convert it? I understand what your point is and Suzuka said there is no point to worry about it either.. however I would like to learn where my mistakes are.
SubStream is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 05-08-2006 , 20:38  
Reply With Quote #8

I wish I did but I'm a bit fuzzy on using fakemeta in general. Engine is much easier.
__________________
Brad is offline
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 05-08-2006 , 20:40  
Reply With Quote #9

Quote:
Originally Posted by Brad
I wish I did but I'm a bit fuzzy on using fakemeta in general. Engine is much easier.
LOL... thats why I used it... I immediately understood it...
SubStream is offline
FatalisDK
Senior Member
Join Date: Mar 2006
Location: bacon
Old 05-08-2006 , 22:10  
Reply With Quote #10

Code:
g_entillusionary = engfunc ( EngFunc_CreateNamedEntity, "func_illusionary" )

->

Code:
new ClassName = engfunc( EngFunc_AllocString, "func_illusionary" ) g_entillusionary = engfunc ( EngFunc_CreateNamedEntity, ClassName )
__________________
FatalisDK 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 04:59.


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