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

SMC parser


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-04-2020 , 14:16   SMC parser
Reply With Quote #1

Are there any SMC tutorials that I might be looking at? I am trying to read the file below, but I have some problems.

PHP Code:
Section 1 <--- Catch this
{
    [
Name 1] <--- Catch this
    
{
        
"x" <----- value 1    "x" <----- value 2    "x" <----- value 3
    
}
    [
Name 2]
    {
        
"x" <----- value 1    "x" <----- value 2    "x" <----- value 3
    
}
}

Section 2 <--- Catch this
{
    [
Name 1] <--- Catch this
    
{
        
"x" <----- value 1    "x" <----- value 2    "x" <----- value 3
    
}

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 12-04-2020 at 14:16.
iceeedr is offline
Send a message via Skype™ to iceeedr
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-04-2020 , 14:38   Re: SMC parser
Reply With Quote #2

show what have you tried.


here's an example structure of how the code will be

Code:
while ( reading file )
{
    if( iStatus == SECTIONS_SEEK )
    {
        Create an Array and set its section name.
        iStatus = SECTION_CATEGORIES // next step
    }
    else if( iStatus == SECTION_CATEGORIES && First_character == '[' )
    {
              copy the name etc....
     }
     etc.....
}
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-04-2020 at 14:46.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-04-2020 , 14:46   Re: SMC parser
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
show what have you tried.
As I said, I didn't find any tutorials and I didn't understand how it works...

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0.0-2"
#define AUTHOR  "iceeedR"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
}

public 
plugin_cfg()
{
    
ReadIni()
}

public 
ReadIni()
{
    new 
szFilename[MAX_FMT_LENGTH]
    
get_configsdir(szFilenamecharsmax(szFilename))
    
add(szFilenamecharsmax(szFilename), "/FileSMC.rc")
    
    if(
file_exists(szFilename))
    {
        new 
SMCParser:hHandle SMC_CreateParser();
        
        if(
hHandle != Invalid_SMCParser)
        {
            
SMC_SetReaders(hHandle,"SMC_OnKeyValue")
            
SMC_ParseFile(hHandleszFilename)
        }
        
        
SMC_DestroyParser(hHandle);
    }
}

public 
SMCResult:SMC_OnKeyValue(SMCParser:hHandle, const FirstBlock[], const SecondBlock[])
{
    
server_print("%s %s"FirstBlockSecondBlock)    
    return 
SMCParse_Continue;

PHP Code:
Section 1 <--- Catch this
{
    [
Name 1] <--- Catch this
    
{
        
"x" <----- value 1    "x" <----- value 2    "x" <----- value 3
    
}
    [
Name 2]
    {
        
"x" <----- value 1    "x" <----- value 2    "x" <----- value 3
    
}
}

Section 2 <--- Catch this
{
    [
Name 1] <--- Catch this
    
{
        
"x" <----- value 1    "x" <----- value 2    "x" <----- value 3
    
}

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 12-04-2020 at 14:47.
iceeedr is offline
Send a message via Skype™ to iceeedr
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-04-2020 , 14:47   Re: SMC parser
Reply With Quote #4

i forgot that the latest amxmodx version support smc parsing.


Edit i found an example here you go..

from the first TRY

https://github.com/alliedmodders/amx...parse_test.sma
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-04-2020 at 14:50.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-04-2020 , 14:52   Re: SMC parser
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
i forgot that the latest amxmodx version support smc parsing.


Edit i found an example here you go..

from the first TRY

https://github.com/alliedmodders/amx...parse_test.sma
I found this example too, (I actually looked over it), but it seems that smc only reads 2 columns "var" and "value", I have doubts about reading 3 columns.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-04-2020 , 14:57   Re: SMC parser
Reply With Quote #6

why you dont use then this method. you will parse the values latter in the function

Code:
Section 1 {     [Name 1]     {         "A B C"     } }


try and test the script with your syntax and post the results.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-04-2020 at 14:59.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-04-2020 , 17:11   Re: SMC parser
Reply With Quote #7

Quote:
Originally Posted by Natsheh View Post
why you dont use then this method. you will parse the values latter in the function

Code:
Section 1 {     [Name 1]     {         "A B C"     } }


try and test the script with your syntax and post the results.

Code:
L 12/04/2020 - 19:10:35: -------- Mapchange to de_dust2 --------
L 12/04/2020 - 19:10:36: [smctest.amxx] ReadCore_ParseStart
L 12/04/2020 - 19:10:36: [smctest.amxx] 	ReadCore_NewSection - Section1
L 12/04/2020 - 19:10:36: [smctest.amxx] 	ReadCore_NewSection - [Name 1]
L 12/04/2020 - 19:10:36: [smctest.amxx] ReadCore_ParseEnd - halted: yes, failed: no
L 12/04/2020 - 19:10:36: [smctest.amxx] Line contained too many invalid tokens
L 12/04/2020 - 19:10:36: [smctest.amxx] 	Tests successful: 8/33
Code:
"Section1"
{
	"[Name 1]"
	{
		"value1 n1"	"value2 n1"	"value3 n1"
	}
	"[Name 2]"
	{
		"value1 n2"	"value2 n2"	"value3 n2"
	}
}
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Reply



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 19:17.


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