![]() |
Trouble With Strlen()
im sorry i havent posted code in a while..
plz help meh X_x if (created) { timeout=0.05; } if (timeout) { timeout=0.05; setstring message2,This is NOT a Test; showimg 2,@@b@#s(client.message2),screenwidth-strlen(message2)*8,screenheight-21; changeimgvis 2,4; } I need it to be kinda like the little thing on GK that says you know "you avatar of govannon atmoizes Glok Lord" |
1) Strlen takes a string, not the name of a string. Currently it's returning the length of 'message2'.
2) Use a this.string for temp stuff. |
what would i use to get the length of "this is NOT a test" then?
|
Use a for loop. What you need to do is get the strlen of the string's value (this is NOT a test), not just the length of the string name.
|
a for loop?
how would the script look then? |
I don't know why protagonist is talking about loops. Anyway:
#s() converts string names into strings. |
Everybody always tells me to do for loops :(.
I would do something like for(i=0;i<strlen(#s(message2));i++) type thing. |
Quote:
|
X_x
strlen(#s(client.message2)) would be the length of "this is NOT a test" then? |
strlen(#s(message2))
|
woo! alright i got it working now... i feel good now that stefan posted in my thread thanks for the help guys
|
Quote:
Ugh, sorry, that would just give i the the value of the length of message2. Quote:
|
Quote:
now i gotta figure out the right number to multiply it by.. X_x and i think capital letters will screw that up Edit : Yep... having lower case letters numbers and capital letters changes everything... now im gonna have to check the string for caps, numbers, and lowercase letters X_x |
Quote:
Do you even know what the guy's trying to do? He's trying to use strlen to return a value. Using a for loop does not help him learn to use strlen. And the fact that everyone else tells you to do for loops has absolutely nothing to do with this situation. Sorry, just had to complain about that. Anyway, as for your problem wonderboy, align your showimg text to the right instead of the left perhaps? Then you need not worry about strlen at all, really. |
omg i can just Align it?????
|
Quote:
Well, that was mean, I already admitted my mistake. I was thinking about sarraylen, not strlen. |
Quote:
Quote:
|
Yes, I didn't have the right command. But Kaimetsu pointed it out already, and I made it clear I was mistaken.
|
If you look in newfeatures2003.txt you will notice there is a nice new handy variable added called textwidth :)
so instead of using strlen() I would suggest using textwidth NPC Code: Makes things easier and more accurate than guessing a formula to get the width of your text ---Kain Morbid |
:confused: umm... i dont think anyone has really helped solved my problem...
|
Quote:
|
NPC Code: I have bolded what you forgot in your script. though I do suggest using text width instead of strlen()*8 seeing as how textwidth is MUCH more accurate. ---Kain Morbid |
yea kain i had gotten that part figured out but it turns out that *8 only works when each letter in message2 is lower case... numbers and CAPS screw up the placement.. which is why i want to know what tseng was talking about when he said i can probably align things to the right
|
It doesn't work at all when the font is not monospaced. Anyway:
Firstly, use showtext instead of showimg. Secondly, use an 'r' in the style argument. If you don't understand, read newfeatures.txt. |
alright thanks kai
i used showimg because im just more used to showimg @@@ but yea ok show text and r in style arguement all so simple ^_^ |
lol, showtext, I can't stand that!
sarraylen() needs a for loop why? Sarraylen you don't need #s for, and it checks the amount of arrays in it rather than it's length x-x ---Shifter |
Quote:
|
cmon kai you cant deny that after using showimg @@@ for a while, it's hard to switch over to a new command
|
Quote:
|
| All times are GMT +2. The time now is 11:09 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.