Raised This Month: $32 Target: $400
 8% 

Solved set_user_frags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 02-08-2021 , 16:18   set_user_frags
Reply With Quote #1

hello guys. i want to set players frags at event round start. this is my code:

PHP Code:
    if(my_data_2_store[0] == 16)
    {
        
get_players(iPlayersiNum)
        for (new 
0iNumi++)
        {
            
iPlayer iPlayers[i]
            
cs_set_user_deaths(iPlayeriDeaths[i])
            
fm_set_user_frags(iPlayeriFrags[i])
        }
        
my_data_2_store[1]
        
my_data_2_store[1] = my_data_2_store[2]
        
my_data_2_store[2] = x    
    

the problem is it will show 0 until the player make 1 frag, then it will show his saved frags + frag that he made. how could i avoid that 0 ? i want to set his frags from the round start not when he's making a frag. i tried with cs_set_user_frags but same result

Last edited by lexzor; 02-09-2021 at 10:51.
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-08-2021 , 16:33   Re: set_user_frags
Reply With Quote #2

"the problem is it will show 0 until the player make 1 frag"

Why would the frag count be greater than 0 if he has not yet made a kill? So I join your server and I am supposed to be given 1 kill for free?

Or are you making some kind of 'save your kills and deaths' plugin?
__________________
Bugsy is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 02-08-2021 , 16:54   Re: set_user_frags
Reply With Quote #3

my server is running an csgo add-on and after 16 rounds there is a swap team and the mode uses sv_restart and all frags and deaths are reseting to 0 so i'm trying to save them after this swap.
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-08-2021 , 21:16   Re: set_user_frags
Reply With Quote #4

I would use nVault array to store each players kills + deaths immediately before sv_restart is called, and then immediately after, restore the score with what is stored in nVault.
__________________
Bugsy is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 02-08-2021 , 21:58   Re: set_user_frags
Reply With Quote #5

A message is written to make it appear in scoreboard.

Code:
    new gmsgScoreInfo;     gmsgScoreInfo = get_user_msgid("ScoreInfo")         message_begin(MSG_ALL,gmsgScoreInfo)         write_byte(iPlayer)         write_short(get_user_frags(iPlayer))         write_short(get_user_deaths(iPlayer))         write_short(0)         write_short(get_user_team(iPlayer))         message_end()
__________________
DJEarthQuake is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-08-2021 , 22:05   Re: set_user_frags
Reply With Quote #6

Ah, I wasn't even thinking his code was working to begin with but now that you say that, maybe it is.

Try this:
PHP Code:
new gmsgScoreInfo;

public 
plugin_init() 
{    
    
gmsgScoreInfo get_user_msgid("ScoreInfo");
}

public 
abc()
{
    if(
my_data_2_store[0] == 16)
    {
        
get_players(iPlayersiNum)
        for (new 
0iNumi++)
        {
            
iPlayer iPlayers[i]
            
cs_set_user_deaths(iPlayeriDeaths[i])
            
fm_set_user_frags(iPlayeriFrags[i])
            
            
message_begin(MSG_ALL,gmsgScoreInfo)
            
write_byte(iPlayer)
            
write_short(iFrags[i])
            
write_short(iDeaths[i])
            
write_short(0)
            
write_short(cs_get_user_team(iPlayer))
            
message_end()
        }
        
        
my_data_2_store[1]
        
my_data_2_store[1] = my_data_2_store[2]
        
my_data_2_store[2] = x    
    


__________________
Bugsy is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 02-09-2021 , 10:51   Re: set_user_frags
Reply With Quote #7

It's working. Thanks!

Where can i find a tutorial about what you did there?
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-09-2021 , 23:28   Re: set_user_frags
Reply With Quote #8

There's no tutorial for this specific thing. But here is a link for game events that you can hook or send. Take a look at ScoreInfo and you can see why the values are sent the way that they are and in a specific order in the above code.. write_byte(), write_short(), etc.
__________________

Last edited by Bugsy; 02-09-2021 at 23:30.
Bugsy is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 02-28-2021 , 18:37   Re: set_user_frags
Reply With Quote #9

There's a problem with the description of ScoreInfo on that link. Some mods like Half-Life/OP4 do not use the last 2 shorts. It will crash on 9 bytes expecting 5.

Code:
public pin_scoreboard(killer) {     if(is_user_connected(killer))     {         emessage_begin(MSG_BROADCAST,get_user_msgid("ScoreInfo"))         ewrite_byte(killer);         ewrite_short(get_user_frags(killer));         ewrite_short(get_user_deaths(killer));         if(cstrike_running())         {             ewrite_short(0); //TFC CLASS             ewrite_short(get_user_team(killer));         }         emessage_end();     } }
__________________
DJEarthQuake is offline
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 03:21.


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