format/ex question/help
Hello,
I have a little problem with formatex.. Let's say I just used function parse, to split a text from a file. Code:
Variable _fileData[x][10] will contain for example "%s is %s's boss" Next I have 1 array which holds names, _names[33][128] Now.. when I try to format another string using formatex like this: Code:
I get the "Error: Array must be indexed (variable "_names") on line xx". Someone told me, function "formatex" doesn't knows that _fileData[x][10] contains 2 %s, so thats why I get that error. I want to know how should I do so it will work as I want? Don't know how to explain better.. if you don't understand I will post the entire code. Thanks in advance. |
Re: format/ex question/help
The format functions treat a string like any other function in pawn in regards to indexing. Post the exact variable declarations and format line that gives you an error.
|
Re: format/ex question/help
Here is the whole code:
http://pastebin.com/Hjr2ynCq And I put this in the file to test: "amx_slay" b s:adminname s:targetname 0 0 0 0 0 "ADMIN: %s slaughtered %s" |
Re: format/ex question/help
So each _names you have in formatex have 2 %s? That may be another problem but that would not throw a compiler error, if anything just a runtime error. I don't have access to a computer so I can't look at your full code now.
|
Re: format/ex question/help
Uhm, lets say that I used format before:
Code:
Variable _fileData[0][10] holds the following text "%s is now %s." (I copied from a file using parse.. just an example) Now I want to format a message like this: Code:
so I can't print it in chat later to get "Lul is now Woot.". |
Re: format/ex question/help
Try to make a little test script and see if it works. I do not see a problem but not sure how the compiler well take it.
|
Re: format/ex question/help
Uhm.. my script test compiled, I guess smthing it's wrong with my variable (still don't know what).
Buuuut.. still doesn't works, now I get a runtime error in the test script. Code:
L 11/10/2011 - 23:21:07: [AMXX] Run time error 25 (plugin "formatex_test.amxx") - debug not enabled! |
Re: format/ex question/help
formatex(msg, charsmax(msg), "%s is now %s.")
-> formatex(msg, charsmax(msg), "%%s is now %%s.") If it's not working, try : msg = "%s is now %s." |
Re: format/ex question/help
Or use copy() since there's no formatting anyway.
or new szStr[] = "%s says hi to %s" |
Re: format/ex question/help
Quote:
But I still have a little problem at my script, not the test one. I have this: Code:
Error: Array must be indexed (variable "strmsg") on line 180 Line 180: Code:
The other cases are not modified.. tried a lot of things, that's why the other case looks diferent (3 to 7) LE: I know.. there are a lot of useless variables, because I tried a lot of things ^.^. I'll clean up my code after I fix this error. |
| All times are GMT -4. The time now is 14:22. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.