The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spaces
Author Message
Runcuks
Journeyman
*

Posts: 179
Likes Given: 5
Likes Received: 3 in 3 posts
Joined: Nov 2012
Reputation: 0



Post: #1
Spaces
Hi, could someone tell me how to players to use spaces when they choose name for example " MyNickname" "MyNickname "
I came up with something like this but it didnt work

IF (STRMATCH(* *, <ARGTXT[0]>)) || (STRMATCH( *, <ARGTXT[0]>)) || (STRMATCH(* , <ARGTXT[0]>))
src.sysmessage @023 You can not use spaces.
return 1
ENDIF
12-04-2013 10:47 PM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: Spaces
Because you are comparing ARGTXT against.... nothing.

http://wiki.sphere.torfo.org/index.php/Chapter_10


If you refer to the link I have posted, you'll find a few methods, inclusing STRPOS which can be used to find spaces in a string.
You should be able to do it with STREGEX also using <ch 32> to detect spaces (I think... haven't run a test to make sure)

[Image: 2nis46r.jpg]
(This post was last modified: 12-04-2013 11:28 PM by Mordaunt.)
12-04-2013 11:06 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Khaos
Master
**

Posts: 595
Likes Given: 166
Likes Received: 83 in 51 posts
Joined: Mar 2012
Reputation: 11



Post: #3
RE: Spaces
This possibly might work.
PHP Code:
if strmatch("* *","<src.name>")
 
src.smsg You cannot use spaces in your name
endif
return 


Try removing the quotes if it gives you an issue.
(This post was last modified: 12-04-2013 11:33 PM by Khaos.)
12-04-2013 11:29 PM
Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes Khaos's post
Runcuks
Journeyman
*

Posts: 179
Likes Given: 5
Likes Received: 3 in 3 posts
Joined: Nov 2012
Reputation: 0



Post: #4
RE: Spaces
(12-04-2013 11:29 PM)Khaos Wrote:  This possibly might work.
PHP Code:
if strmatch("* *","<src.name>")
 
src.smsg You cannot use spaces in your name
endif
return 


Try removing the quotes if it gives you an issue.

Jup that worked thanks!
12-04-2013 11:55 PM
Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes Runcuks's post
Khaos
Master
**

Posts: 595
Likes Given: 166
Likes Received: 83 in 51 posts
Joined: Mar 2012
Reputation: 11



Post: #5
RE: Spaces
You are quite welcome. Smile
12-05-2013 01:01 AM
Find all posts by this user Like Post Quote this message in a reply
Feeh
Sphere Developer
*****

Posts: 156
Likes Given: 6
Likes Received: 40 in 29 posts
Joined: Sep 2012
Reputation: 4



Post: #6
RE: Spaces
What about STRTRIM? You can use it to remove spaces
http://wiki.sphere.torfo.org/index.php/C...10#STRTRIM

if (STRMATCH(*32*,<asc <ARGTXT[0]>>))
SYSMESSAGE "No spaces allowed!"

Feeh/Epila - Nightly releases / SphereWiki / Github Issues / Sphere's GitHub
(This post was last modified: 12-05-2013 08:02 AM by Feeh.)
12-05-2013 08:00 AM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #7
RE: Spaces
StrTrim only works for spaces at begin of given string, if you want to remove any spaces from the text they Input use <asciiremove 32,<argtxt[0]>>

Code:
[function asciiremove]
local.ascii=<argv[0]>        //Ascii Dec value of the character we want to remove, for detailed information and IDs look http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters
local.text=<streat <args>>    //Text to remove <local.ascii>
local.check=<strpos 0 <dlocal.ascii> <args>>    //We check if we have any specified ascii chr to remove
while <local.check>>0    //If so we begin
    local.len=<eval STRLEN(<local.text>)>    //Length of the text
    local.pos=<strpos 0 <dlocal.ascii> <local.text>>    //Position of current ascii char found
    if (<local.pos>==0)    //If ascii is first char we make aditional IF to remove it
        local.text=<strsub <eval <local.pos>+1> <local.len> <local.text>>    //local.text=Text except first character
    else    //Otherwise we can do whole replacement with one line
        local.text=<strsub 0 <local.pos> <local.text>><strsub <eval <local.pos>+1> <local.len> <local.text>>    //Text until found charText from found char (without spaces nor anything)
    endif
    if (<strpos 0 <dlocal.ascii> <local.text>>==-1)    //We check if we have more ascii chars to remove
        local.check=0    //and we set to 0 if not, to stop while.
    endif    
endwhile
return <local.text>        //Fixed text
(This post was last modified: 12-05-2013 09:13 AM by XuN.)
12-05-2013 09:06 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)