strlower -
ATGOggy - 19.01.2015
What's wrong with this?
PHP код:
strlower(string[])
{
for(new i=0; i<MAX_PLAYER_NAME; i++)
{
string[i] = tolower(string[i]);
}
return string;
}
When I types amalm, it prints "#Lњamalm"
What should I do?
Re: strlower -
Banana_Ghost - 19.01.2015
If I'm not mistaking, tolower only lowercases one letter, so this comes in handy:
pawn Код:
#define UpperToLower(%1) for ( new ToLowerChar; ToLowerChar < strlen( %1 ); ToLowerChar ++ ) if ( %1[ ToLowerChar ] > 64 && %1[ ToLowerChar ] < 91 ) %1[ ToLowerChar ] += 32
credits to original author of that define.
Try this:
pawn Код:
strlower(string[])
{
UpperToLower(string);
return string;
}
Re: strlower -
Misiur - 19.01.2015
Also you could use
pawn Код:
for(new i=0; string[i] != EOS; i++)
Watch out for accidental arrays though
Re: strlower -
ATGOggy - 19.01.2015
Quote:
Originally Posted by Misiur
Also you could use
pawn Код:
for(new i=0; string[i] != EOS; i++)
Watch out for accidental arrays though
|
When I use that, it prints "<#L�amalm"
Re: strlower -
nezo2001 - 19.01.2015
What is the meaning of this ??
Did you make a stock with this function ?
If this is the code that you made the function with add
before the nae of the function.
Re: strlower -
ATGOggy - 19.01.2015
Quote:
Originally Posted by nezo2001
What is the meaning of this ??
Did you make a stock with this function ?
If this is the code that you made the function with add
before the nae of the function.
|
Read the post I made a few hours ago:
https://sampforum.blast.hk/showthread.php?tid=558834
I also had the same doubt.
But, still my problem isn't fixed. Anybody help me.
Re: strlower -
xVIP3Rx - 19.01.2015
With your code, it gives me spaces instead of litters
test code:
pawn Код:
public OnPlayerText(playerid, text[])
{
SendClientMessage(playerid, -1, strlower(text));
return 0;
}
stock strlower(string[])
{
for(new i; i<strlen(string); i++) string[i] = tolower(string[i]);
return string;
}
Those work, tested, one returns the string and one doesn't.
pawn Код:
#define strlower(%1) for(new i; i<strlen(%1); i++) %1[i] = tolower(%1[i])
public OnPlayerText(playerid, text[])
{
strlower(text);
return 1;
}
pawn Код:
public OnPlayerText(playerid, text[])
{
SendClientMessage(playerid, -1, strlower(text));
return 0;
}
stock strlower(string[])
{
new tempstring[MAX_PLAYER_NAME];
for(new i; i<strlen(string); i++) tempstring[i] = tolower(string[i]);
return tempstring;
}
Re: strlower -
Misiur - 19.01.2015
If those weird characters appeared on the end of the string it woulbe be understandable - typical overflow. However they are appearing at the beginning of the string. What argument are you passing to this function? Is it some substring of inputtext?
Re: strlower -
ATGOggy - 20.01.2015
Quote:
Originally Posted by xVIP3Rx
With your code, it gives me spaces instead of litters
test code:
pawn Код:
public OnPlayerText(playerid, text[]) { SendClientMessage(playerid, -1, strlower(text)); return 0; } stock strlower(string[]) { for(new i; i<strlen(string); i++) string[i] = tolower(string[i]);
return string; }
Those work, tested, one returns the string and one doesn't.
pawn Код:
#define strlower(%1) for(new i; i<strlen(%1); i++) %1[i] = tolower(%1[i])
public OnPlayerText(playerid, text[]) { strlower(text); return 1; }
pawn Код:
public OnPlayerText(playerid, text[]) { SendClientMessage(playerid, -1, strlower(text)); return 0; } stock strlower(string[]) { new tempstring[MAX_PLAYER_NAME];
for(new i; i<strlen(string); i++) tempstring[i] = tolower(string[i]);
return tempstring; }
|
I gets these errors with the second code:
Quote:
E:\San Andreas Roleplay Cops And Robbers\gamemodes\SARCR.pwn(789) : error 029: invalid expression, assumed zero
E:\San Andreas Roleplay Cops And Robbers\gamemodes\SARCR.pwn(789) : error 029: invalid expression, assumed zero
E:\San Andreas Roleplay Cops And Robbers\gamemodes\SARCR.pwn(789) : warning 215: expression has no effect
E:\San Andreas Roleplay Cops And Robbers\gamemodes\SARCR.pwn(789) : error 017: undefined symbol "i"
E:\San Andreas Roleplay Cops And Robbers\gamemodes\SARCR.pwn(789) : fatal error 107: too many error messages on one line
|
These lines are the stock Userpath
Re: strlower -
ATGOggy - 20.01.2015
Quote:
Originally Posted by xVIP3Rx
With your code, it gives me spaces instead of litters
test code:
pawn Код:
public OnPlayerText(playerid, text[]) { SendClientMessage(playerid, -1, strlower(text)); return 0; } stock strlower(string[]) { for(new i; i<strlen(string); i++) string[i] = tolower(string[i]);
return string; }
Those work, tested, one returns the string and one doesn't.
pawn Код:
#define strlower(%1) for(new i; i<strlen(%1); i++) %1[i] = tolower(%1[i])
public OnPlayerText(playerid, text[]) { strlower(text); return 1; }
pawn Код:
public OnPlayerText(playerid, text[]) { SendClientMessage(playerid, -1, strlower(text)); return 0; } stock strlower(string[]) { new tempstring[MAX_PLAYER_NAME];
for(new i; i<strlen(string); i++) tempstring[i] = tolower(string[i]);
return tempstring; }
|
Third code worked
Thank you very very much, bro
You are the best
rep++;