Raised This Month: $ Target: $400
 0% 

Saving Created entities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 07-25-2011 , 00:49   Saving Created entities
Reply With Quote #1

how can i save an entity say abc for that specific map in a file ? like if i make an entity in a specific map and specific positions with some angle and if i press save it should and save and on map restart i dont have to create that again ?
thanks
__________________
Preparing to release my plugins..
r0ck is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-25-2011 , 03:09   Re: Saving Created entities
Reply With Quote #2

Search for plugins that save to file, there are alot of them.

And you must re-create the entity with the data from the file anyway, you can't expect it to be created on it's own.
__________________
Hunter-Digital is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 07-25-2011 , 09:17   Re: Saving Created entities
Reply With Quote #3

i have done it anyway thnks and it creates on it own also
__________________
Preparing to release my plugins..
r0ck is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-25-2011 , 09:44   Re: Saving Created entities
Reply With Quote #4

Hmm, I think you're refering to creating entity by using commands... I was refering by creating entity using specific code because I thought you meant saving the entities and loading them from a file... like the .BSP map loads it's integrated entities automatically.

Still, you could link what you've found or post the code for people who stunble upon this thread and want to know aswell.
__________________
Hunter-Digital is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 07-25-2011 , 13:03   Re: Saving Created entities
Reply With Quote #5

got from xpaws jailbreak football plugin
http://forums.alliedmods.net/showthread.php?t=155255

ITS just an example of ball entity

LOADING FROM FILE

PHP Code:

get_mapname
g_szMapname31 );
    
strtolowerg_szMapname );
    
    
// File
    
new szDatadir64 ];
    
get_localinfo"amxx_datadir"szDatadircharsmaxszDatadir ) );
    
    
formatexszDatadircharsmaxszDatadir ), "%s"szDatadir );
    
    if( !
dir_existsszDatadir ) )
        
mkdirszDatadir );
    
    
formatexg_szFilecharsmaxg_szFile ), "%s/ball.ini"szDatadir );
    
    if( !
file_existsg_szFile ) ) {
        
write_fileg_szFile"// Ball Spawn Editor", -);
        
write_fileg_szFile" ", -);
        
        return; 
// We dont need to load file
    
}
    
    new 
szData256 ], szMap32 ], szOrigin][ 16 ];
    new 
iFile fopeng_szFile"rt" );
    
    while( !
feofiFile ) ) {
        
fgetsiFileszDatacharsmaxszData ) );
        
        if( !
szData] || szData] == ';' || szData] == ' ' || ( szData] == '/' && szData] == '/' ) )
            continue;
        
        
parseszDataszMap31szOrigin], 15szOrigin], 15szOrigin], 15 );
        
        if( 
equalszMapg_szMapname ) ) {
            new 
Float:vOrigin];
            
            
vOrigin] = str_to_floatszOrigin] );
            
vOrigin] = str_to_floatszOrigin] );
            
vOrigin] = str_to_floatszOrigin] );
            
            
CreateBall0vOrigin );
            
            
g_vOrigin vOrigin;
            
            break;
        }
    }
    
    
fcloseiFile );

SAVING

PHP Code:

{
            new 
iBalliEntityFloat:vOrigin];
            
            while( ( 
iEntity find_ent_by_classiEntityg_szBallName ) ) > )
                
iBall iEntity;
            
            if( 
iBall )
                
entity_get_vectoriBallEV_VEC_originvOrigin );
            else
                return 
PLUGIN_HANDLED;
            
            new 
bool:bFoundiPosszData32 ], iFile fopeng_szFile"r+" );
            
            if( !
iFile )
                return 
PLUGIN_HANDLED;
            
            while( !
feofiFile ) ) {
                
fgetsiFileszData31 );
                
parseszDataszData31 );
                
                
iPos++;
                
                if( 
equalszDatag_szMapname ) ) {
                    
bFound true;
                    
                    new 
szString256 ];
                    
formatexszString255"%s %f %f %f"g_szMapnamevOrigin], vOrigin], vOrigin] );
                    
                    
write_fileg_szFileszStringiPos );
                    
                    break;
                }
            }
            
            if( !
bFound )
                
fprintfiFile"%s %f %f %f^n"g_szMapnamevOrigin], vOrigin], vOrigin] );
            
            
fcloseiFile );
            
            
client_printidprint_chat"* Successfully saved ball!" );
        }
        default: return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_HANDLED;

__________________
Preparing to release my plugins..

Last edited by r0ck; 07-25-2011 at 14:16.
r0ck 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 00:56.


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