08.08.2011, 13:03
thx, but what is load speed with that code ?
stock IsFloat(buf[])
{
new l = strlen(buf);
new dcount = 0;
for(new i=0; i<l; i++)
{
if(buf[i] == '.')
{
if(i == 0 || i == l-1) return 0;
else
{
dcount++;
}
}
if((buf[i] > '9' || buf[i] < '0') && buf[i] != '+' && buf[i] != '-' && buf[i] != '.') return 0;
if(buf[i] == '+' || buf[i] == '-')
{
if(i != 0 || l == 1) return 0;
}
}
if(dcount == 0 || dcount > 1) return 0;
return 1;
}
#define GetDistancePointLine(%0,%1,%2,%3,%4,%5,%6,%7,%8) \
floatsqroot(floatpower((%4) * ((%8) - (%2)) - (%5) * ((%7) - (%1)), 2.0) + floatpower((%5) * ((%6) - (%0)) - (%3) * ((%8) - (%2)), 2.0) + floatpower((%3) * ((%7) - (%1)) - (%4) * ((%6) - (%0)), 2.0)) / floatsqroot((%3) * (%3) + (%4) * (%4) + (%5) * (%5))
%0 - Line start position X. %1 - Line start position Y. %2 - Line start position Z. %3 - Line vector X. %4 - Line vector Y. %5 - Line vector Z. %6 - Point X. %7 - Point Y. %8 - Point Z.
GetDistancePointLine(0.0, 0.0, 0.0, 0.5, 0.5, 0.1, 500.0, 800.0, 10.0);
x> = player look at --- = line x> --------------------
[07:09:54] [Strong] Execute in 892 ms [07:09:55] [Ryder] Execute in 894 ms
Is there any function for randomizing letters?
I would just use random(26) and a series of case but that'll just slow down the code. Just curious if someone had done this the easy and faster kind of way. |
random(26) + 'a'; // non-captial letters
random(26) + 'A'; // captial letters
Well the only way I know of would be to use random bounds
pawn Код:
which I think is 0x61 to 0x7A So the code would be RandomBounds(0x61, 0x7A); (sorry I forgot the actual numbers for some reason I can only remember the hex) Hope that helps ... if it's right (should be I think!) |
RandomBounds('a', 'z');
RandomBounds('A', 'Z');
RyDeR's you have any sever ?
send for my in PM. _________________ UpToLower In Macros: following the post of RyDeR's i'm create this: <code> INT: FORUM SA-MP OUT: forum sa-mp StrToUpper <code> Int: forum sa-mp Out: FORUM SA-MP Credts: me. |
#define strToUpper(%0) \
for(new i; %0[i] != EOS; ++i) \
%0[i] = ('a' <= %0[i] <= 'z') ? (%0[i] += 'A' - 'a') : (%0[i])
#define strToLower(%0) \
for(new i; %0[i] != EOS; ++i) \
%0[i] = ('A' <= %0[i] <= 'Z') ? (%0[i] += 'a' - 'A') : (%0[i])
Well the only way I know of would be to use random bounds
pawn Код:
which I think is 0x61 to 0x7A So the code would be RandomBounds(0x61, 0x7A); (sorry I forgot the actual numbers for some reason I can only remember the hex) Hope that helps ... if it's right (should be I think!) |
pawn Код:
pawn Код:
|
Thanks guys, will try both.
Anyway do these functions outputs the code in string or integer? |
#define Array:%1<%2> %1[(%2) char]
stock Array_Get(array[], index) return array{index};
stock getPlayerFirstRPName( playerid, bool: oneCharAllowed = false )
{
new
pName[ MAX_PLAYER_NAME ]
;
GetPlayerName( playerid, szName, sizeof szName );
if ( !( 'A' <= pName[ 0 ] <= 'Z' ) ) // if ( !( szName[ 0 ] >= 'A' && szName[ 0 ] <= 'Z' ) )
return 0;
if ( !oneCharAllowed )
{
if ( szName[ 1 ] == '_' )
return 0;
}
new
iPos = strfind( szName, "_" )
;
strdel( szName, iPos, strlen( szName ) );
return szName;
}
stock getPlayerFirstRPName( playerid, bool: oneCharAllowed = false )
{
new
pName[ MAX_PLAYER_NAME ]
;
GetPlayerName( playerid, szName, sizeof szName );
if ( !( 'A' <= pName[ 0 ] <= 'Z' ) ) // if ( !( szName[ 0 ] >= 'A' && szName[ 0 ] <= 'Z' ) )
return 0;
if ( !oneCharAllowed )
{
if ( szName[ 1 ] == '_' )
return 0;
}
new
iPos = strfind( szName, "_" )
;
if ( iPos == -1 )
szName[ iPos ] = EOS;
return szName;
}
new
iPos = strfind(szName, "_")
;
if(iPos != -1)
szName[iPos] = EOS;
return szName;
OffTopic: May I ask what does ' szName[ iPos ] = EOS ' does ? And what's EOS?
Sorry if I act like a noob, I really want to know And thanks, rep++ |