![]() |
Something really helpful with string lists i discovered last night
I thought I would post this so people of my scripting skill level might use this. I was working on my housing system, and I didn't want to store a variable in the housing database showing how many users are on the list, so it knows how many times to loop.
So heres what I did: I took my string list and stored it in this.houseowners using setstring thiso.houseowners within the getnpc. I then tokenized the string list, and I could loop through it with tokenscount. I hope others can find this as useful as I did. As its helpful with bans from certain levels, housing systems, lottery systems. Proof that you do learn more efficient ways to do things as you script. Otherwise id still be setting a variable to store how many items are in the string list. |
If the list is a list of account names, tokenize isn't what you want to use, as it's going to split based on commas AND spaces. There are account names with spaces in them... and doing it with that method will prevent them from working.
|
what would be a good way to handle spaces?
|
Use the string list as you were, with commas separating each account. Then use sarraylen(string) and #I(string,index) instead of tokenscount and #t(index).
|
Thanks!
|
If you tokenized and put account omg wow w/ out quotes in the database it wouldnt work but if you set omg wow with quotes around it I believe it would. Like for example a staff tool.
If you said: /nick self "*KuJi <3" It would set your name as *KuJi <3 If you said: /nick self *KuJi <3 It would set your name as *KuJi |
But he already figured that out..?
|
| All times are GMT +2. The time now is 04:11 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.