• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Skipping extra spaces
#1
Hello! Not so long ago, I tried to write?a script that would remove extra spaces?in the players' sentences, so that's what I did:

PHP Code:
new strlen(text), spaces

while(--
!= -1)



? ?switch(
text[i]) 

? ?{ 

? ? ? ?case 
' ':

? ? ? ?{ 

? ? ? ? ? ?
spaces;

? ? ? ? ? ?if(
spaces 1)

? ? ? ? ? ?{ 

? ? ? ? ? ? ? ?
spaces--; ?

? ? ? ? ? ? ? ?
strdel(textii);

? ? ? ? ? ?} 

? ? ? ?} 

? ? ? ?default: 
spaces 0;

? ?} 

} ?

if(
text[i-1] == ' 'strdel(texti-1i);

if(
text[0] == ' 'strdel(text01); 

It is work, but i would like to know what can be optimized or improved.



Thanks, that's what i got:


PHP Code:
DeSpace(string[], 0)

{

? ?while((
strfind(string" ?"_i)) != -1strdel(stringii  1);

? ?if(
string[0] == ' 'strdel(string01);

? ?if(
string[strlen(string)-1] == ' 'strdel(stringstrlen(string)-1strlen(string));

? ?return 
string[strlen(string)];


[Image: aWbv5wm.gif]

  Reply


Messages In This Thread
Skipping extra spaces - by Mark2 - 2019-04-15, 11:40 AM
RE: Skipping extra spaces - by SimoSbara - 2019-04-15, 09:01 PM
RE: Skipping extra spaces - by Mark2 - 2019-04-16, 09:21 AM
RE: Skipping extra spaces - by Bork - 2019-04-15, 09:20 PM
RE: Skipping extra spaces - by SimoSbara - 2019-04-15, 09:23 PM
RE: Skipping extra spaces - by Y_Less - 2019-04-15, 10:39 PM
RE: Skipping extra spaces - by SimoSbara - 2019-04-15, 11:48 PM
RE: Skipping extra spaces - by Y_Less - 2019-04-16, 12:33 AM
RE: Skipping extra spaces - by SimoSbara - 2019-04-16, 05:52 AM
RE: Skipping extra spaces - by mr_sacrimoni - 2019-04-16, 08:06 AM
RE: Skipping extra spaces - by SimoSbara - 2019-04-16, 08:51 AM
RE: Skipping extra spaces - by SimoSbara - 2019-04-16, 10:50 AM
RE: Skipping extra spaces - by Y_Less - 2019-04-16, 11:21 AM
RE: Skipping extra spaces - by Mark2 - 2019-04-16, 01:12 PM
RE: Skipping extra spaces - by SimoSbara - 2019-04-16, 01:39 PM
RE: Skipping extra spaces - by Y_Less - 2019-04-16, 02:03 PM
RE: Skipping extra spaces - by WestCoast - 2019-04-16, 03:01 PM
RE: Skipping extra spaces - by Y_Less - 2019-04-16, 03:08 PM
RE: Skipping extra spaces - by WestCoast - 2019-04-16, 03:45 PM
RE: Skipping extra spaces - by SimoSbara - 2019-04-16, 05:49 PM
RE: Skipping extra spaces - by SyS - 2019-04-17, 03:18 AM
RE: Skipping extra spaces - by Y_Less - 2019-04-17, 02:22 PM
RE: Skipping extra spaces - by SyS - 2019-04-17, 03:06 PM
RE: Skipping extra spaces - by Y_Less - 2019-04-17, 03:29 PM

Forum Jump: