AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Saving Created entities (https://forums.alliedmods.net/showthread.php?t=162954)

r0ck 07-25-2011 00:49

Saving Created entities
 
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 :)

Hunter-Digital 07-25-2011 03:09

Re: Saving Created entities
 
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.

r0ck 07-25-2011 09:17

Re: Saving Created entities
 
i have done it anyway thnks :) and it creates on it own also

Hunter-Digital 07-25-2011 09:44

Re: Saving Created entities
 
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.

r0ck 07-25-2011 13:03

Re: Saving Created entities
 
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;




All times are GMT -4. The time now is 00:56.

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