Raised This Month: $ Target: $400
 0% 

Variable in txt motd.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-18-2012 , 09:45   Re: Variable in txt motd.
Reply With Quote #4

Something like this:

PHP Code:
new const g_sz_const_file[] = "addons/amxmodx/configs/custom_motd.txt" // motd file path 
PHP Code:
new g_sz_motd_buffer_str[256// variable to store motd string from the file 
PHP Code:
// File doesn't exist?
if(!file_exists(g_sz_const_file)) return
 
// Open the file...static h_open
static h_open
h_open 
fopen(g_sz_const_file,"rt")
 
// Can't open it? (no access, etc...)
if(!h_open) return
 
static 
sz_buffer[256]
 
// Loop trough every line of the file... (is end reached?)
while(!feof(h_open))
{
 
// Get current line's contents into a string
 
fgets(h_open,sz_buffer,charsmax(sz_buffer))
 
 
// The line is empty?
 
if(!sz_buffer[0]) continue // continue with the next line
 
 
add(g_sz_motd_buffer_str,charsmax(g_sz_motd_buffer_str),sz_buffer// add this line to the motd string buffer
}
 
// Close the file (free it)
fclose(h_open
PHP Code:
static sz_motd_str[256// make new variable to cache the file string
 
copy(sz_motd_str,charsmax(sz_motd_str),g_sz_motd_buffer_str)
 
static 
sz_name[32]
get_user_name(id,sz_name,charsmax(sz_name)) // get user's name
 
replace_all(sz_motd_str,charsmax(sz_motd_str),"%PLAYER_NAME%",sz_name// replace %PLAYER_NAME% with user's name in the new cached string
 
show_motd(id,sz_motd_str// show the motd with this string 
__________________

Last edited by <VeCo>; 05-18-2012 at 09:45.
<VeCo> is offline
 



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:30.


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