AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hud message problems. (https://forums.alliedmods.net/showthread.php?t=135373)

GarbageBox 08-15-2010 11:28

Hud message problems.
 
When I test it, it does not show any hud message.
I just want to show the info of the dead player who looking for an alive player.
Here is my code, can someone fix?
Code:

#include <amxmodx>
#include <amxmisc>
#include <csx>
#include <cstrike>
#include <csstats>
#include <geoip>

#define PLUGIN_NAME "Dead Hud Message"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "WS.Chu"
new SzAddCmd[] = "amx_pausecfg add ^"%s^""

public plugin_init()
{
        register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
        register_event("HLTV", "new_round", "a", "1=0", "2=0")
        register_event("TextMsg", "restart_round", "a", "2=#Game_will_restart_in")
        set_task(1.0, "DHM",0,"",0,"b")
        return PLUGIN_CONTINUE
}

public plugin_cfg()
{
        // Put here titles of plugins which you don't want to pause
        server_cmd(SzAddCmd, "Dead Hud Message")
}

public DHM(id)
{
                new SzHostname[64], SzTimer[32] // Get Hostname & Time
                get_cvar_string("Hostname",SzHostname,63) // Get Hostname
                get_time("%Y/%m/%d - %H:%M:%S", SzTimer,31) // Get Time
               
                new SzName[128] // Get Player Name
                get_user_name(id, SzName, 127) // Get Player Name
               
                new SzAuthID[32] // Get STEAMID
                get_user_authid(id, SzAuthID, 32) // Get STEAMID
               
                new SzScores = (get_user_frags(id) - cs_get_user_deaths(id)) // Get Player Scores
               
                new mOsef[8], SzRank // Get Player Rank
                SzRank = get_user_stats(id, mOsef, mOsef) // Get Player Rank
               
                new SzIP[16] // Get Player IP
                static SzCountry[32] // Get Player Country
                get_user_ip(id, SzIP, 15, 1) // Get Player IP
                geoip_country(SzIP, SzCountry, 45) // Get Player Country By Using The IP
               
                set_hudmessage(random_num(0,255), random_num(0,255), random_num(0,255), 0.05, 0.60, 2, 1.0, 1.0, 0.1, 0.2, -1)
                show_hudmessage(Player,"%s^nTime: %s^nPlayer Name: %s^nID: %s^n分數: %d^nRank: %i / %i^nCountry: %s", SzHostname, SzTimer, SzName, SzAuthID, SzScores, SzRank, get_statsnum(), SzCountry)
}


Arkshine 08-15-2010 11:45

Re: Hud message problems.
 
The player's id can not appear by magic from such task. You have to loop through all players.

GarbageBox 08-15-2010 22:33

Re: Hud message problems.
 
How can I correct it?
I`m a code newbie...

RedRobster 08-15-2010 23:08

Re: Hud message problems.
 
Quote:

Originally Posted by Arkshine (Post 1271543)
You have to loop through all players.


Mxnn 08-15-2010 23:24

Re: Hud message problems.
 
Quote:

Originally Posted by RedRobster (Post 1272222)
Quote:

Originally Posted by Arkshine (Post 1271543)
You have to loop through all players.


Quote:

Originally Posted by GarbageBox (Post 1272201)
I`m a code newbie...

PHP Code:

new maxplayers get_maxplayers()
for (new 
1i<= maxplayersi++) {
         
//Here your stuff
         //i var, represents the player id



RedRobster 08-15-2010 23:32

Re: Hud message problems.
 
And you are showing him wrong.
If you are going to do it that way, create "maxplayers" as a global variable and get the value in plugin_init() since that will not change during that map.

Also, you must do:
PHP Code:

for(new 1<= maxplayersi++)
{
        
//Your stuff


0 is the server id.

GarbageBox 08-16-2010 01:16

Re: Hud message problems.
 
Here is the code what I have edited.
But still nothing show, something wrong?
Code:

#include <amxmodx>
#include <amxmisc>
#include <csx>
#include <cstrike>
#include <csstats>
#include <geoip>

#define PLUGIN_NAME "Dead Hud Message"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "WS.Chu"
new SzAddCmd[] = "amx_pausecfg add ^"%s^""
new MaxPlayers

public plugin_init()
{
        register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
        register_event("HLTV", "new_round", "a", "1=0", "2=0")
        register_event("TextMsg", "restart_round", "a", "2=#Game_will_restart_in")
        MaxPlayers = get_maxplayers()
        set_task(1.0, "DHM",0,"",0,"b")
        return PLUGIN_CONTINUE
}

public plugin_cfg()
{
        // Put here titles of plugins which you don't want to pause
        server_cmd(SzAddCmd, "Dead Hud Message")
}

public DHM(id)
{
        for (new i = 1; i <= SzMaxPlayers; i++)
        {
                new SzHostname[64], SzTimer[32] // Get Hostname & Time
                get_cvar_string("Hostname",SzHostname,63) // Get Hostname
                get_time("%Y/%m/%d - %H:%M:%S", SzTimer,31) // Get Time
               
                new SzName[128] // Get Player Name
                get_user_name(id, SzName, 127) // Get Player Name
               
                new SzAuthID[32] // Get STEAMID
                get_user_authid(id, SzAuthID, 32) // Get STEAMID
               
                new SzScores = (get_user_frags(id) - cs_get_user_deaths(id)) // Get Player Scores
               
                new mOsef[8], SzRank // Get Player Rank
                SzRank = get_user_stats(id, mOsef, mOsef) // Get Player Rank
               
                new SzIP[16] // Get Player IP
                static SzCountry[32] // Get Player Country
                get_user_ip(id, SzIP, 15, 1) // Get Player IP
                geoip_country(SzIP, SzCountry, 45) // Get Player Country By Using The IP
               
                set_hudmessage(random_num(0,255), random_num(0,255), random_num(0,255), 0.05, 0.60, 2, 1.0, 1.0, 0.1, 0.2, -1)
                show_hudmessage(MaxPlayers, "%s^nTime: %s^nPlayer Name: %s^nID: %s^n分數: %d^nRank: %i / %i^nCountry: %s", SzHostname, SzTimer, SzName, SzAuthID, SzScores, SzRank, get_statsnum(), SzCountry)
        }
}



All times are GMT -4. The time now is 22:00.

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