AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bomb Planted called twice (https://forums.alliedmods.net/showthread.php?t=126359)

Apollyon 05-08-2010 14:54

Bomb Planted called twice
 
Everything works except that when I plant the bomb it seems to call the function 2 times. My chat message appears twice and I get 2 bonus kills instead of 1. What am I missing?

PHP Code:

register_logevent("eBombPlanted"3"2=Planted_The_Bomb"); 

PHP Code:

public eBombPlanted()
{
    for(new 
1<= g_iMaxPlayers; ++i)
    {    
        if(
is_user_alive(i) && get_user_team(i) == 1)
        {
            new 
frags 2;
            if(
fragsset_user_frags(i,get_user_frags(i) + frags);
    
            
ColorChat(iRED"[Badlands] ^4Bonus Frags!");
        }
    }
    return 
PLUGIN_CONTINUE;



ConnorMcLeod 05-08-2010 14:58

Re: Bomb Planted called twice
 
Either you use csx forward : http://www.amxmodx.org/funcwiki.php?go=func&id=900
Either you name your callback a different way.

Also, use get_user_frags(id) and set_user_frags(id) (<- last one from fun module) natives .

Apollyon 05-08-2010 15:15

Re: Bomb Planted called twice
 
Thanks Connor, it's working great now.

Apollyon 05-08-2010 20:26

Re: Bomb Planted called twice
 
I noticed another issue with my edited code above. I was testing with bots and noticed that when the bot planted the bomb I was able to see the "Bonus" chat message. What needs to be changed to make the message only visible to the planter.

EDIT: I just tested with a human player and have the same issue.

Using this code along with Ven's stock solved the problem.
PHP Code:

public eBombPlanted()
{
    new 
id get_loguser_index();
    
    if(
is_user_alive(id) && get_user_team(id) == 1)
    {
        new 
frags 2;
        if(
fragsset_user_frags(id,get_user_frags(id) + frags);
    
        
ColorChat(idRED"[Badlands] ^4Bonus Frags!");
    }
    return 
PLUGIN_CONTINUE;




All times are GMT -4. The time now is 03:40.

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