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

restscore Request


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DINO11
Member
Join Date: Jun 2016
Old 07-02-2016 , 03:51   restscore Request
Reply With Quote #1

hi can someone make plugine code of restescore like thise
when player score 0 msg = !g[KGB]: !yVec ste resetovali skor.
when player have a score msg = !g[KGB]: !yVratili ste svoj skor na !t0!y.
DINO11 is offline
ish12321
Veteran Member
Join Date: May 2016
Old 07-02-2016 , 05:57   Re: restscore Request
Reply With Quote #2

Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN "ResetScore"
#define VERSION "1.0"
#define AUTHOR "Ish Chhabra"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say resetscore", "resetscore")
    // Add your code here...
}

new name[33]
public resetscore(id) {
    
    get_user_name(id, name, 17)
    
    if(cs_get_user_deaths(id)==0 | get_user_frags(id)==0) {
        set_user_frags(id, 0)
        cs_set_user_deaths(id, 0)
        
        client_print_color(id, print_chat, "!g%s, !tYour score has been reset.",name)
    }
    else {
        client_print_color(id, print_chat, "!g%s, !tYour score is alrady 0.", name)
    }
}

// COLOR CHAT CODE TO BE PUT IN THE PLUGIN
stock client_print_color(id, type, const text[], any:...)
{
 if(type == print_chat)
 {
  new g_iMsgidSayText;
  g_iMsgidSayText = get_user_msgid("SayText");

  new szMsg[191], iPlayers[32], iCount = 1;
  vformat(szMsg, charsmax(szMsg), text, 3);

  replace_all(szMsg, charsmax(szMsg), "!g","^x04");
  replace_all(szMsg, charsmax(szMsg), "!n","^x01");
  replace_all(szMsg, charsmax(szMsg), "!t","^x03");

  if(id)
   iPlayers[0] = id;
  else
   get_players(iPlayers, iCount, "ch");

  for(new i = 0 ; i < iCount ; i++)
  {
   if(!is_user_connected(iPlayers[i]))
    continue;
   
   message_begin(MSG_ONE_UNRELIABLE, g_iMsgidSayText, _, iPlayers[i]);
   write_byte(iPlayers[i]);
   write_string(szMsg);
   message_end();
  }
 }
}
ish12321 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-02-2016 , 08:48   Re: restscore Request
Reply With Quote #3

I advise you to use my code if it works since i saw some typo's and wrong checks in ish's code.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>

#define PLUGIN "Reset Score"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new const szSayCommands[][] = {
    
"say /rs",
    
"say /resetscore",
    
"say_team /rs",
    
"say_team /resetscore"
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    for(new 
isizeof(szSayCommands); i++) {
        
register_clcmd(szSayCommands[i], "ResetScore")
    }
}

public 
ResetScore(id) {
    new 
deaths cs_get_user_deaths(id)
    new 
frags get_user_frags(id)
    
    if(
frags != || deaths != 0) {
        new 
szName[33]; get_user_name(idszNamecharsmax(szName))
        
        
cs_set_user_deaths(id0)
        
ColorChat(0GREEN"[KGB]:^3 %s^1 has reset his/her score."szName)
        return 
PLUGIN_HANDLED
    
}
    
    else if(
frags == && deaths == 0) {
        
ColorChat(idGREEN"[KGB]^1 You already have 0 frags & deaths.")
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED

untested
Attached Files
File Type: inc colorchat.inc (2.8 KB, 113 views)
__________________

Last edited by Napoleon_be; 07-02-2016 at 08:49.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-02-2016 , 10:36   Re: restscore Request
Reply With Quote #4

Napoleon, if I remember well, you should send a ScoreInfo message so scoreboard is immediately updated.
__________________

Last edited by HamletEagle; 07-02-2016 at 10:36.
HamletEagle is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-02-2016 , 11:08   Re: restscore Request
Reply With Quote #5

Changed my code, here it is. Credits to Hunter-Digital from a post from 2009 that i managed to find the answer from. Let me know if anything is outdated or does not work.

I had no idea how to update the scoreboard immediatly and i certainly have no idea what these write_functions do.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>

#define PLUGIN "Reset Score"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new const szSayCommands[][] = {
    
"say /rs",
    
"say /resetscore",
    
"say_team /rs",
    
"say_team /resetscore"
}

new 
MessageScoreInfo

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    for(new 
isizeof(szSayCommands); i++) {
        
register_clcmd(szSayCommands[i], "ResetScore")
    }
    
    
MessageScoreInfo get_user_msgid("ScoreInfo")
}

public 
ResetScore(id) {
    new 
deaths cs_get_user_deaths(id)
    new 
frags get_user_frags(id)
    
    if(
frags != || deaths != 0) {
        new 
szName[33]; get_user_name(idszNamecharsmax(szName))
        
        
cs_set_user_deaths(id0)
        
ColorChat(0GREEN"[KGB]:^3 %s^1 has reset his/her score."szName)
        return 
PLUGIN_HANDLED
    
}
    
    else if(
frags == && deaths == 0) {
        
ColorChat(idGREEN"[KGB]^1 You already have 0 frags & deaths.")
        return 
PLUGIN_HANDLED
    
}
    
    
message_begin(MSG_ALLMessageScoreInfo)
    
write_byte(id)
    
write_short(frags)
    
write_short(deaths)
    
write_short(0)
    
write_short(get_user_team(id))
    
message_end()
    
    return 
PLUGIN_HANDLED

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
ish12321
Veteran Member
Join Date: May 2016
Old 07-02-2016 , 11:30   Re: restscore Request
Reply With Quote #6

Quote:
Originally Posted by Napoleon_be View Post
I advise you to use my code if it works since i saw some typo's and wrong checks in ish's code.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>

#define PLUGIN "Reset Score"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new const szSayCommands[][] = {
    
"say /rs",
    
"say /resetscore",
    
"say_team /rs",
    
"say_team /resetscore"
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    for(new 
isizeof(szSayCommands); i++) {
        
register_clcmd(szSayCommands[i], "ResetScore")
    }
}

public 
ResetScore(id) {
    new 
deaths cs_get_user_deaths(id)
    new 
frags get_user_frags(id)
    
    if(
frags != || deaths != 0) {
        new 
szName[33]; get_user_name(idszNamecharsmax(szName))
        
        
cs_set_user_deaths(id0)
        
ColorChat(0GREEN"[KGB]:^3 %s^1 has reset his/her score."szName)
        return 
PLUGIN_HANDLED
    
}
    
    else if(
frags == && deaths == 0) {
        
ColorChat(idGREEN"[KGB]^1 You already have 0 frags & deaths.")
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED

untested
Can you point me wrong things
ish12321 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-02-2016 , 12:01   Re: restscore Request
Reply With Quote #7

https://wiki.alliedmods.net/Half-Lif...ents#ScoreInfo
Code:
byte	PlayerID
short	Score
short	Deaths
short	ClassID
short	TeamID
Each write_* line correspond to the "param" from the message structure. First is byte PlayerId so you use write_byte and send a player index.
Second is short Score so you use write_short and pass player frags.
__________________
HamletEagle is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 07-02-2016 , 19:57   Re: restscore Request
Reply With Quote #8

Why not using default method by calling reset native 2 times and avoid problems?
siriusmd99 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-03-2016 , 03:23   Re: restscore Request
Reply With Quote #9

Quote:
Originally Posted by siriusmd99 View Post
Why not using default method by calling reset native 2 times and avoid problems?
What problems are you talking about? It's about sending a message, nothing more.
__________________
HamletEagle is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-03-2016 , 07:26   Re: restscore Request
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
https://wiki.alliedmods.net/Half-Lif...ents#ScoreInfo
Code:
byte    PlayerID
short    Score
short    Deaths
short    ClassID
short    TeamID
Each write_* line correspond to the "param" from the message structure. First is byte PlayerId so you use write_byte and send a player index.
Second is short Score so you use write_short and pass player frags.
Now i understand, never had a clue what these write_ functions were, now i do
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 04:34.


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