Raised This Month: $ Target: $400
 0% 

HELP edit plugin code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vase070
Senior Member
Join Date: Jun 2011
Old 09-14-2016 , 12:49   HELP edit plugin code
Reply With Quote #1

can someone pls edit this code and remove the hp and armor bonuses from it and only leave the money one ? i know someone will say just set

Code:
amx_mg_award_hp 0
amx_mg_award_ap 0
i know but when someone gets correct answer it still shows


Code:
[MG] Gero's answer (64) was correct - Gero won 0 HP and 0 AP
Plugin Code:

Code:
/*

DESCRIPTION

Solve something like 18 * (-4) + (-35) and win HP, AP or cash


LINK

http://forums.alliedmods.net/showthread.php?t=44765


CVARS (copy to server.cfg)

amx_mg_level 2 // Difficulty (1 - 6)
amx_mg_plus_minus 30 // Biggest number
amx_mg_times 12 // Biggest number
amx_mg_tries 2 // Tries for each Exercise
amx_mg_frequency 60.0 // Frequency in Seconds
amx_mg_award_hp 35 // HP Award
amx_mg_award_ap 10 // AP Award
amx_mg_reward 1000 // Cash Reward


VERSION HISTORY

1.0.0 -> Initial release
1.0.1 -> Added multiplication
1.0.2 -> Added amx_mg_plus_minus and amx_mg_times
1.0.3 -> Fixed miscalculation bug
1.0.4 -> Fixed zero/text bug


TODO

+ Check CVARS before use


CREDITS

Silencer123
MaximusBrood
slmclarengt

////////////////////////////////////////////////////////////////
*/

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

new bool:globalBoolSolved = false
new globalIntSolution = 0
new globalIntMaxTries[33]
new globalNativeLevel
new globalNativePlusMinus
new globalNativeTimes
new globalNativeTries
new globalNativeFrequency
new globalNativeAwardHP
new globalNativeAwardAP
new globalNativeReward

public plugin_init()
{
	register_plugin("Maths Genius", "1.0.4", "Silencer123")
	
	register_concmd("say", "checkSolution", 0, "Solution - Correct Answer is awarded with HP and AP")
	
	globalNativeLevel = register_cvar("amx_mg_level", "2", FCVAR_ARCHIVE)
	globalNativePlusMinus = register_cvar("amx_mg_plus_minus", "30", FCVAR_ARCHIVE)
	globalNativeTimes = register_cvar("amx_mg_times", "12", FCVAR_ARCHIVE)
	globalNativeTries = register_cvar("amx_mg_tries", "2", FCVAR_ARCHIVE)
	globalNativeFrequency = register_cvar("amx_mg_frequency", "60.0", FCVAR_ARCHIVE)
	globalNativeAwardHP = register_cvar("amx_mg_award_hp", "35", FCVAR_ARCHIVE)
	globalNativeAwardAP = register_cvar("amx_mg_award_ap", "10", FCVAR_ARCHIVE)
	globalNativeReward = register_cvar("amx_mg_reward", "1000", FCVAR_ARCHIVE)

	set_task(get_pcvar_float(globalNativeFrequency), "buildQuestion")
}

public checkSolution(id)
{
	if ( !globalBoolSolved )
	{
		new strAnswer[ 32 ]
		read_argv( 1, strAnswer, 31 )
		
		new intAnswer = str_to_num(strAnswer) // words/letters become 0
		if ( intAnswer == 0 && ( globalIntSolution != 0 || strAnswer[ 0 ] != '0' ) )
			return

		if ( globalIntMaxTries[id] > 0 )
		{
			if ( intAnswer == globalIntSolution )
			{
				//Prevent other users from answering quiz
				globalBoolSolved = true
				
				if ( is_user_alive(id) )
				{
					//Award HP and AP
					set_user_health(id, get_user_health(id) + get_pcvar_num(globalNativeAwardHP))
					set_user_armor(id, get_user_armor(id) + get_pcvar_num(globalNativeAwardAP))
					
					//Pass message to winning player
					//client_print(id, print_chat, "[MG] Your answer (%i) was correct - You won %i HP and %i AP", intAnswer, get_pcvar_num(globalNativeAwardHP), get_pcvar_num(globalNativeAwardAP))
					
					static winningUserName[32]
					get_user_name(id, winningUserName, 31)
					
					client_print(0, print_chat, "[MG] %s's answer (%i) was correct - %s won %i HP and %i AP", winningUserName, intAnswer, winningUserName, get_pcvar_num(globalNativeAwardHP), get_pcvar_num(globalNativeAwardAP))
				}
				else
				{
					cs_set_user_money(id, cs_get_user_money(id) + get_pcvar_num(globalNativeReward), 1)
					
					//client_print(id, print_chat, "[MG] Your answer (%i) was correct - You won $%i", intAnswer, get_pcvar_num(globalNativeReward))
					
					static winningUserName[32]
					get_user_name(id, winningUserName, 31)
					
					client_print(0, print_chat, "[MG] %s's answer (%i) was correct - %s won $%i", winningUserName, intAnswer, winningUserName, get_pcvar_num(globalNativeReward))
				}
			}
			else
			{
				globalIntMaxTries[id]--
				client_print(id, print_chat, "[MG] Your answer (%i) was incorrect - Remaining Tries: %i", intAnswer, globalIntMaxTries[id])
			}
		}
		else
		{
			client_print(id, print_chat, "[MG] You have no more Tries left for this Round")
		}
	}
}

public questionTimeout()
{
	if(!globalBoolSolved)
		client_print(0, print_chat, "[MG] You all were too slow - Learn more Math - The Solution was %i", globalIntSolution)
	
	globalBoolSolved = true
	
	set_task(get_pcvar_float(globalNativeFrequency) / 2.0, "buildQuestion");
}

public buildQuestion()
{
	new intNumbers[7]
	new charSigns[6]
	
	//new intScaleDown = 0
	
	new strQuestion[64], intPos = 0

	for ( new a = 0; a < get_pcvar_num(globalNativeLevel); a++ )
	{
		switch ( random_num(1, 3) )
		{
			case 1:
			{
				charSigns[a] = '+'
				intNumbers[a] = random_num(-get_pcvar_num(globalNativePlusMinus), get_pcvar_num(globalNativePlusMinus))
			}
			case 2:
			{
				charSigns[a] = '-'
				intNumbers[a] = random_num(-get_pcvar_num(globalNativePlusMinus), get_pcvar_num(globalNativePlusMinus))
			}
			case 3:
			{
				charSigns[a] = '*'
				//intScaleDown++
			}
		}
	}
	
	if ( charSigns[get_pcvar_num(globalNativeLevel) - 1] == '+' || charSigns[get_pcvar_num(globalNativeLevel) - 1] == '-' )
		intNumbers[get_pcvar_num(globalNativeLevel)] = random_num(-get_pcvar_num(globalNativePlusMinus), get_pcvar_num(globalNativePlusMinus))

	//if ( intScaleDown > 0 )
	//	intScaleDown = floatround(float(get_pcvar_num(globalNativeTimes)) / float(intScaleDown))
	
	//if ( intScaleDown < 2 )
	//	intScaleDown = 2

	for ( new a = 0; a < get_pcvar_num(globalNativeLevel); a++ )
	{
		if ( charSigns[a] == '*' )
		{
			intNumbers[a] = random_num(-get_pcvar_num(globalNativeTimes), get_pcvar_num(globalNativeTimes))
			intNumbers[a + 1] = random_num(-get_pcvar_num(globalNativeTimes), get_pcvar_num(globalNativeTimes))
		}
		
		intPos += formatex(strQuestion[intPos], 63 - intPos, " %s%d%s %c ",
					( intNumbers[a] < 0 ) ? "(" : "", intNumbers[a], ( intNumbers[a] < 0 ) ? ")" : "", charSigns[a])
	}
	
	intPos += formatex(strQuestion[intPos], 63 - intPos, " %s%d%s",
				( intNumbers[get_pcvar_num(globalNativeLevel)] < 0 ) ? "(" : "",
				intNumbers[get_pcvar_num(globalNativeLevel)],
				( intNumbers[get_pcvar_num(globalNativeLevel)] < 0 ) ? ")" : "")

	//Point pre-coating rule
	if ( charSigns[0] == '*' )
	{
		charSigns[0] = '+'
		intNumbers[1] = (intNumbers[0] * intNumbers[1])
		intNumbers[0] = 0
	}
	for ( new a = 1; a < get_pcvar_num(globalNativeLevel); a++ )
	{
		if ( charSigns[a] == '*' )
		{
			charSigns[a] = charSigns[a - 1]
			intNumbers[a + 1] = (intNumbers[a] * intNumbers[a + 1])
			intNumbers[a] = 0
		}
	}
	
	globalIntSolution = intNumbers[0]
	
	for ( new a = 0; a < get_pcvar_num(globalNativeLevel); a++ )
	{
		if ( charSigns[a] == '+' )
		{
			globalIntSolution += intNumbers[a + 1]
		}
		else if ( charSigns[a] == '-' )
		{
			globalIntSolution -= intNumbers[a + 1]
		}
	}

	//Print it
	client_print(0, print_chat, "[MG] Solve:  %s", strQuestion)
	
	//Reset tries
	for ( new a = 0; a < 33; a++ )
		globalIntMaxTries[a] = get_pcvar_num(globalNativeTries)
	
	globalBoolSolved = false
	
	//Set timeout
	set_task(get_pcvar_float(globalNativeFrequency) / 2.0, "questionTimeout")
}
vase070 is offline
iNdio
Senior Member
Join Date: Apr 2015
Location: Ro
Old 09-14-2016 , 14:32   Re: HELP edit plugin code
Reply With Quote #2

Works fine with hp & ap, anyway...
Attached Files
File Type: sma Get Plugin or Get Source (reward.sma - 448 views - 6.0 KB)
__________________
Where Cs had no value, amxx, sometimes, had its price...
iNdio is offline
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 09:39.


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