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

update score


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-22-2021 , 02:55   update score
Reply With Quote #1

I am using this ReAPI code to update player frags and deaths but it update only when player kills enemy or die

I want to update the score instantly just like cs_set_user_frags and deaths.

PHP Code:
new Float:Frags[32];
new 
Deaths[32];

public 
setScore()
{
    new 
name[32];
    new 
players[32], playerCountplayer
    get_players
(playersplayerCount)

    for(new 
i=0i<playerCounti++)
    {
        
player players[i]
        
get_user_name(playernamecharsmax(name));

        
set_entvar(playervar_frags5.0);
        
set_member(playerm_iDeaths4);

        
//client_print(0, print_chat, "Debug %s : Frags: %.f & Deaths: %d", name, Frags[player], Deaths[player])
    
}

__________________

Last edited by Sanjay Singh; 01-22-2021 at 02:57.
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-22-2021 , 06:59   Re: update score
Reply With Quote #2

Took the code below from zp50_rewards_frags_hp, you'll need to call "ScoreInfo".

Code:
// Update Player Frags and Deaths UpdateFrags(attacker, victim, frags, deaths, scoreboard) {     // Set attacker frags     set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) + frags))         // Set victim deaths     fm_cs_set_user_deaths(victim, cs_get_user_deaths(victim) + deaths)         // Update scoreboard with attacker and victim info     if (scoreboard)     {         message_begin(MSG_BROADCAST, g_MsgScoreInfo)         write_byte(attacker) // id         write_short(pev(attacker, pev_frags)) // frags         write_short(cs_get_user_deaths(attacker)) // deaths         write_short(0) // class?         write_short(_:cs_get_user_team(attacker)) // team         message_end()                 message_begin(MSG_BROADCAST, g_MsgScoreInfo)         write_byte(victim) // id         write_short(pev(victim, pev_frags)) // frags         write_short(cs_get_user_deaths(victim)) // deaths         write_short(0) // class?         write_short(_:cs_get_user_team(victim)) // team         message_end()     } }
__________________








CrazY. is offline
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-22-2021 , 12:11   Re: update score
Reply With Quote #3

Quote:
Originally Posted by CrazY. View Post
Took the code below from zp50_rewards_frags_hp, you'll need to call "ScoreInfo".

Code:
// Update Player Frags and Deaths UpdateFrags(attacker, victim, frags, deaths, scoreboard) {     // Set attacker frags     set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) + frags))         // Set victim deaths     fm_cs_set_user_deaths(victim, cs_get_user_deaths(victim) + deaths)         // Update scoreboard with attacker and victim info     if (scoreboard)     {         message_begin(MSG_BROADCAST, g_MsgScoreInfo)         write_byte(attacker) // id         write_short(pev(attacker, pev_frags)) // frags         write_short(cs_get_user_deaths(attacker)) // deaths         write_short(0) // class?         write_short(_:cs_get_user_team(attacker)) // team         message_end()                 message_begin(MSG_BROADCAST, g_MsgScoreInfo)         write_byte(victim) // id         write_short(pev(victim, pev_frags)) // frags         write_short(cs_get_user_deaths(victim)) // deaths         write_short(0) // class?         write_short(_:cs_get_user_team(victim)) // team         message_end()     } }
Small mistake fixed ty.
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Reply



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 16:44.


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