AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hud_showmessage not showing up (https://forums.alliedmods.net/showthread.php?t=74734)

skis 07-23-2008 21:18

hud_showmessage not showing up
 
Can anyone please check out my code and figure out why hud_showmessage isn't showing up to the person who picked up the bomb? No errors are coming up in the server log when someone picks the bomb up.

Also, is there a way to show the message to everybody instead of just the player who picks it up? (I'm assuming in the "id" parameter of the "public bombpickup(id)" function that metamod is passing the id of the player who made the event fire in the first place? Is that how it works?)

Here's my code:

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "mod_name_goes_here"
#define VERSION "1.0"
#define AUTHOR "author_name_goes_here"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("bombdrop"3"2=Dropped_The_Bomb");
    
register_logevent("bombpickup"3"2=Got_The_Bomb");
}

public 
bombdrop(id) {
    
//not written yet
    
return PLUGIN_CONTINUE;
}

public 
bombpickup(id) {
    new 
players[32];
    new 
numi;
    
get_players(playersnum"e""TERRORIST");
    for(
1;numi++) {
        new 
weapons[32];
        new 
numweaponsj;
        
get_user_weapons(iweaponsnumweapons);
        for (
0numweaponsj++) {
            if (
equal(weapons[j],"weapon_c4")) {
                
set_hudmessage(25500, -1.00.01)
                
show_hudmessage(id"you picked up the bomb")
            }
        }
    }
    return 
PLUGIN_CONTINUE;


Thanks

Exolent[jNr] 07-23-2008 21:31

Re: hud_showmessage not showing up
 
Change:
Code:
if(equal(weapons[j],"weapon_c4"))
To:
Code:
if(weapons[j]==CSW_C4)

skis 07-23-2008 21:37

Re: hud_showmessage not showing up
 
That compiles and doesn't cause any errors when the bomb is picked up, but it also doesn't show the message on the screen when the bomb is picked up.

Exolent[jNr] 07-23-2008 21:41

Re: hud_showmessage not showing up
 
http://forums.alliedmods.net/showthread.php?t=40164

skis 07-23-2008 22:19

Re: hud_showmessage not showing up
 
OK, I changed to fakemeta to find who has the bomb using the script from that thread. The message is still not displaying on the screen. Is there a way to show the message to every player so I can see if it's just sending it to the wrong player?

Here's my code now:

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta_util>

#define PLUGIN "mod_name_goes_here"
#define VERSION "1.0"
#define AUTHOR "author_goes_here"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("bombdrop"3"2=Dropped_The_Bomb");
    
register_logevent("bombpickup"3"2=Got_The_Bomb");
}

public 
bombdrop() {
    return 
PLUGIN_CONTINUE;
}

public 
bombpickup(id) {
    new 
carrier 0ownerentbomb fm_find_ent_by_class(-1"weapon_c4");
    if (
bomb && (ownerent pev(bombpev_owner)) <= get_maxplayers()) {
        
carrier ownerent;
    }
    if (
carrier) {
        
set_hudmessage(25500, -1.00.01)
        
show_hudmessage(id"you picked up the bomb")
        return 
PLUGIN_CONTINUE;
    } else {
        return 
PLUGIN_CONTINUE;
    }
    return 
PLUGIN_CONTINUE;



Jon 07-24-2008 05:49

Re: hud_showmessage not showing up
 
Quote:

Originally Posted by skis (Post 657609)
Is there a way to show the message to every player so I can see if it's just sending it to the wrong player?

Change:
Code:

show_hudmessage(id, "you picked up the bomb")

To (0 = everyone)
Code:

show_hudmessage(0, "you picked up the bomb")

hzqst 07-24-2008 08:33

Re: hud_showmessage not showing up
 
why not using "cs_get_user_plant(index)"?

skis 07-24-2008 17:26

Re: hud_showmessage not showing up
 
OK, I changed to cs_get_user_plant and here's what I've got now, along with server_prints to see what exactly is getting called:

PHP Code:

public bombpickup(id)
{
    
server_print("bombpickup called");
    new 
max get_maxplayers();
    for (new 
1<= maxi++)
    {
        
server_print("checking id %d"i);
        if (
cs_get_user_plant(i) == 1)
        {
            
server_print("match for id %d"i);
            
set_hudmessage(25500, -1.00.01);
            
show_hudmessage(0"someone picked up the bomb");
            return 
PLUGIN_CONTINUE;
        }
    }
    return 
PLUGIN_CONTINUE;


Every time the bomb is picked up, this is what happens in the server console (16 slot server):

Code:

bombpickup called
checking id 1
checking id 2
checking id 3
checking id 4
checking id 5
checking id 6
checking id 7
checking id 8
checking id 9
checking id 10
checking id 11
checking id 12
checking id 13
checking id 14
checking id 15
checking id 16

Are all my returns correct, or does anyone see anything wrong with this code?

Jon 07-25-2008 08:57

Re: hud_showmessage not showing up
 
"cs_get_user_plant - Returns 1 if a player can plant the bomb"

Doesn't that mean the player has to be standing on the bombsite with the C4 icon blinking red?


All times are GMT -4. The time now is 05:38.

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