Raised This Month: $12 Target: $400
 3% 

Solved reset score, add hud function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 01-05-2021 , 10:56   reset score, add hud function
Reply With Quote #1

hi, if anyone could add a little something for me on this plugin, i use a simple resetscore plugin on my server, i want to add a cool feature

i want to show on hud for whoever is spectating the player, how many time he has used the command, like

player has used the resetscore 3 times

can be on the top right corner, but the position is not important as i can change to where it fits better, if any one can add this for me plz

PHP Code:
#include <amxmodx>
#include <reapi>

#define PLUGIN     "resetscore(ReAPI)"
#define VERSION "1.0"
#define AUTHOR  "modders"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say .rr""resetscore");
    
register_clcmd("say_team .rr""resetscore");
    
register_clcmd("say /rs""resetscore");
    
register_clcmd("say /resetscore""resetscore");
}

public 
resetscore(id) {
    if(!
is_user_connected(id)) return;

    
set_entvar(idvar_frags0.0);
    
set_member(idm_iDeaths0);

    
client_print_color(idprint_team_blue"^3Score Resetado!");
    
client_cmd(id"spk fvox/buzz.wav");

    
message_begin(MSG_ALL85);
    
write_byte(id);
    
write_short(0); write_short(0); write_short(0); write_short(0);
    
message_end();

thanks

Last edited by tarsisd2; 01-12-2021 at 03:42.
tarsisd2 is offline
YonatanM
New Member
Join Date: Dec 2020
Old 01-06-2021 , 02:10   Re: reset score, add hud function
Reply With Quote #2

Code:
#include <amxmodx>
#include <reapi>
#include <dhudmessage>

#define PLUGIN     "resetscore(ReAPI)"
#define VERSION "1.0"
#define AUTHOR  "modders"

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_clcmd("say .rr", "resetscore");
    register_clcmd("say_team .rr", "resetscore");
    register_clcmd("say /rs", "resetscore");
    register_clcmd("say /resetscore", "resetscore");
}

public resetscore(id) {
    if(!is_user_connected(id)) return;

    set_entvar(id, var_frags, 0.0);
    set_member(id, m_iDeaths, 0);
    
    set_dhudmessage(random(256), random(256), 
    random(256), -1.0, 0.72, 2, 6.0, 3.0, 0.1, 1.5);
    show_dhudmessage(id, "^nYour Prefix");
    set_dhudmessage(random(256), random(256), 
    random(256), -1.0, 0.79, 2, 6.0, 3.0, 0.1, 1.5);
    show_dhudmessage(id, "You have reset your score.");

    client_print_color(id, print_team_blue, "^3Score Resetado!");
    client_cmd(id, "spk fvox/buzz.wav");

    message_begin(MSG_ALL, 85);
    write_byte(id);
    write_short(0); write_short(0); write_short(0); write_short(0);
    message_end();
}

Last edited by YonatanM; 01-06-2021 at 02:12.
YonatanM is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 01-06-2021 , 02:16   Re: reset score, add hud function
Reply With Quote #3

Quote:
Originally Posted by YonatanM View Post
Code:
#include <amxmodx>
#include <reapi>
#include <dhudmessage>

#define PLUGIN     "resetscore(ReAPI)"
#define VERSION "1.0"
#define AUTHOR  "modders"

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_clcmd("say .rr", "resetscore");
    register_clcmd("say_team .rr", "resetscore");
    register_clcmd("say /rs", "resetscore");
    register_clcmd("say /resetscore", "resetscore");
}

public resetscore(id) {
    if(!is_user_connected(id)) return;

    set_entvar(id, var_frags, 0.0);
    set_member(id, m_iDeaths, 0);
    
    set_dhudmessage(random(256), random(256), 
    random(256), -1.0, 0.72, 2, 6.0, 3.0, 0.1, 1.5);
    show_dhudmessage(id, "^nYour Prefix");
    set_dhudmessage(random(256), random(256), 
    random(256), -1.0, 0.79, 2, 6.0, 3.0, 0.1, 1.5);
    show_dhudmessage(id, "You have reset your score.");

    client_print_color(id, print_team_blue, "^3Score Resetado!");
    client_cmd(id, "spk fvox/buzz.wav");

    message_begin(MSG_ALL, 85);
    write_byte(id);
    write_short(0); write_short(0); write_short(0); write_short(0);
    message_end();
}
thanks for your reply but its not what i want, i don`t want to notify the player when he resets his score, i want the player spectating to see how many times that player has used the reset command

like if i`m watching you play, i can see on hud how many times you used the resetscore in that map
tarsisd2 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-06-2021 , 16:53   Re: reset score, add hud function
Reply With Quote #4

Not tested

PHP Code:
#include <amxmodx>
#include <reapi>

#define PLUGIN          "resetscore(ReAPI)"
#define VERSION         "1.0"
#define AUTHOR          "modders"

#define TASK_SPEC 100

new iFragRestarts[33]

public 
plugin_init()
{
        
register_plugin(PLUGINVERSIONAUTHOR);
        
register_clcmd("say .rr""resetscore");
        
register_clcmd("say_team .rr""resetscore");
        
register_clcmd("say /rs""resetscore");
        
register_clcmd("say /resetscore""resetscore")

        
RegisterHookChain(RG_HandleMenu_ChooseTeam"HC_HandleMenu_ChooseTeam_Pre"false)
}

public 
resetscore(id)
{
        if(!
is_user_connected(id)) return;

        
set_entvar(idvar_frags0.0);
        
set_member(idm_iDeaths0);

        
client_print_color(idprint_team_blue"^3Score Resetado!");
        
client_cmd(id"spk fvox/buzz.wav");

        
message_begin(MSG_ALL85);
        
write_byte(id);
        
write_short(0); write_short(0); write_short(0); write_short(0);
        
message_end();

        
iFragRestarts[id]++
}

public 
HC_HandleMenu_ChooseTeam_Pre(idMenuChooseTeam:iSlot)
{
        switch(
iSlot)
        {
                case 
MenuChoose_Spec:
                {
                        
set_task(1.0"Observer"id TASK_SPEC, .flags "b")
                        return 
HC_CONTINUE
                
}
                case 
MenuChoose_CTMenuChoose_TMenuChoose_AutoSelect:
                {
                        
remove_task(id TASK_SPEC)
                        return 
HC_CONTINUE
                
}
        }

        return 
HC_CONTINUE
}

public 
client_disconnected(idbool:dropmessage[], maxlen)
{
        
remove_task(id TASK_SPEC)
        
iFragRestarts[id] = 0
}

public 
Observer(taskid)
{
        new 
id taskid TASK_SPEC

        
if(get_member(idm_iTeam) != TEAM_SPECTATOR)
        {
                
remove_task(id TASK_SPEC)
                return 
1
        
}

        static 
id2
        id2 
get_entvar(idvar_iuser2)

        if(
id2)
        {
                
serverset_dhudmessage(02550, -1.00.3, .effects 0, .fxtime 2.0, .holdtime 1.0, .fadeintime 0.1, .fadeouttime 0.2)
                
show_dhudmessage(id"Times restarted [%i]"iFragRestarts[id2])
                return 
0
        
}
        return 
1

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 01-07-2021 at 09:45.
iceeedr is offline
Send a message via Skype™ to iceeedr
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 01-06-2021 , 22:55   Re: reset score, add hud function
Reply With Quote #5

Quote:
Originally Posted by iceeedr View Post
Not tested

PHP Code:
#include <amxmodx>
#include <reapi>

#define PLUGIN          "resetscore(ReAPI)"
#define VERSION         "1.0"
#define AUTHOR          "modders"

#define TASK_SPEC 100

new iFragRestarts[33]

public 
plugin_init()
{
        
register_plugin(PLUGINVERSIONAUTHOR);
        
register_clcmd("say .rr""resetscore");
        
register_clcmd("say_team .rr""resetscore");
        
register_clcmd("say /rs""resetscore");
        
register_clcmd("say /resetscore""resetscore")

        
RegisterHookChain(RG_HandleMenu_ChooseTeam"HC_HandleMenu_ChooseTeam_Pre"false)
}

public 
resetscore(id)
{
        if(!
is_user_connected(id)) return;

        
set_entvar(idvar_frags0.0);
        
set_member(idm_iDeaths0);

        
client_print_color(idprint_team_blue"^3Score Resetado!");
        
client_cmd(id"spk fvox/buzz.wav");

        
message_begin(MSG_ALL85);
        
write_byte(id);
        
write_short(0); write_short(0); write_short(0); write_short(0);
        
message_end();

        
iFragRestarts[id]++
}

public 
HC_HandleMenu_ChooseTeam_Pre(idMenuChooseTeam:iSlot)
{
        switch(
iSlot)
        {
                case 
MenuChoose_Spec:
                {
                        
set_task(1.0"Observer"id TASK_SPEC, .flags "b")
                        return 
HC_CONTINUE
                
}
        }

        return 
HC_CONTINUE
}

public 
client_disconnected(idbool:dropmessage[], maxlen)
{
        
remove_task(id TASK_SPEC)
        
iFragRestarts[id] = 0
}

public 
Observer(id)
{
        if(
get_member(idm_iTeam) != TEAM_SPECTATOR)
        {
                
remove_task(id TASK_SPEC)
                return 
PLUGIN_HANDLED
        
}

        new 
id2
        id2 
get_entvar(idvar_iuser2)

        
set_dhudmessage(02550, -1.00.3, .effects 0, .fxtime 2.0, .holdtime 1.0, .fadeintime 0.1, .fadeouttime 0.2)
        
show_dhudmessage(id"Times restarted [%i]"iFragRestarts[id2])
        return 
PLUGIN_HANDLED

i tried your plugin but didn`t work, the reset is ok, but nothing is showing on the HUD

Last edited by tarsisd2; 01-06-2021 at 22:55.
tarsisd2 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-07-2021 , 00:45   Re: reset score, add hud function
Reply With Quote #6

Curiosity, tested with bots or common players?
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 01-07-2021 , 08:59   Re: reset score, add hud function
Reply With Quote #7

Quote:
Originally Posted by iceeedr View Post
Curiosity, tested with bots or common players?
tested on a full server with 32 real players

Last edited by tarsisd2; 01-07-2021 at 09:00.
tarsisd2 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-07-2021 , 09:45   Re: reset score, add hud function
Reply With Quote #8

Quote:
Originally Posted by tarsisd2 View Post
tested on a full server with 32 real players
Updated post, this time I was able to test, there were some errors so I optimized the previous code in general, you just need to change the place of the hud (xy) to your preference.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 01-07-2021 , 13:00   Re: reset score, add hud function
Reply With Quote #9

Quote:
Originally Posted by iceeedr View Post
Updated post, this time I was able to test, there were some errors so I optimized the previous code in general, you just need to change the place of the hud (xy) to your preference.
now i can`t even compile

PHP Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// resetscore_novo.sma
//
// C:\Users\D2-Studios\Documents\servidor\[RE UPDATES]\amxmodx-1.9.0-git5263-windows\amxmodx-1.9.0-git5263-windows\addons\amxmodx\scripting\resetscore_novo.sma(81) : error 017: undefined symbol "serverset_dhudmessage"
// C:\Users\D2-Studios\Documents\servidor\[RE UPDATES]\amxmodx-1.9.0-git5263-windows\amxmodx-1.9.0-git5263-windows\addons\amxmodx\scripting\resetscore_novo.sma(81) : warning 215: expression has no effect
// C:\Users\D2-Studios\Documents\servidor\[RE UPDATES]\amxmodx-1.9.0-git5263-windows\amxmodx-1.9.0-git5263-windows\addons\amxmodx\scripting\resetscore_novo.sma(81) : error 029: invalid expression, assumed zero
// C:\Users\D2-Studios\Documents\servidor\[RE UPDATES]\amxmodx-1.9.0-git5263-windows\amxmodx-1.9.0-git5263-windows\addons\amxmodx\scripting\resetscore_novo.sma(81) : error 017: undefined symbol "fxtime"
// C:\Users\D2-Studios\Documents\servidor\[RE UPDATES]\amxmodx-1.9.0-git5263-windows\amxmodx-1.9.0-git5263-windows\addons\amxmodx\scripting\resetscore_novo.sma(81) : fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 4 Errors.
// Could not locate output file C:\Users\D2-Studios\Documents\servidor\[RE UPDATES]\amxmodx-1.9.0-git5263-windows\amxmodx-1.9.0-git5263-windows\addons\amxmodx\scripting\compiled\resetscore_novo.amx (compile failed).
//
// Compilation Time: 0.28 sec
// ----------------------------------------

Press enter to exit ... 
tarsisd2 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-07-2021 , 14:16   Re: reset score, add hud function
Reply With Quote #10

PHP Code:
serverset_dhudmessage(02550, -1.00.3, .effects 0, .fxtime 2.0, .holdtime 1.0, .fadeintime 0.1, .fadeouttime 0.2
-->

PHP Code:
set_dhudmessage(02550, -1.00.3, .effects 0, .fxtime 2.0, .holdtime 1.0, .fadeintime 0.1, .fadeouttime 0.2
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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