Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[HELP] pm's message
#1
Where an error?
The message comes together without blanks
Quote:[PM]: hihowareyou


Code:
//pm's a player with supplied message
        void personalMessage(ServerClient issuer, String message)
        {
            String[] split = message.Split(' ');
            ServerClient target;
            if (!(split.Length > 1))
            {
                TellClient(issuer.ClientNum, "Please provide a receiver", true);
                return;
            }
            else if (!(split.Length > 2))
            {
                TellClient(issuer.ClientNum, "Please provide a message", true);
                return;
            }
            target = findClient(split[1]);
            if (target == null)
            {
                TellClient(issuer.ClientNum, "Player could not be found, or multiple were found", true);
                return;
            }
            else
            {
                String pmessage = "";
                for (int i = 2; i < split.Length; i++)
                {
                    pmessage += split[i];
                }
                TellClient(target.ClientNum, "^1[PM]^2" + issuer.Name + ":^7 " + pmessage, true);
            }
        }
Reply

#2
(12-15-2012, 11:51)korsika Wrote: Where an error?
The message comes together without blanks
Quote:[PM]: hihowareyou


Code:
//pm's a player with supplied message
        void personalMessage(ServerClient issuer, String message)
        {
            String[] split = message.Split(' ');
            ServerClient target;
            if (!(split.Length > 1))
            {
                TellClient(issuer.ClientNum, "Please provide a receiver", true);
                return;
            }
            else if (!(split.Length > 2))
            {
                TellClient(issuer.ClientNum, "Please provide a message", true);
                return;
            }
            target = findClient(split[1]);
            if (target == null)
            {
                TellClient(issuer.ClientNum, "Player could not be found, or multiple were found", true);
                return;
            }
            else
            {
                String pmessage = "";
                for (int i = 2; i < split.Length; i++)
                {
                    pmessage += split[i];
                }
                TellClient(target.ClientNum, "^1[PM]^2" + issuer.Name + ":^7 " + pmessage, true);
            }
        }

You are splitting by the blanks => All blanks get "deleted"
So you have to add them again:
Use this:
pmessage += split[i] + " ";
instead of this:
pmessage += split[i];
[Image: compiling.png][Image: aLKA8og_460sa.gif]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Spawn Message Playing on Respawn? Killjoy 7 5,231 07-11-2013, 14:53
Last Post: Killjoy
  [News] Message from Gabe to Steam Community d0h! 8 5,616 04-05-2013, 18:16
Last Post: SuperNovaAO
  Help timer/message for flags hillbilly 31 14,646 01-20-2013, 18:20
Last Post: [Z00MBY] Alex
  [Request] Different message per map hillbilly 6 3,777 12-22-2012, 20:55
Last Post: hillbilly
  Chat Message The Tronuo 8 5,017 11-12-2012, 18:05
Last Post: Nekochan
  Health,regenerate, and message changes help mbakerinnv 4 3,491 11-02-2012, 18:12
Last Post: mbakerinnv
  S&D Welcome message only once (no repeating) islamsaab 2 2,613 10-11-2012, 18:40
Last Post: islamsaab
  Can I add the first blood message from infected to another gametype? NooB_StalkeR 0 1,726 07-12-2012, 04:21
Last Post: NooB_StalkeR
  plugin message kpoviv 1 1,945 07-08-2012, 17:24
Last Post: JariZ
  message central kpoviv 2 2,059 07-08-2012, 03:55
Last Post: JariZ

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.