Raised This Month: $ Target: $400
 0% 

missed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
007asha
Member
Join Date: Mar 2010
Old 10-22-2010 , 09:02   missed
Reply With Quote #1

missed

Last edited by 007asha; 10-18-2016 at 04:48.
007asha is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 10-22-2010 , 13:35   Re: [Req] Every X minutes change "game name"
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <fakemeta>
 
new const g_szFile[] = "dgn.ini"// This should be located in game's directory
 
new Array:g_aList;
new 
g_szCurrent[64]; // Don't know the limit of characters for game name
new g_iCount;
new 
g_iNext;
 
new 
g_pType;
new 
g_pInterval;
 
public 
plugin_init()
{
        
register_plugin("Dynamic Game Name""1.0""hleV");
 
        
g_pType register_cvar("amx_dgn_type""0"); // 0 - one by one, 1 - random
        
g_pInterval register_cvar("amx_dgn_interval""5.0"); // In minutes
        
g_aList ArrayCreate(sizeof(g_szCurrent), 1);
 
        new 
pFile fopen(g_szFile"r");
 
        if (!
pFile)
                return;
 
        new 
szData[sizeof(g_szCurrent)];
 
        while (!
feof(pFile))
        {
                
fgets(pFileszDatacharsmax(g_szCurrent));
                
trim(szData);
 
                if (
szData[0] == ';' || (szData[0] == '/' && szData[1] == '/'))
                        continue;
 
                
ArrayPushString(g_aListszData);
 
                
g_iCount++;
        }
 
        
register_forward(FM_GetGameDescription"fnGetGameDescription");
 
        
fnUpdateGameName();
}
 
public 
fnGetGameDescription()
{
        
forward_return(FMV_STRINGg_szCurrent);
 
        return 
FMRES_SUPERCEDE;
}
 
public 
fnUpdateGameName()
{
        switch (
get_pcvar_num(g_pType))
        {
                case 
0ArrayGetString(g_aList, ++g_iNext g_iCount g_iNext : (g_iNext 0), g_szCurrentcharsmax(g_szCurrent));
                case 
1ArrayGetString(g_aList, (g_iNext random(g_iCount)), g_szCurrentcharsmax(g_szCurrent));
        }
 
        
set_task(get_pcvar_float(g_pInterval) * 60.0"fnUpdateGameName");

Attached Files
File Type: sma Get Plugin or Get Source (dynamicgamename.sma - 631 views - 1.4 KB)
__________________

Last edited by hleV; 10-22-2010 at 13:38.
hleV is offline
Old 10-22-2010, 21:30
007asha
This message has been deleted by 007asha.
Old 10-22-2010, 23:31
007asha
This message has been deleted by 007asha.
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 10-23-2010 , 06:07   Re: [Req] Every X minutes change "game name"
Reply With Quote #3

Oh how I hate such randomizing.
Code:
#include <amxmodx> #include <fakemeta> new const g_szFile[] = "dgn.ini"; // This should be located in game/mod's directory new Array:g_aList; new g_szCurrent[64]; // Don't know the limit of characters for game name new g_iCount; new g_iNext; new g_pType; new g_pInterval; public plugin_init() {         register_plugin("Dynamic Game Name", "1.1", "hleV");         g_pType = register_cvar("amx_dgn_type", "1"); // 0 - one by one, 1 - random         g_pInterval = register_cvar("amx_dgn_interval", "5.0"); // In minutes         g_aList = ArrayCreate(sizeof(g_szCurrent), 1);         new pFile = fopen(g_szFile, "r");         if (!pFile)                 return;         new szData[sizeof(g_szCurrent)];         while (!feof(pFile))         {                 fgets(pFile, szData, charsmax(g_szCurrent));                 trim(szData);                 if (szData[0] == ';' || (szData[0] == '/' && szData[1] == '/'))                         continue;                 ArrayPushString(g_aList, szData);                 g_iCount++;         }         register_forward(FM_GetGameDescription, "fnGetGameDescription");         fnUpdateGameName(); } public fnGetGameDescription() {         forward_return(FMV_STRING, g_szCurrent);         return FMRES_SUPERCEDE; } public fnUpdateGameName() {         switch (get_pcvar_num(g_pType))         {                 case 0:                         ArrayGetString(g_aList, g_iCount == 1 ? 0 : ++g_iNext < g_iCount ? g_iNext : (g_iNext = 0), g_szCurrent, charsmax(g_szCurrent));                 case 1:                 {                         if (g_iCount > 1)                                 while (g_iNext == (g_iNext = random(g_iCount))) {}                         else                                 g_iNext = 0;                         ArrayGetString(g_aList, g_iNext, g_szCurrent, charsmax(g_szCurrent));                 }         }         set_task(get_pcvar_float(g_pInterval) * 60.0, "fnUpdateGameName"); }
Attached Files
File Type: sma Get Plugin or Get Source (dynamicgamename.sma - 609 views - 1.6 KB)
__________________

Last edited by hleV; 10-23-2010 at 11:31. Reason: Changed g_iNext with g_iCount in highlighted line.
hleV is offline
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 09:11.


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