AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting A Variable (https://forums.alliedmods.net/showthread.php?t=47594)

raa 11-21-2006 18:58

Setting A Variable
 
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

Emp` 11-21-2006 19:31

Re: Setting A Variable
 
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)


XxAvalanchexX 11-21-2006 19:53

Re: Setting A Variable
 
http://wiki.amxmodx.org/index.php/In...od_X_Scripting

raa 11-21-2006 20:07

Re: Setting A Variable
 
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 (Post 405797)

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.

raa 11-21-2006 21:59

Re: Setting A Variable
 
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
}



All times are GMT -4. The time now is 06:58.

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