Author Topic: GUI text reading  (Read 1160 times)

New Problem, I am trying to make a manual for Survival RP, and I'm loading a text file (its all one) to the MLText Control name SRPM_Contents, and for some reason, it doesn't set the text to it, but the Index text does, I used some of the RTB system for this, but I have another idea in mind for the index system, here is the code for loading the Contents:
Code: [Select]
function Survival_Manual::OnWake(%this)
{
   if(!isFile("Add-ons/Gamemode_SurvivalRP/GUI/Manual/Index.txt"))
   {
      messageBoxOK("...","ERROR: Survival_Manual - Missing File Index.txt, leave coding to the proffesionals and don't screw with things!");
      return;
   }
   SRPM_Index.clear();
   SRPM_Contents.clear(); //Clearing them and then resetting them to new values
   
   if(isFile("Add-ons/Gamemode_SurvivalRP/GUI/Manual/Content.txt"))
   {
      echo("Loading Manual Content");
      %Content = new Fileobject();
      %Content.openforRead("Add-ons/Gamemode_SurvivalRP/GUI/Manual/Content.txt");
      while(!%Content.isEOF())
         {
            %stuff = %Content.readline();
               SRPM_Contents.setText(%stuff);
         }
         %Content.close();
         %Content.delete();
   }
Please help, what could be causing this not to set the text, it doesn't echo any errors!
« Last Edit: June 01, 2009, 08:46:55 PM by AGlass0fMilk »

InitContainerRadiusSearch(%speakerpos,$Survival::ChatRange, $TypeMasks::PlayerObjectType);
      while((%Listener = ContainerSearchNext()) != 0)
      {
         %Cprefix = %client.clanprefix;
         %Csuffix = %client.clansuffix;
         %Cname = %client.name;
         if(%client.tdmTeam $= %Listener.tdmTeam)
         Try adding an open bracket here...
         %TeamListenerNum++;
         messageClient(%Listener.client,"","\c5[Local] \c7"@ %Cprefix @"\c3"@ %Cname @"\c7"@ %Csuffix @"\c4: "@ %text);
         And a close one here
      }
      if(%TeamListenerNum <= 1)
      {
         messageClient(%client,"","\c6No one else hears you...");
         }
      }
   }
};

And you're comparing a client object's team variable to a player object's team variable.

And you're comparing a client object's team variable to a player object's team variable.
Oh. That too.

yeah, I got it working myself, but thanks anyways. Here is my finished code:
Code: [Select]
if(%client.tdmTeam == %Listener.client.tdmTeam && %client.minigame.isMember(%Listener.client))
         {
         %TeamListenerNum++;
         messageClient(%Listener.client,"","\c5[Local] \c7"@ %Cprefix @"\c3"@ %Cname @"\c7"@ %Csuffix @"\c4: "@ %text);
      }}
      if(%TeamListenerNum <= 1)
      {
         messageClient(%client,"","\c6No one else hears you...");
That's not all of it, but that is all you need to know. The reason I got stuck on this is because I rarely use While statements, I was figuring out how to structure it so it would work.  :cookieMonster:

Shouldn't it be:
 if(%TeamListenerNum < 1)
otherwise its going to say that if there is only one player near you.

Shouldn't it be:
 if(%TeamListenerNum < 1)
otherwise its going to say that if there is only one player near you.
No, because the person who uses it is counted in that radius search.

I'll consult you if I need anymore help.

No, because the person who uses it is counted in that radius search.
Oh. My mistake.

Here's a tip for when you're doing stuff with the chat:

Instead of using
Code: [Select]
messageClient(client, callback, string);Use
Code: [Select]
commandtoclient(client, 'chatmessage', sender*, 0*, 0*, string, sender.clanPrefix, sender.getPlayerName(), sender.clanSuffix, message, 0*);*: Not 100% sure about these bunch but nothing seems to break just using 0s there.
To perfectly replicate how the default chat appears (visually, the *'d arguments may differ) you would use:
Code: [Select]
function servercmdmessagesent(%client,%message)
{
commandtoall('chatmessage', %client, 0, 0, "\c7" @ %client.clanPrefix @ "\c3" @ %client.getPlayerName() @ "\c7" @ %client.clanSuffix @ "\c6:" SPC %message, %client.clanPrefix, %client.getPlayerName(), %client.clanSuffix, %message, 0);
}

This way, people with clientside mods that do things with chat (mine is a bot, which I admit is somewhat frowned upon but mine does a bunch of useful stuff as well as standard buggering, plus some little modifications to chat display, but another example is Trader's filter chat by BL_ID mod that was released at some point) won't be broken by your modification of the chat.

THE MOAR YOU KNOW. :D

Well, I plane on manipulating the chat, like make it so if you are closer, the chat is bigger, and if you are further away, the chat is smaller. I'm pretty sure that is no problem though, even using that method.



What's an "unction"?

I accidentally cut off the f on function, it would be giving me syntax errors if that was the problem, it doesn't echo any syntaxes, but why isn't the text in the file loading to the Text control?