Array Wont hold Value....
1 Attachment(s)
Ok....Coin Mod again...
ok the variable coins[33] ( which is a float ).... never seems to change... NOTE: ( the array is to hold the index e.g coins[id] ) like when you connect its supposed to give you 5 coins..but when i type /coinstat its says [COIN MOD] You have 0 coins. And...on the functins coinmod_addcoins and coinmod_removecoins when i type this commands in... e.g coin_addcoins Zenith 2 it will say something like [COIN MOD] ADMIN Zenith gave 50 coins to Zenith and i have no clue why it does that nor why the variable coins[33] wont change at all :/ |
arg2 is a string. So, the line that adds coins should look like this:
coins[target] += floatstr(arg2) And the line that displays coins should look like this: server_print( " [COIN MOD] ADMIN %s Added %f coins to player %s!", name, floatstr(arg2), victim ) Also, I think you should move get_user_name(id, victim, 31) down after you get the target and get the target's name instead of id's name. Also, there are a lot of points where you compare coins[id] to an integer. Instead of coins[id] >= 25 it should be coins[id] >= 25.0 |
Thnx avalanche! I changed all that...
And i think i know my problem... this.... Code:
should be this... Code:
right? |
Code:
That's just fine, as long as you include a decimal place, the number is considered a float, no need for the extra float keyword. |
1 Attachment(s)
it still doesnt work :/ ...
I type /coinstat " [COIN MOD] You have 0.000000 coins! " Not only that wont work but the console_print doesnt do anything either :/ ok this version is the most updated ( working ) version. |
Quote:
But you dont us it anyways. with "coins[target] += floatstr(arg2[31])" you are starting at the 31st character of the string to get the float which is why its always 0.0000 You have two choices to fix 1) new Add = str_to_num(arg2) //... coins[target] += Add 2) remove line str_to_num(arg2) //... coins[target] += floatstr(arg2) [Edit] Quote:
|
Ok someof what your saying doesn ot make since if i remove the [32] it will give me array must be indexed error...so should i make it like
arg2[0] so it starts at zero? but i think i am going to go with the string to num solution... |
When using floatstr(arg2) you dont need the [] it knows that its a string. and will start at the beginning and go to the end of and and convert to float.
|
* turltes * got it to work :)
|
Code:
|
| All times are GMT -4. The time now is 14:34. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.