AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to refresh stats after adding frags ? (https://forums.alliedmods.net/showthread.php?t=64124)

orglee 12-08-2007 18:49

how to refresh stats after adding frags ?
 
Hello.
I have one line of code which gives a player reward for picking up a flag:
Code:
set_user_frags(id, get_user_frags(id) + get_pcvar_num(pickupreward_frags))
But stats does not refreshes automatically. Only when player kills someone.
So how to refresh stats ?

Arkshine 12-08-2007 20:14

Re: how to refresh stats after adding frags ?
 
Using ScoreInfo event : http://wiki.alliedmods.net/Half-Life...ents#ScoreInfo

orglee 12-08-2007 22:09

Re: how to refresh stats after adding frags ?
 
Well I've searched all forums and I cannot find any part of code which will tell me how to implement this. I really don't know how can I refresh stats or use that event. I found some code examples how to check does user presses +showscores but I don't think it can help.
http://forums.alliedmods.net/showpost.php?p=455980
Code:
#include <amxmodx> #include <fakemeta> public plugin_init() {       register_plugin("Block ShowScore", "1.0", "P34nut")   register_forward(FM_PlayerPreThink, "fwPlayerPreThink") } public fwPlayerPreThink(id) {       static iButton       iButton = pev(id, pev_button)           if (iButton & IN_SCORE)           set_pev(id, pev_button, iButton & ~IN_SCORE) }
http://forums.alliedmods.net/showpos...1&postcount=10
Code:
public plugin_init() {   register_message(get_user_msgid("ScoreInfo"), "hook_ScoreInfo" ); } public hook_ScoreInfo() {     return PLUGIN_HANDLED; }

Arkshine 12-08-2007 23:08

Re: how to refresh stats after adding frags ?
 
Something like :


Code:
new g_msgScoreInfo; public plugin_init() {     g_msgScoreInfo = get_user_msgid( "ScoreInfo" ); } UpdateScoreboard( id ) {     // Update killers scorboard with new info     message_begin( MSG_ALL, g_msgScoreInfo )     write_byte( id )     write_short( get_user_frags( id ) )     write_short( get_user_deaths( id ) )     write_short( 0 )     write_short( get_user_team( id ) )     message_end() }

orglee 12-08-2007 23:22

Re: how to refresh stats after adding frags ?
 
Does it updates all players scoreboard ?

Arkshine 12-08-2007 23:29

Re: how to refresh stats after adding frags ?
 
message_begin( MSG_ALL, g_msgScoreInfo ) . So yes, it does.

orglee 12-08-2007 23:44

Re: how to refresh stats after adding frags ?
 
Thank you it works for me perfectly :)


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

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