Working with string alteration and control...
I've been working with pawn on and off for about a year, but something I never quite understood was how to use the returned array from some sort of string function such as "clamp" or "max".
Code:
clamp(gaben,10,20)Code:
public function_setitcolor(id) { |
Niether of those 2 functions return an array. I don't know what the value of 'gaben' is that you are passing to the function but:
max() clamp() They both return a single value, depending on the input. Clamp will make sure a number is within a specified range, and max just returns the higher of the 2 numbers you pass it. Ex 1: var1 = 501 var2 = clamp(var1, 0, 300) Clamp will return: 300 Ex 2: var1 = -45 var2 = clamp(var1, 0, 300) Clamp will return: 0 Ex 3: var1 = 501 var2 = 300 var3 = max(var1, var2) Max will return: 501 |
Then allow me to rephrase my question; What if the function DOES, as in read_argv().
|
You can either use a loop to clamp each cell in the array, or just clamp whichever you need.
I'm not exactly sure what your question is, but you never seem to have mentioned str_to_num. Perhaps you're looking for that? |
You must be looking for str_to_num() then, but why are you getting 2 values for a single number? Like 10 broken into [0] = 1 and [1] = 0 ????
|
My exact question looks something like this:
"When a function returns a array that is a string broken up into different pieces (I.E. read_argv(1,blah), will make blah = 102, blah[0] = 1, blah[1] = 0, blah[2] = 2), what is the best way to use this if the command you want to use won't accept an array". I'm confusing, I know, sorry. That's the best way I can verbalize my question. You HAVE to pass an array to read_argv, and the only way to use the information it gets (to my knowlage) is that way... |
You're looking for str_to_num then.
|
Wow, very confusing.. I don't know why you are getting your number as an array, but since you are, you could do some math on it:
Assuming: blah[0] = 1 blah[1] = 0 blah[2] = 2 Code:
After you get it as an integer, then you can use max or clamp on it: new myNewNum = clamp(myNum, 1, 100) myNewNum would equal 100 :) BUT: If the value of your blah[] array has strings, like: blah[0] = "1" blah[1] = "0" blah[2] = "2" Then do this: Code:
|
| All times are GMT -4. The time now is 16:42. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.