AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Where is wrong? help me ! thanks! (https://forums.alliedmods.net/showthread.php?t=63989)

griefhy 12-05-2007 10:21

Where is wrong? help me ! thanks!
 
#include <amxmodx>
#include <amxmisc>
#include <csstats>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"

#define MAX_NAME_LENGTH 31

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("SendAudio", "EndRoundShow", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin", "2=%!MRAD_rounddraw")

return PLUGIN_CONTINUE
}

public EndRoundShow()
{
new g_stats[8]
new g_hits[8]
new players[32]
new num
get_players(players, num)

for(new i = 0; i < num; i++)
{
new player
player = players[i]
new name[MAX_NAME_LENGTH+1]
get_user_name(player,name,MAX_NAME_LENGTH)
get_user_rstats(player,g_stats,g_hits)
client_print(0,print_chat,"[%s] kills [%d]",name,g_stats[0])
}

return PLUGIN_CONTINUE
}

Do this section of codes have any wrong place? Why can't export correctly?Please help me ,thanks!!!!

ConnorMcLeod 12-05-2007 10:46

Re: Where is wrong? help me ! thanks!
 
Don't create a var in a loop.
Also chat can only show 5 lines.

Code:
#include <amxmodx> #include <amxmisc> #include <csstats> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" #define MAX_NAME_LENGTH 31 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("SendAudio", "EndRoundShow", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin", "2=%!MRAD_rounddraw") } public EndRoundShow() {     new g_stats[8]     new g_hits[8]     new players[32]     new player     new name[MAX_NAME_LENGTH+1]     new num     get_players(players, num)     for(new i = 0; i < num; i++)     {         player = players[i]         get_user_name(player,name,MAX_NAME_LENGTH)         get_user_rstats(player,g_stats,g_hits)         client_print(0,print_chat,"[%s] kills [%d]",name,g_stats[0])     } }

You should make a hud_message rather than chat message.

griefhy 12-05-2007 21:50

Re: Where is wrong? help me ! thanks!
 
thanks!
but,
if player1 kill player2
show : [player1] kills [0]
[player2] kills [0]

not
[player1] kills [1]

why ???

Arkshine 12-05-2007 22:10

Re: Where is wrong? help me ! thanks!
 
Try this. If I understand you want to display player's frags. So, using get_user_frags() should be enough.

Code:
#include <amxmodx> public plugin_init() {     register_plugin( "Show kills", "1.0", "Amxx Community" );     register_event( "SendAudio", "EndRoundShow", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin", "2=%!MRAD_rounddraw" ); } public EndRoundShow() {     static iPlayers[32], sUser_name[32], iNum, iPid;     get_players( iPlayers, iNum );     for( new i; i < iNum; i++ )     {         iPid = iPlayers[i];         get_user_name( iPid, sUser_name, 31 );         client_print( iPid, print_chat, "[%s] kills [%d]", sUser_name, get_user_frags( iPid ) );     } }

griefhy 12-05-2007 22:34

Re: Where is wrong? help me ! thanks!
 
-_-!!

thanks,this is not my meaning!
I want to do :
show kills,headshots in the every Round ,use "get_user_rstats"
like:
Code:

client_print(id,"kills %d,headshots %d",stats[0],stats[2])

If player1 kill player2

this is right:
Code:

register_clcmd("say /test","show",0)
public show(id)
{
get_user_rstats(id,stats,bodyhits)
client_print(id,print_chat,"kill %d,headshots %d",,stats[0],stats[2])
}

show:[player1] kills [1]

but this is wrong:
Code:

for(new i = 0; i < num; i++)
{
        player = players[i]
        get_user_name(player,name,MAX_NAME_LENGTH)
        get_user_rstats(player,g_stats,g_hits)
        client_print(player,print_chat,"[%s] kills [%d]",name,g_stats[0])
}

show:[player1] kills [0]

why ???

Arkshine 12-05-2007 22:49

Re: Where is wrong? help me ! thanks!
 
Probably because stats are updated at new round only, not in real time. get_user_rstats() gets round stats of player.

Try to print message at new round, not end round.

griefhy 12-06-2007 06:11

Re: Where is wrong? help me ! thanks!
 
thanks ,I try....
You are right, put in new round ,The ALL right!
but , I find as good as a play thing,
if in the endround,
only stats[6] is right.....


All times are GMT -4. The time now is 11:02.

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