Resolved (ReAPI) AntiFlashLightSpam + ResetScore

Coding Help/Re-API Supported
User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 626
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 49 times
Age: 19
Contact:

Re: (ReAPI) AntiFlashLightSpam + ResetScore

#11

Post by Mohamed Alaa » 1 Year Ago

Here you go.
Sound has been added: client_cmd(id, "spk \"cleanup(t20) progress(t20)\"")
Dictionary file has been removed.
You can add more commands like in: new const resetScoreCommands[][]
Replace yoursound with Your own sound.

Code: Select all

#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
}
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#12

Post by ArminC » 1 Year Ago

Thank you, the "spk" isn't affected by the sheild/filterstuff.. right?

But it don't have the tag (like tag have color x and the chat have color y) -- client_print_color(id, print_team_default, "^4[RS]^3Your score has been reset successfully^1.")

Right?

(edit) can you set an else chat print if no required connditon achived = a message if deaths/frags lower than #definde

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#13

Post by Raheem » 1 Year Ago

ArminC wrote:
1 Year Ago
Thank you, the "spk" isn't affected by the sheild/filterstuff.. right?
Yes not filtered by CS. Not blocked by VALVE so it still working.
ArminC wrote:
1 Year Ago
But it don't have the tag (like tag have color x and the chat have color y) -- client_print_color(id, print_team_default, "^4[RS]^3Your score has been reset successfully^1.")

Right?
Right like: client_print_color(id, print_team_default, "^4[RS] ^3Your score has been reset successfully^1.")
ArminC wrote:
1 Year Ago
(edit) can you set an else chat print if no required connditon achived = a message if deaths/frags lower than #definde
Simply add it:
  • Code: Select all

    	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
    	}
    	else
    	{
    		client_print_color(id, print_team_default, "ANY THING")
    	}
You don't know? Learn and you will know.

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#14

Post by ArminC » 1 Year Ago

Oh I found another one.. (why I can't think at all in first reply.. ideeas appear on the run :))

Code: Select all

client_print_color(id, print_team_default, "1[^4RS^1] ^3You don't have %s frags and %s to ^4reset ^3the score^1.")
If you didn't get it already.. how I can connect the already checked/known (from this)

Code: Select all

if (get_entvar(id, var_frags) > MIN_FRAGS || get_member(id, m_iDeaths) > MIN_DEATHS)
deaths/frags to my message (replace the %s with #define value) ?
Oh and here I can include some acces declined sounds.. (I like verrry much Half-life lol)

(edit) Can you fix this for me, just an ideea :) + add the above features? Thanks for nr.100 request :lol: (I tried more ideeas from more pawn/amxx wiki but nothing..)

Code: Select all

#include <amxmodx>
#include <reapi>

#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)
{
	static iFloodTime[33], systime;
	if (iFloodTime[id] > (systime = get_systime()))
	{
		client_print_color(id, print_team_default, "^1[^4RS^1] ^3To ^4reset ^3the score, wait %d seconds.^1.", iFloodTime[id] - systime);
	} 
	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()
		
		client_print_color(id, print_team_default, "^1[^4RS^1] ^3Your score has been ^4reset^1.")
		client_cmd(id, "spk ^"cleanup(t20) terminated(t20)^"")
		
		iFloodTime[id] = systime + 20;
		
		return PLUGIN_HANDLED

	else
	{
		client_print_color(id, print_team_default, "1[^4RS^1] ^3You don't have %s frags and %s in order to ^4reset ^3the score^1.")
		client_cmd(id, "spk ^"cleanup(t20) denied(t20)^"")
	}

	return PLUGIN_CONTINUE
}

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#15

Post by Raheem » 1 Year Ago

Yes, You can include any sounds in Valve/sound folder without any problem and not needed to precache them.

Second thing: You should know that %i is used for integer and %s used for string arrays. You may read more about it, It's explained well here: https://www.codingunit.com/printf-forma ... ted-output and note that these specifiers used when you need to send a Chat, Text HUD Message ... etc.
So in your code this:
    1. client_print_color(id, print_team_default, "1[^4RS^1] ^3You don't have %s frags and %s deaths in order to ^4reset ^3the score^1.")
Should be:
    1. client_print_color(id, print_team_default, "1[^4RS^1] ^3You don't have %i frags and %i deaths in order to ^4reset ^3the score^1.", MIN_FRAGS, MIN_DEATHS)
You don't know? Learn and you will know.

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#16

Post by ArminC » 1 Year Ago

Ah, ok I understand.. I wasn't sure what letter to put after %..

I put the string but as I said eariler.. I can't code it correctly.. any help? -- until now I did have if + else now I have 3 scenarios and I don't know how to make it to work..

Code: Select all

#include <amxmodx>
#include <reapi>

#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.
#define FLOODTIME 20

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)
{
	static iFloodTime[33], systime;
	if (iFloodTime[id] > (systime = get_systime()))
	{
		client_print_color(id, print_team_default, "^1[^4RS^1] ^3To ^4reset ^3the score, wait %d seconds.^1.", iFloodTime[id] - systime);
	} 
	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()
		
		client_print_color(id, print_team_default, "^1[^4RS^1] ^3Your score has been ^4reset^1.")
		client_cmd(id, "spk ^"cleanup(t20) terminated(t20)^"")
		
		iFloodTime[id] = systime + FLOODTIME; 
		
		return PLUGIN_HANDLED

	else
	{
		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)
		client_cmd(id, "spk ^"cleanup(t20) denied(t20)^"")
	}

	return PLUGIN_CONTINUE
}}
// C:\Users\armin\Desktop\Compiler\reset_score.sma(56) : warning 225: unreachable code
// C:\Users\armin\Desktop\Compiler\reset_score.sma(56) : warning 217: loose indentation
// C:\Users\armin\Desktop\Compiler\reset_score.sma(56) : error 029: invalid expression, assumed zero
// C:\Users\armin\Desktop\Compiler\reset_score.sma(63) : warning 209: function "CmdSay" should return a value
(because that 2nd else?)
Last edited by ArminC on 27 Jan 2018, 16:18, edited 1 time in total.

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 626
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 49 times
Age: 19
Contact:

#17

Post by Mohamed Alaa » 1 Year Ago

Missing } before last 2nd else.
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#18

Post by ArminC » 1 Year Ago

wtf? That's all a misstype.. omfg.. I didn't see it lool (and I searched over 10 topics :\ )

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#19

Post by Raheem » 1 Year Ago

Hmm, Not need to search next time you read the error not warning. Error which will not allow compiler to compile but warning not important to fix. So if you read reset_score.sma(56) : error 029: invalid expression, assumed zero this mean in line 56 there is an invalid expression which jack tells you about it it's the missing closing bracket.

If compiler with smart enough to detect these things like missing bracket '}' or parentheses ')' and fix it .. but it's not smart so you should review your code and concentrate.
You don't know? Learn and you will know.

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 1 Year Ago
Location: Bucharest
Has thanked: 0
Been thanked: 2 times
Age: 17
Contact:

#20

Post by ArminC » 1 Year Ago

Code: Select all

#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
}
That's my final code :o It's final or could be re-sized to be smaller (more efficient?)

Anyway what return PLUGIN_CONTINUE+HANDLED do?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest