Raised This Month: $ Target: $400
 0% 

Setting A Variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
raa
Senior Member
Join Date: Oct 2005
Old 11-21-2006 , 18:58   Setting A Variable
Reply With Quote #1

OK in PHP to set a variable based off of a calculation I do

Code:
$value_1 = 1;
$value_2 = 2;

$sum = (($value_2 - $value_1));

echo $sum;
In amxx I've gotten this far

Code:
#define VALUE_1 0
#define VALUE_2 1
#define VALUE_3 2

#define MAXVALUE 3

new SUMVALUES[33]

new const SUMS[MAXVALUE][] = 
{ 
	"0",
	"1",
        "2"
}

??????? <----  set a variable based on the sum of VALUE_3 minus VALUE_2 for use of calling later on. 

client_print(id,print_chat, "Three minus two is %i", SUMS[SUMVALUES[id]]);
secondly, am I even on the right track with the amxx script that I do have down? lol
raa is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-21-2006 , 19:31   Re: Setting A Variable
Reply With Quote #2

I'm pretty sure you're overcomplicating things. heres an equivilent (sp?) of your php code
Code:
new value1 = 1
new value2 = 2

new sum = value2 - value1

client_print(id, print_chat, "%d", sum)
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 11-21-2006 , 19:53   Re: Setting A Variable
Reply With Quote #3

http://wiki.amxmodx.org/index.php/In...od_X_Scripting
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
raa
Senior Member
Join Date: Oct 2005
Old 11-21-2006 , 20:07   Re: Setting A Variable
Reply With Quote #4

yeah I'm sure I may be making it more complicated then it needs to be. I always do that. Thank you for the reply.

However,

I guess I misled a little.. There are many more sums then just value1 and value2. Depending on certain conditions the player may need to subtract 32 from another variable, 33 from a completely different variable..

In other words I need to know how to

do a calculation (which is different depending on conditions.)
for example;
Code:
if(stats[0] >= 100 && stats[0] <= 150)
		{
		PlayerRank[id] = RANK_1
	}
then also subtract "stats[0]" from RANK_2, store that sum as sum[variable[id]].

then call that stored number in a client_print
Code:
client_print(id,print_chat, "%d", sum[variable[id]]);
get what I"m saying? or am I completely missing something?


Quote:
Originally Posted by XxAvalanchexX View Post
yeah I look through that quite often. It's hard to find what I need not knowing anything to begin with.(vocab / terminology) Got any keywords I should search for in there?
All I know is what a plugin needs to do to get something done.
As always i will be looking through that and trying stuff when waiting for reply's.

Last edited by raa; 11-21-2006 at 20:13.
raa is offline
raa
Senior Member
Join Date: Oct 2005
Old 11-21-2006 , 21:59   Re: Setting A Variable
Reply With Quote #5

ok I figured it out.. Thanks for the nudges guys...

Code:
new SUM[33]

new VALUE1 = 1
new VALUE2 = 2
new VALUE3 = 3

if(stats[0] < 1)
		{
		SUM[id] = (VALUE2  -  stats[0])  
	}
if(stats[0] < 2)
		{
		SUM[id] = (VALUE3  -  stats[0])  
	}
        client_print(id,print_chat, "%d is the answer", SUM[id]);
	
	return 0
}
raa 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 06:58.


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