Raised This Month: $51 Target: $400
 12% 

[HOWTO] Finding a Random Origin (Scanning)


Post New Thread Reply   
 
Thread Tools Display Modes
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-17-2010 , 14:38   Re: [HOWTO] Finding a Random Origin (Scanning)
Reply With Quote #31

Quote:
Originally Posted by drekes View Post
Sorry, but my english is not that good, i don't understand this part
The ent should be reachable at all times. So i guess i should use exolents link?
I don't think Chronic's code will guarantee that it's always reachable. If it's up on top of a box or behind a wall or something (like on de_dust, kind of but not really near the T spawn) then it can't really do anything about that.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-17-2010 , 14:41   Re: [HOWTO] Finding a Random Origin (Scanning)
Reply With Quote #32

I created some code as an example for you.

Code:
#include < amxmodx > #include < amxmisc > #include < GHW_spawnlist_gen > new bool:loaded_spawns new save_file[ 128 ] public plugin_init( ) {     get_datadir( save_file, charsmax( save_file ) )     new len = add( save_file, charsmax( save_file ), "/some_spawns" )         if( !dir_exists( save_file ) )     {         mkdir( save_file )     }         save_file[ len++ ] = '/'     get_mapname( save_file[ len ], charsmax( save_file ) - len )     add( save_file, charsmax( save_file ), ".txt" )         if( !( loaded_spawns = load_spawns( ) ) )     {         genspawnlist( 1, MAX_ORIGINS )         set_task( TIMEOUT, "save_spawns" )     } } bool:load_spawns( ) {     num_origins = 0         new f = fopen( save_file, "rt" )         if( !f )     {         return false     }         new data[ 64 ], i, char_loc         while( !feof( f ) && num_origins < MAX_ORIGINS )     {         fgets( f, data, charsmax( data ) )         trim( data )                 if( data[ 0 ] )         {             i = char_loc = 0                         do             {                 origins[ num_origins ][ i ] = str_to_float( data[ char_loc ] )             }             while( ++i < 3 && ( char_loc += ( contain( data[ char_loc ], "," ) + 1 ) ) != -1 )                         num_origins++         }     }         fclose( f )         return true } public save_spawns( ) {     loaded_spawns = num_origins > 0         new f = fopen( save_file, "wt" )         if( !f )     {         return     }         for( new i = 0; i < num_origins; i++ )     {         fprintf( f, "%f,%f,%f^n", origins[ i ][ 0 ], origins[ i ][ 1 ], origins[ i ][ 2 ] )     }         fclose( f ) } spawnCoin( id ) {     if( !loaded_spawns )     {         return     }         new spawn_index = random( num_origins )         // create entity at origins[ spawn_index ] }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 05-19-2010 at 00:32.
Exolent[jNr] is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-17-2010 , 14:45   Re: [HOWTO] Finding a Random Origin (Scanning)
Reply With Quote #33

Thanks Exolent, i think i understand it now.
I'll try it and let you know if i figured it out.

I made it. and it makes the directory in the data folder, but create the file in data folder instead of data/mario_spawns and file in named mario_spawns.txt

I did this:
PHP Code:
    // Random Item spawns
    
new len get_datadir(save_filecharsmax(save_file))
    
len += add(save_filecharsmax(save_file), "/mario_spawns")

    if(!
dir_exists(save_file))
    {
        
mkdir(save_file)
    }

    
save_file[len++] = '/'
    
    
get_mapname(save_file[len], charsmax(save_file) - len)
    
add(save_filecharsmax(save_file), ".txt")

    if(!(
loaded_spawns load_spawns()))
    {
        
genspawnlist(1MAX_ORIGINS)
        
set_task(TIMEOUT"save_spawns")
    } 
I tried with this to, same effect.
PHP Code:
    new datadir[128], mapname[33], filename[33]
    
get_datadir(datadir127)
    
    
get_mapname(mapname32)
    
    
formatex(filename33"%s/mario_spawn/%s"datadirmapname)
    
add(filenamecharsmax(filename), ".txt")
    
    if(!(
loaded_spawns load_spawns()))
    {
        
genspawnlist(1MAX_ORIGINS)
        
set_task(TIMEOUT"save_spawns")
    } 
@Hawk552:
Sorry, I looked over your post. Which will guarantee the most reachable? Yours or Chronics?
I'm having troubles with the directory, can't seem to figure it out.

EDIT: I fixed it, it works now, but as Hawk552 said: sometimes they are unreachable. Do you know how i can add like csdm spawnmaker from Chronic, the testing part to see if everything is rigth.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 05-17-2010 at 19:34.
drekes is offline
Send a message via MSN to drekes
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-19-2010 , 00:29   Re: [HOWTO] Finding a Random Origin (Scanning)
Reply With Quote #34

i have a new question:

Is there a way to determine how many spawns there are, and then do something like this:
PHP Code:
max_item_spawns // the amount of spawns

set_task(1.0"spawn_coin"___"a"max_item_spawns 2)
set_task(1.0"spawn_box"___"a"max_item_spawns 2
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-19-2010 , 00:34   Re: [HOWTO] Finding a Random Origin (Scanning)
Reply With Quote #35

Quote:
Originally Posted by drekes View Post
i have a new question:

Is there a way to determine how many spawns there are, and then do something like this:
PHP Code:
max_item_spawns // the amount of spawns

set_task(1.0"spawn_coin"___"a"max_item_spawns 2)
set_task(1.0"spawn_box"___"a"max_item_spawns 2
num_origins is the total number of origins..
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 05-19-2010 , 01:06   Re: [HOWTO] Finding a Random Origin (Scanning)
Reply With Quote #36

Thanks Exolent
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
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 21:39.


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