Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   String being trimmed when I don't want it to? (https://forums.graalonline.com/forums/showthread.php?t=68602)

ChibiChibiLuc 09-07-2006 10:29 PM

String being trimmed when I don't want it to?
 
Due to a 'typo,' an item's name was set as 'Gold Platemail '
Notice the extra space at the end.
The string holding the number of Gold Platemail I have is set as 'Gold Platemail =3' in attributes. Notice the space again.

When the system goes to load the archetype of 'Gold Platemail,' it trims out the space even though I didn't tell it to. This causes a bug. The systems look for the stats of 'Gold Platemail ' but they're saved as 'Gold Platemail' so it doesn't find them.

I tried to make an NPC convert all 'Gold Platemail ' strings to 'Gold Platemail' but the NPC automatically trims the space off the end..

Any ideas?

xXziroXx 09-07-2006 11:05 PM

Try substring'ing it?

Admins 09-08-2006 01:26 AM

What script operation is trimming the string?

ApothiX 09-11-2006 04:01 PM

Why don't you just rename the archetype? If it has an error in it's name like that it should be renamed anyway x_x

Yen 09-11-2006 08:56 PM

That's the problem.
It automatically trims the space, so even if I rename the archetype to have a space it will be trimmed.

PHP Code:

  if (clientr.(@"item-Gold Platemail ").size() >= 1) {
    
clientr.(@"item-Gold Platemail") = {clientr.(@"item-Gold Platemail")[0] + clientr.(@"item-Gold Platemail ")[0],"armor/chest/goldplatemail"};
    
clientr.(@"item-Gold Platemail ") = "";
  } 


Admins 09-12-2006 12:51 AM

I still don't understand where exactly your problem is, I would need to know when it is trimming your strings and when it is not.

ChibiChibiLuc 09-12-2006 02:52 AM

To anyone still interested:
Stefan found out that you can find if the player has an instance of the string with the space (Gold Platemail ) by using getstringkeys("clientr.item-Gold Platemail").

After that, I figured out you can do something like this:
PHP Code:

temp.gpmstring "clientr.item-Gold Platemail ";
clientr.("item-Gold Platemail") = {makevar(temp.gpmstring)[0],"armor/chest/goldplatemail"}; 



All times are GMT +2. The time now is 08:51 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.