So after the unsolved topic, I'l make a request for a plugin from 0
Can you make: A resetscore (trough reapi, if you can) with:
Minimal Frags&Death (set by cvar) in order to allow the reset (if you are denied, there should be a chat message + spk)
A timer (set by cvar) that block from using reset for X seconds (if you already use this command within X seconds there should be a chat emssage)
Chat message just for that player, not for all
"spk" play sound alongside the chat message (for reseted and minimal frags acces denied)
A list of commands to triger it, not just a single one.. (const, right?) (like /rs, /reset, /resetscore and so on)
-- and all of these to disable them (separate for each one) if I don't wana use any of them (for example if I don' want spk, just messsage or vice-versa.., or no timer just minimal score and so on..)
Use whatever you want: define or cvar (just to be efficient, flexible)
This code is untested. I used the task_complete.wav sound located in your events sounds directory. I couldn't find the sounds you were talking about, or i just misunderstood you.
new szCommands[][] = { // All available commands. If you wish to add or delete some, make sure the layout stays the same. the last command shouldn't have a "," at the end, as all the rest does. "say /resetscore", "say /rs", "say /scorereset", "say_team /resetscore", "say_team /rs", "say_team /scorereset" }
new pMainPlugin new pDelayTime new pMinimalFrags new pMinimalDeaths new pAdvertiseMethod
new bool:OnCoolDown[33]
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR)
for(new i; i < sizeof(szCommands); i++) { register_clcmd(szCommands[i], "ResetScore") }
pMainPlugin = register_cvar("rs_resetscore", "1") // Enables/disables the plugin. 0 = disabled. pDelayTime = register_cvar("rs_delaytime", "10.0") // Default = 10.0 seconds, should always be a float to avoid trouble. pMinimalFrags = register_cvar("rs_minfrags", "0") pMinimalDeaths = register_cvar("rs_mindeaths", "0") pAdvertiseMethod = register_cvar("rs_message", "1") // 1 = print text & play sound, 2 = print text only, 3 = play sound only. }
public plugin_precache() { precache_sound("events/task_complete.wav") }
if(OnCoolDown[id] == true) { // Has already used command. client_print(id, print_chat, "[RS] You have to wait a little longer to use this command again.") return PLUGIN_HANDLED }
new iFrags = get_user_frags(id) new iDeaths = get_user_deaths(id)
DisplayMessage(id) } else { client_print(id, print_chat, "[RS] You don't meet the minimum requirments to use this command.") client_print(id, print_chat, "[RS] Minimum deaths: %i - Minimum frags: %i", get_pcvar_num(pMinimalDeaths), get_pcvar_num(pMinimalFrags)) return PLUGIN_HANDLED } return PLUGIN_HANDLED }
public DisplayMessage(id) { switch(pAdvertiseMethod) { case 1: { client_print(id, print_chat, "[RS] You reset your score.") client_cmd(id, "spk events/task_complete.wav") } case 2: { client_print(id, print_chat, "[RS] You reset your score.") } case 3: { client_cmd(id, "spk events/task_complete.wav") } } }
public EndDelayTime(id) { if(is_user_connected(id) && get_pcvar_num(pMainPlugin)) { client_print(id, print_chat, "[RS] You can use the resetscore function again.") OnCoolDown[id] = false } }
1. Can you make it trough ReAPI?
2. At the commands list can't you make just /rs instead of say /rs and say_team /rs? (look at my plugin example)
3. Don't you hear about "spk" command in console? lol (look at plugin example)
4. At you have to wait a bit to reset .. can you put like you have to wait %s seconds?
5. At you need %i frags/deaths in order to reset.. try to make it in a single sentence.. (You don't have minimum %i frags and %i deaths to reset the score) instead of 2..
6. "[RS] You can use the resetscore function again." - can you delete it or make a cvar (1/0)?
Original Plugin Example (without my mess)
Spoiler
Code:
#include <amxmodx>
#include <reapi>
#define MIN_FRAGS 5 // Player who has more than minimum frags will be able to reset his score but not lower
#define MIN_DEATHS 5 // Player who has more than minimum deaths will be able to reset his score but not lower
new const resetScoreCommands[][] =
{
"/rs", "/resetscore", "/rscore", "/resets"
}
new sayCmd[64], sayTeamCmd[64], x
public plugin_init()
{
register_plugin("Reset Score", "1.1", "Raheem")
// Commands
for (x = 0; x <= charsmax(resetScoreCommands); x++)
{
formatex(sayCmd, charsmax(sayCmd), "say %s", resetScoreCommands[x])
formatex(sayTeamCmd, charsmax(sayTeamCmd), "say_team %s", resetScoreCommands[x])
register_clcmd(sayCmd, "CmdSay")
register_clcmd(sayTeamCmd, "CmdSay")
}
}
public CmdSay(id)
{
if (get_entvar(id, var_frags) > MIN_FRAGS || get_member(id, m_iDeaths) > MIN_DEATHS)
{
set_entvar(id, var_frags, 0.0)
set_member(id, m_iDeaths, 0)
message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
write_byte(id) // id
write_short(0) // Frags
write_short(0) // Deaths
write_short(0) // Class
write_short(get_member(id, m_iTeam)) // Team
message_end()
client_print_color(id, print_team_default, "^3Your score has been reset successfully^1.")
client_cmd(id, "spk yoursound")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
Plugin example edited by me with floodtime (but a mess)
Spoiler
Code:
#include <amxmodx>
#include <reapi>
#define CHAT // Message in chat when the score is reseted.
#define SOUND // Audio speak when the score is rested.
#define FLOODTIME 20 // Block reusing resetscore for defined seconds.
#define MIN_FRAGS 2 // Player who has more than minimum frags will be able to reset his score but not lower.
#define MIN_DEATHS 2 // Player who has more than minimum deaths will be able to reset his score but not lower.
new const resetScoreCommands[][] =
{
"/rs", "/resetscore", "/reset", "/rscore", "/resets"
}
new sayCmd[64], sayTeamCmd[64], x
public plugin_init()
{
register_plugin("Reset Score", "1.1", "Raheem")
// Commands
for (x = 0; x <= charsmax(resetScoreCommands); x++)
{
formatex(sayCmd, charsmax(sayCmd), "say %s", resetScoreCommands[x])
formatex(sayTeamCmd, charsmax(sayTeamCmd), "say_team %s", resetScoreCommands[x])
register_clcmd(sayCmd, "CmdSay")
register_clcmd(sayTeamCmd, "CmdSay")
}
}
public CmdSay(id)
{
#if defined FLOODTIME
static iFloodTime[33], systime;
if (iFloodTime[id] > (systime = get_systime()))
{
#if defined CHAT
client_print_color(id, print_team_default, "^1[^4RS^1] ^3To ^4reset ^3the score, wait %d seconds.^1.", iFloodTime[id] - systime);
#endif
}
#endif
else if (get_entvar(id, var_frags) > MIN_FRAGS || get_member(id, m_iDeaths) > MIN_DEATHS)
{
set_entvar(id, var_frags, 0.0)
set_member(id, m_iDeaths, 0)
message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
write_byte(id) // id
write_short(0) // Frags
write_short(0) // Deaths
write_short(0) // Class
write_short(get_member(id, m_iTeam)) // Team
message_end()
#if defined CHAT
client_print_color(id, print_team_default, "^1[^4RS^1] ^3Your score has been ^4reset^1.")
#endif
#if defined SOUND
client_cmd(id, "spk ^"cleanup(t20) terminated(t20)^"")
#endif
#if defined FLOODTIME
iFloodTime[id] = systime + FLOODTIME;
#endif
return PLUGIN_HANDLED
}
else
{
#if defined CHAT
client_print_color(id, print_team_default, "1[^4RS^1] ^3You don't have minimum %i frags and %i deaths to ^4reset ^3the score^1.", MIN_FRAGS, MIN_DEATHS)
#endif
#if defined SOUND
client_cmd(id, "spk ^"cleanup(t20) denied(t20)^"")
#endif
}
return PLUGIN_CONTINUE
}
1. No
2. Your plugin is doing the exact same thing, the format is just different.
3. I'll change this when i get home.
4. Same as point 3.
5. Idem ditto
6. Same as 3, 4 and 5.
new szCommands[][] = { // All available commands. If you wish to add or delete some, make sure the layout stays the same. the last command shouldn't have a "," at the end, as all the rest does. "say /resetscore", "say /rs", "say /scorereset", "say_team /resetscore", "say_team /rs", "say_team /scorereset" }
new pMainPlugin new pDelayTime new pMinimalFrags new pMinimalDeaths new pAdvertiseMethod
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR)
for(new i; i < sizeof(szCommands); i++) { register_clcmd(szCommands[i], "ResetScore") }
pMainPlugin = register_cvar("rs_resetscore", "1") // Enables/disables the plugin. 0 = disabled. pDelayTime = register_cvar("rs_delaytime", "10") pMinimalFrags = register_cvar("rs_minfrags", "0") pMinimalDeaths = register_cvar("rs_mindeaths", "0") pAdvertiseMethod = register_cvar("rs_message", "1") // 1 = print text & play sound, 2 = print text only, 3 = play sound only. }
public plugin_precache() { precache_sound("events/task_complete.wav") }
Somehow you made my day =)
1. client_print(id, print_chat, "[RS] You reset your score.") -> client_cmd(id, "spk ^"cleanup(t20) denied(t20)^"") -- 10/10
2. Why you precache that sound anyway?
3. You forgot to add the cleanup client_cmd(id, "spk ^"cleanup(t20) terminated(t20)^"")
4. It would be nicer to have colors inside the message (See my example)
-> This I can edit/fix by myself (anyway you could include these too for those are watching the topic) but this not:
PS: Can you make the commands to auto-detect if it's AllChat or TeamChat (like in list: /rs, /resetscore instead of say /rs say_team /rs and so on..)?.. I didn't want to bother you again but it did give me some errors
+ Add a cvar in order to chose wich to use timer or kill/death ratio not the 2 in same time