19.06.2012, 19:12
Quote:
Create a TextDraw box. This is about as accurate as I could get it.
|
pawn Код:
new Text:box = TextDrawCreate(x1, y1, "LD_BUM:blkdot");
TextDrawFont(box, 4);
TextDrawTextSize(box, (x2 - x1), (y2 - y1));
Create a TextDraw box. This is about as accurate as I could get it.
|
new Text:box = TextDrawCreate(x1, y1, "LD_BUM:blkdot");
TextDrawFont(box, 4);
TextDrawTextSize(box, (x2 - x1), (y2 - y1));
stock ConvertPrice( price, no_price_tag = 0 )
{
new
szString[ 32 ],
iNumbers = 0,
bool: isneg = price < 0 ? true : false
;
if( isneg ) price = price * -1;
iNumbers = floatround( floatlog( price ), floatround_floor ) + 1;
format( szString, sizeof( szString ), "%d", price );
while( iNumbers >= 4 ) {
iNumbers -= 3;
strins( szString, ",", iNumbers );
}
if( !no_price_tag ) strins( szString, "$", 0 );
if( isneg ) strins( szString, "-", 0 );
return szString;
}
stock convertNumber(iValue, iDelim[2] = ".", szNum[15] = "", iSize = sizeof(szNum)) {
format(szNum, iSize, "%d", iValue < 0 ? -iValue : iValue);
for(new i = strlen(szNum) - 3; i > 0; i -= 3) {
strins(szNum, iDelim, i, iSize);
}
if(iValue < 0) {
strins(szNum, "-", 0, iSize);
}
return szNum;
}
printf("%s", convertNumber(1246645455, .iDelim = "_")); // 1_246_645_455
printf("%s", convertNumber(-145455, .iDelim = ".")); // -145.455
printf("%s", convertNumber(-94411254, .iDelim = ",")); // -94,411,254
// Usage: wait(time)
wait(5000);
#define varGet(%0) getproperty(0,%0)
#define varSet(%0,%1) setproperty(0, %0, %1)
#define new_strcmp(%0,%1) \
(varSet(%0, 1), varGet(%1) == varSet(%0, 0)) // by DraKiNs
Hey RyDeR' !
You that like math, answer me (GangZones Post) --- I tried everything, but can not find anything (to create "circulation" must make "interpolation" of gangzones) |
stock RoundGangZone(const Float: radius, const Float: X , const Float: Y, const color, const size = 20) {
new
Float: inc = 90.0 / size,
Float: deg = inc,
Float: cos,
Float: sin,
zone
;
while(deg < 90.0) {
cos = floatcos(deg, degrees) * radius;
sin = floatsin(deg, degrees) * radius;
zone = GangZoneCreate(X - cos, Y - sin, X + cos, Y + sin);
GangZoneShowForAll(zone, color);
deg += inc;
}
return zone;
}
#include < YSI\y_scripting >
stock debugAllZCMDCommands( playerid, szAdditionParam[ ] = "500" ) // The first parameter will be 500 e.g /kick 500
{
static
szPublic[ 32 ],
iCount
;
while( ( iCount = Scripting_GetPublicFast( iCount, szPublic, ( Scripting_FastString('c', 'm', 'd', '_') ) ) ) )
{
if( !strcmp( szPublic, "cmd_testallcmds", true ) ) continue; // The command that you're placing this function in (so it doesn't repeat...)
printf( "%s", szPublic );
CallLocalFunction( szPublic, "ds", playerid, szAdditionParam );
}
// If your server crashes, then the last command called is the problem
return 1;
}
Revamped the version someone posted about ConvertPrice itself, it now doesn't use valstr and supports negative numbers.
pawn Код:
I fixed some little glitch with the logarithm... Should work fine now! |
pawn Код:
It doesnt look like a circle because of my resolution |
fRemoveLine(file[],line[])//By: Firecat
{
new string[256],
File:Temp = fopen("Temp.ini",io_append),
File:Main = fopen(file,io_read);
while(fread(Main,string))
{
if(strcmp(string,line) != 0)
{
fwrite(Temp,string);
}
}
fclose(Main);
fclose(Temp);
fremove(file);
Main = fopen(file, io_append);
Temp = fopen("Temp.ini",io_read);
while(fread(Temp,string))
{
fwrite(Main,string);
}
fclose(Main);
fclose(Temp);
fremove("Temp.ini");
return 1;
}
fUpdateLine(file[],oldline[],newline[])//By: Firecat
{
new string[256],
File:Temp = fopen("Temp.ini",io_append),
File:Main = fopen(file,io_append);
while(fread(Main,string))
{
if(!strcmp(oldline,string))
fwrite(Temp,newline)
else
fwrite(Temp,string)
}
fclose(Main);
fclose(Temp);
fremove(file);
File:Main = fopen(file,io_append);
File:Temp = fopen("Temp.ini",io_read);
while(fread(Temp,string))
{
fwrite(Main,string);
}
fclose(Temp);
fclose(Main);
fremove(Temp);
return 1;
}
fChangeName(file[],newname[])//By:Firecat
{
new string[256],
File:New = fopen(newname,io_append),
File:Main = fopen(file,io_read);
while(fread(Main,string))
{
fwrite(New,string);
}
fclose(Main);
fclose(New);
fremove(Main);
return 1;
}
Yeah, right here.
|
Question:
Is there a function that gives me a random X Axis, random Y axis, from a given Max X, Max Y? |
stock Float: randomFloat(Float: fMin, Float: fMax, iDig) {
iDig = _: floatpower(10.0, iDig);
fMin = Float: (floatround(fMin * Float: iDig));
fMax = Float: (floatround(fMax * Float: iDig));
return (random((_: fMax - _: fMin)) + _: fMin) / Float: iDig;
}
pawn Код:
|
That "iDig" is...?
Edit: and how would I use the function? What does it return ? e.e |
#define SIGNIFICANT_DIGITS (3)
printf("%.*f", SIGNIFICANT_DIGITS, randomFloat(6.123, 11.5, SIGNIFICANT_DIGITS)); // Possible output: 8.465
Yeah sorry, I was kinda in a hurry. iDig is the amount of significant digits. A basic example would be:
pawn Код:
No, I have tested it a couple of times and it did actually work with no problems. |
for(new i; i < 1600; i++)
{
CreateExplosion(randomFloat(-341.5977,-135.6987,3),randomFloat(2796.9480,2589.1521,3),61.8585,2,50);
}
Thanks! <3
Edit: I'm using this code: pawn Код:
|
stock Float: randomFloat(Float: fMin, Float: fMax, iDig) {
iDig = _: floatpower(10.0, iDig);
fMin = Float: (floatround(fMin * Float: iDig));
fMax = Float: (floatround(fMax * Float: iDig));
return (random((_: fMax - _: fMin)) + _: fMin) / Float: iDig;
}
CreateExplosion(randomFloat(-341.5977, -135.6987, 3), randomFloat(2589.1521, 2796.9480, 3), 61.8585, 2, 50);