Quote:
Originally Posted by Elusive13
Can you explain to me exactly how this works, that is, what exactly you do to make things happen or what to read to learn it.
What is this "i"before "File" var,what mean that g_szMessage or szFile
|
PHP Code:
#include <amxmodx>
#include <amxmisc>
#if !defined MAX_FMT_LENGTH
const MAX_FMT_LENGTH = 192 // Max Message length
#endif
new g_szMessage[ MAX_FMT_LENGTH ]; // String variable to store the message from the file
public plugin_init( )
{
register_plugin( "Welcome Message", "1.0", "Supremache" )
ReadWelcomeMessageFile( ); // Read the file
}
public client_putinserver( id )
{
set_task( 10.0, "OnConnectMessage", id ); // Display the message when the client connects to the server
}
public OnConnectMessage( id )
{
set_hudmessage( 0, 80, 255, -1.0, 0.18, 2, 3.0, 15.0, 0.1, 1.5, false )
show_hudmessage( id, g_szMessage ) // Put the message that was stored from the file
}
ReadWelcomeMessageFile( )
{
new g_szFile[ 128 ]; // Create a variable to store the location of the file
get_configsdir( g_szFile, charsmax( g_szFile ) ) // the location of the confing folder
add( g_szFile, charsmax( g_szFile ), "/WelcomeMessages.ini" ) // add the file name
new iFile = fopen( g_szFile, "rt" ); // Open the file
if( iFile ) // If the file exist
{
new szData[ MAX_FMT_LENGTH ]; // Create variable to store the data from the file
while( fgets( iFile, szData, charsmax( szData ) ) ) // Get the date from the file
{
trim( szData ); // remove space
switch( szData[ 0 ] )
{
case EOS, ';', '#', '/': continue; // Block these symbols
default:
{
copy( g_szMessage, charsmax( g_szMessage ), szData ) // store the message from the file
replace_all( g_szMessage, charsmax( g_szMessage ), "!n", "^n" ) // Replace field !n to ^n if you want to add line
}
}
}
fclose( iFile ); // Close the file
}
}
__________________