Raised This Month: $ Target: $400
 0% 

Chat getting spammed with levels


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
P1raten
Senior Member
Join Date: Feb 2010
Old 01-26-2013 , 09:32   Chat getting spammed with levels
Reply With Quote #1

So, I've made this plugin based an XP mod. It's the same principal as an XP mod.

Now, when people connect it prints a message for each level that they have achieved.

Let's say a player is level 16.

The plugin will loop through each level and print it out.
Code:
Player is now level 1!
Player is now level 2!
Player is now level 3!
Player is now level 4!
Player is now level 5!
// etc
This is not at all what I want it to do.

I just want it to print when someone reaches a new level.

Here's some of the code.

PHP Code:
#define MAXCLASSES 53

new const CLASS[MAXCLASSES][] =
{
    
"None",
    
"Newbie",
    {...}
};

new const 
LEVELS[52] =
{
    
0,
    
10,
    {...}
};

public 
plugin_init()
{
    
register_pluginPLUGIN_NAMEVERSION"P1raten" );
    
register_forwardFM_CmdStart"FM_CmdStart_Pre");

    
register_clcmd("say","CmdSay");

    
set_task(1.0"MySql_Init");
}

public 
client_putinserver(id)
{
    
Load_MySql(id);
    
set_task(1.0,"checkLevel",id,_,_,"b");
}

public 
checkLevel(id)
{
    new 
szName[32];

    
get_user_name(idszNamecharsmax(szName));

    while(
XP[id] >= LEVELS[Level[id]])
    {
        
plrXP[id]++;
        
ColorChat(0NORMAL"^x03%s^x01 is now level ^x04%i with %i XP!"szName, CLASS[Level[id]], plrXP[id]);
    }

Any ideas?

EDIT:

I managed to fix this by adding this:

PHP Code:
#define MAXCLASSES 53

new bool:isDone;

new const CLASS[
MAXCLASSES][] =
{
    
"None",
    
"Newbie",
    {...}
};

new const 
LEVELS[52] =
{
    
0,
    
10,
    {...}
};

public 
plugin_init()
{
    
register_pluginPLUGIN_NAMEVERSION"P1raten" );
    
register_forwardFM_CmdStart"FM_CmdStart_Pre");

    
register_clcmd("say","CmdSay");

    
set_task(1.0"MySql_Init");
}

public 
client_putinserver(id)
{
    
Load_MySql(id);
    
set_task(1.0,"checkLevel",id,_,_,"b");
}

public 
checkLevel(id)
{
    new 
szName[32];

    
get_user_name(idszNamecharsmax(szName));

    while(
XP[id] >= LEVELS[Level[id]])
    {
        
plrXP[id]++;
        
isDone true;
    }

    if(
isDone)
    {
        
ColorChat(0NORMAL"^x03%s^x01 is now level ^x04%i with %i XP!"szName, CLASS[Level[id]], plrXP[id]);
        
isDone false;
    }

__________________
No salvation. Only madness.

Last edited by P1raten; 01-26-2013 at 10:32.
P1raten is offline
Reply


Thread Tools
Display Modes

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 20:32.


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