File size: 22,486 Bytes
72629ed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | #if defined _INC_SSCANF
#endinput
#endif
#define _INC_SSCANF
#if !defined _samp_included
#error Please include <a_npc> or <a_samp> first.
#endif
#define SSCANF_STATIC__
#if defined __PawnBuild
#if __PawnBuild == 11
#undef SSCANF_STATIC__
#define SSCANF_STATIC__ static
#endif
#else
#if !defined SSCANF_NO_NICE_FEATURES
#error sscanf utilises community compiler features. Use `#define SSCANF_NO_NICE_FEATURES` to live without (if you can call that living) or better yet download it here: github.com/pawn-lang/compiler/releases
#endif
#endif
#if defined GetDistanceFromMeToPoint
static stock SSCANF_NPC = 1;
#define SSCANF_NPC (1)
#pragma library sscanf
#else
static stock SSCANF_NPC = 0;
#define SSCANF_NPC (0)
#endif
static stock SSCANF_VERSION_MAJOR = 2;
#define SSCANF_VERSION_MAJOR 2
static stock SSCANF_VERSION_MINOR = 13;
#define SSCANF_VERSION_MINOR 13
static stock SSCANF_VERSION_BUILD = 8;
#define SSCANF_VERSION_BUILD 8
static stock SSCANF_VERSION_STRING[] = #SSCANF_VERSION_MAJOR "." #SSCANF_VERSION_MINOR "." #SSCANF_VERSION_BUILD;
#define SSCANF_VERSION_STRING #SSCANF_VERSION_MAJOR "." #SSCANF_VERSION_MINOR "." #SSCANF_VERSION_BUILD
forward BCD(number);
#define BCD(%0) (_:MORE_BCD:NO_MORE_BCD:%0.$0)
#define MORE_BCD:NO_MORE_BCD:%0.%1$%2) MORE_BCD:NO_MORE_BCD:%1$(%2) << 8 | DO_BCD(%0))
#define NO_MORE_BCD:$
#define DO_BCD(%0) _:(%0) / 10 << 4 | _:(%0) % 10
const SSCANF_VERSION = BCD(SSCANF_VERSION_MAJOR.SSCANF_VERSION_MINOR.SSCANF_VERSION_BUILD);
stock const SSCANF_VERSION_BCD = SSCANF_VERSION;
#define sscanf_%0\32; sscanf_
#define SSCANF:%0(%1) forward sscanf_%0(%1);public sscanf_%0(%1)
#define @kustom()%0(%1) forward sscanf_%0(%1);public sscanf_%0(%1)
#if defined sscanf && !defined SSCANF_GetClosestString
#error sscanf already defined, or used before inclusion.
#endif
native SSCANF__(const file[], const line, const data[], const format[], {T_WEAPON, Float, _}:...);
native UNFORMAT__(const file[], const line, const data[], const format[], {T_WEAPON, Float, _}:...) = SSCANF__;
native SSCANF_Init(players, invalid, len);
native SSCANF_Join(playerid, const name[], bool:npc);
native SSCANF_Leave(playerid);
native bool:SSCANF_IsConnected(playerid);
native SSCANF_Levenshtein(const string1[], const string2[]);
native Float:SSCANF_TextSimilarity(const string1[], const string2[]);
native SSCANF_GetOption(const name[]) = SSCANF_Option;
native SSCANF_GetOption__(const name[]) = SSCANF_Option;
native SSCANF_SetOption(const name[], {_, Float}:value) = SSCANF_Option;
native SSCANF_SetOption__(const name[], {_, Float}:value) = SSCANF_Option;
forward SSCANF_Option(const name[], {_, Float}:value = -1);
#define SSCANF_Option SSCANF_GetOption__
#define SSCANF_GetOption__(%0,%1) SSCANF_SetOption__(%0,%1)
#define _ALS_SSCANF_Option
#define _ALS_SSCANF_GetOption__
native SSCANF_VersionString(version[], size = sizeof (version)) = SSCANF_Version;
native SSCANF_VersionString__(version[], size = sizeof (version)) = SSCANF_Version;
native SSCANF_VersionBCD() = SSCANF_Version;
native SSCANF_VersionBCD__() = SSCANF_Version;
static stock SSCANF_Version(version[] = "", size = sizeof (version))
{
return SSCANF_VERSION_BCD;
}
#define SSCANF_Version SSCANF_VersionString__
#define SSCANF_VersionString__() SSCANF_VersionBCD__()
#define _ALS_SSCANF_Version
#define _ALS_SSCANF_VersionString__
#if defined __PawnBuild
#pragma warning push
#pragma warning disable 234
#endif
#pragma deprecated - include <sscanf2> first.
forward sscanf(const data[], const format[], {T_WEAPON, Float, _}:...);
#if defined __PawnBuild
#pragma warning pop
#endif
#if defined __PawnBuild
#define sscanf( SSCANF__(__file,__line,
#else
#define sscanf( SSCANF__(SSCANF_UNK_,-1,
#endif
#if defined __PawnBuild
#pragma warning push
#pragma warning disable 234
#endif
#pragma deprecated - include <sscanf2> first.
forward unformat(const data[], const format[], {T_WEAPON, Float, _}:...);
#if defined __PawnBuild
#pragma warning pop
#endif
#if defined __PawnBuild
#define unformat( SSCANF__(__file,__line,
#else
#define unformat( SSCANF__(SSCANF_FOM_,-1,
#endif
stock const SSCANF_UNK_[] = "sscanf";
stock const SSCANF_FOM_[] = "unformat";
stock const SSCANF_EXT_[] = "extract";
stock const SSCANF_QUIET[] = "SSCANF_QUIET";
stock const OLD_DEFAULT_NAME[] = "OLD_DEFAULT_NAME";
stock const MATCH_NAME_PARTIAL[] = "MATCH_NAME_PARTIAL";
stock const CELLMIN_ON_MATCHES[] = "CELLMIN_ON_MATCHES";
stock const OLD_DEFAULT_KUSTOM[] = "OLD_DEFAULT_KUSTOM";
stock const OLD_DEFAULT_CUSTOM[] = "OLD_DEFAULT_CUSTOM";
stock const SSCANF_COLOUR_FORMS[] = "SSCANF_COLOUR_FORMS";
stock const SSCANF_ALPHA[] = "SSCANF_ALPHA";
stock const SSCANF_ARGB[] = "SSCANF_ARGB";
stock const MATCH_NAME_FIRST[] = "MATCH_NAME_FIRST";
stock const MATCH_NAME_SIMILARITY[] = "MATCH_NAME_SIMILARITY";
static stock SSCANF_gInit = 0;
#if !defined CHAIN_ORDER
#define CHAIN_ORDER() 0
#endif
#define CHAIN_HOOK(%0) forward @CO_%0();public @CO_%0(){return CHAIN_ORDER()+1;}
#define CHAIN_NEXT(%0) @CO_%0
#define CHAIN_FORWARD:%0_%2(%1)=%3; \
forward %0_%2(%1); \
public %0_%2(%1) <_ALS : _ALS_x0, _ALS : _ALS_x1> { return (%3); } \
public %0_%2(%1) <> { return (%3); }
#define CHAIN_PUBLIC:%0(%1) %0(%1) <_ALS : _ALS_go>
CHAIN_HOOK(SSCANF)
#undef CHAIN_ORDER
#define CHAIN_ORDER CHAIN_NEXT(SSCANF)
static stock _SSCANF_IncludeStates() <_ALS : _ALS_x0, _ALS : _ALS_x1, _ALS : _ALS_x2, _ALS : _ALS_x3> {}
static stock _SSCANF_IncludeStates() <_ALS : _ALS_go> {}
#if SSCANF_NPC && !defined SSCANF_NO_PLAYERS
forward SSCANF_PlayerCheck();
#endif
native SSCANF_SetTimer(const funcname[], interval, bool:repeating) = SetTimer;
#if !defined __PawnBuild
forward SSCANF_RunInit();
static stock SSCANF_RunInit0()
{
}
#endif
static stock SSCANF_RunInit()
{
#if SSCANF_NPC
state _ALS : _ALS_go;
SSCANF_Init(MAX_PLAYERS, INVALID_PLAYER_ID, MAX_PLAYER_NAME);
#if !defined SSCANF_NO_PLAYERS
SSCANF_PlayerCheck();
SSCANF_SetTimer("SSCANF_PlayerCheck", 0, true);
#endif
#else
state _ALS : _ALS_go;
if ((SSCANF_gInit = SSCANF_Init(GetMaxPlayers(), INVALID_PLAYER_ID, MAX_PLAYER_NAME)) == 1)
{
new
name[MAX_PLAYER_NAME + 1];
for (new i = 0; i != MAX_PLAYERS; ++i)
{
if (IsPlayerConnected(i) && !SSCANF_IsConnected(i))
{
GetPlayerName(i, name, sizeof (name));
SSCANF_Join(i, name, bool:IsPlayerNPC(i));
}
}
}
#endif
}
#if SSCANF_NPC
public OnNPCModeInit()
{
SSCANF_RunInit();
SSCANF_OnNPCModeInit();
return 1;
}
#if defined _ALS_OnNPCModeInit
#undef OnNPCModeInit
#else
#define _ALS_OnNPCModeInit
#endif
#define OnNPCModeInit(%0) CHAIN_PUBLIC:SSCANF_OnNPCModeInit(%0)
CHAIN_FORWARD:SSCANF_OnNPCModeInit() = 1;
#else
const SSCANF_STATIC__ SSCANF_OnNPCModeInit = 0;
#define SSCANF_OnNPCModeInit
#endif
#if SSCANF_NPC && !defined SSCANF_NO_PLAYERS
public SSCANF_PlayerCheck()
{
new
name[MAX_PLAYER_NAME + 1];
for (new i = 0; i != MAX_PLAYERS; ++i)
{
if (IsPlayerConnected(i))
{
if (!SSCANF_IsConnected(i))
{
GetPlayerName(i, name, sizeof (name));
SSCANF_Join(i, name, false);
}
}
else
{
if (SSCANF_IsConnected(i))
{
SSCANF_Leave(i);
}
}
}
}
#else
const SSCANF_STATIC__ SSCANF_PlayerCheck = 0;
#define SSCANF_PlayerCheck
#endif
#define SSCANF_BRACKETS ()
forward OnScriptInit SSCANF_BRACKETS;
#undef SSCANF_BRACKETS
#if SSCANF_NPC
const SSCANF_STATIC__ SSCANF_OnScriptInit = 0;
#define SSCANF_OnScriptInit
#else
public OnScriptInit()
{
if (!SSCANF_gInit)
{
SSCANF_RunInit();
}
SSCANF_OnScriptInit();
return 1;
}
#if defined _ALS_OnScriptInit
#undef OnScriptInit
#else
#define _ALS_OnScriptInit
#endif
#define OnScriptInit(%0) CHAIN_PUBLIC:SSCANF_OnScriptInit(%0)
CHAIN_FORWARD:SSCANF_OnScriptInit() = 1;
#endif
#if SSCANF_NPC
const SSCANF_STATIC__ SSCANF_OnFilterScriptInit = 0;
#define SSCANF_OnFilterScriptInit
#else
public OnFilterScriptInit()
{
if (!SSCANF_gInit)
{
SSCANF_RunInit();
}
SSCANF_OnFilterScriptInit();
return 1;
}
#if defined _ALS_OnFilterScriptInit
#undef OnFilterScriptInit
#else
#define _ALS_OnFilterScriptInit
#endif
#define OnFilterScriptInit(%0) CHAIN_PUBLIC:SSCANF_OnFilterScriptInit(%0)
CHAIN_FORWARD:SSCANF_OnFilterScriptInit() = 1;
#endif
#if SSCANF_NPC
const SSCANF_STATIC__ SSCANF_OnGameModeInit = 0;
#define SSCANF_OnGameModeInit
#else
public OnGameModeInit()
{
if (!SSCANF_gInit)
{
SSCANF_RunInit();
}
SSCANF_OnGameModeInit();
return 1;
}
#if defined _ALS_OnGameModeInit
#undef OnGameModeInit
#else
#define _ALS_OnGameModeInit
#endif
#define OnGameModeInit(%0) CHAIN_PUBLIC:SSCANF_OnGameModeInit(%0)
CHAIN_FORWARD:SSCANF_OnGameModeInit() = 1;
#endif
forward OnCachedInit();
#if SSCANF_NPC
const SSCANF_STATIC__ SSCANF_OnCachedInit = 0;
#define SSCANF_OnCachedInit
#else
public OnCachedInit()
{
SSCANF_RunInit();
SSCANF_OnCachedInit();
return 1;
}
#if defined _ALS_OnCachedInit
#undef OnCachedInit
#else
#define _ALS_OnCachedInit
#endif
#define OnCachedInit(%0) CHAIN_PUBLIC:SSCANF_OnCachedInit(%0)
CHAIN_FORWARD:SSCANF_OnCachedInit() = 1;
#endif
#if SSCANF_NPC
const SSCANF_STATIC__ SSCANF_OnPlayerConnect = 0;
#define SSCANF_OnPlayerConnect
#else
public OnPlayerConnect(playerid)
{
if (SSCANF_gInit == 1)
{
new
name[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, name, sizeof(name));
SSCANF_Join(playerid, name, bool:IsPlayerNPC(playerid));
}
SSCANF_OnPlayerConnect(playerid);
return 1;
}
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect(%0) CHAIN_PUBLIC:SSCANF_OnPlayerConnect(%0)
CHAIN_FORWARD:SSCANF_OnPlayerConnect(playerid) = 1;
#endif
#if SSCANF_NPC
const SSCANF_STATIC__ SSCANF_OnPlayerDisconnect = 0;
#define SSCANF_OnPlayerDisconnect
#else
public OnPlayerDisconnect(playerid, reason)
{
SSCANF_OnPlayerDisconnect(playerid, reason);
if (SSCANF_gInit == 1)
{
SSCANF_Leave(playerid);
}
return 1;
}
#if defined _ALS_OnPlayerDisconnect
#undef OnPlayerDisconnect
#else
#define _ALS_OnPlayerDisconnect
#endif
#define OnPlayerDisconnect(%0) CHAIN_PUBLIC:SSCANF_OnPlayerDisconnect(%0)
CHAIN_FORWARD:SSCANF_OnPlayerDisconnect(playerid, reason) = 1;
#endif
#define SSCANF_Init
#define SSCANF_Join
#define SSCANF_Leave
#define SSCANF_IsConnected
#if defined __PawnBuild
#define extract%0->%1; EXTRN%1;UNFORMAT__(__file,__line,_:EXTRV:EXTRX:%0,""#,%1,,);
#else
#define extract%0->%1; EXTRN%1;UNFORMAT__(SSCANF_EXT_,-1,_:EXTRV:EXTRX:%0,""#,%1,,);
#endif
#define UNFORMAT__(%7,%8,_:EXTRV:EXTRX:%0,""#,%1);%2else if (UNFORMAT__(%7,%8,_:EXTRV:EXTRX:%0,""#,%1))
#define EXTRV:EXTRX:%0<%3>%4#,%9new%1,%2) EXTRZ:EXTRY:%0%4#P<%3>,|||%1|||%2)
#define EXTRZ:EXTRY:%0#P<,> EXTRY:%0"P<,>"#
#define EXTRX:%0#,%9new%1,%2) EXTRY:%0#,|||%1|||%2)
#define EXTRY: EXTR8:EXTR9:EXTR0:EXTR1:EXTR2:EXTR3:EXTR4:
#define EXTR8:EXTR9:EXTR0:EXTR1:EXTR2:EXTR3:EXTR4:%0#%1,%2|||%6:%3=%9|||%4) %6_EXTRO:%0#%1,%2|||%3=%9|||%4)
#define EXTR9:EXTR0:EXTR1:EXTR2:EXTR3:EXTR4:%0#%1,%2|||%3=%9|||%4) __EXTRO:%0#%1,%2|||%3=%9|||%4)
#define EXTR0:EXTR1:EXTR2:EXTR3:EXTR4:%0#%1,%2|||%6:%3[%7]|||%4) %6_EXTRW:%0#%1,%2|||%3[%7]|||%4)
#define EXTR1:EXTR2:EXTR3:EXTR4:%0#%1,%2|||%3[%7]|||%4) __EXTRW:%0#%1,%2|||%3[%7]|||%4)
#define EXTR2:EXTR3:EXTR4:%0#%1,%2|||%6:%3|||%4) %6_EXTRN:%0#%1,%2|||%3|||%4)
#define EXTR3:EXTR4:%0#%1,,%2||||||%4) %0#%1,%2)
#define EXTR4:%0#%1,%2|||%3|||%4) __EXTRN:%0#%1,%2|||%3|||%4)
#define __EXTRO:%0#%1,%2|||%3=%9|||%4,%5) EXTRY:%0#%1I"("#%9")"#,%2,%3|||%4|||%5)
#define Float_EXTRO:%0#%1,%2|||%3=%9|||%4,%5) EXTRY:%0#%1F"("#%9")"#,%2,%3|||%4|||%5)
#define player_EXTRO:%0#%1,%2|||%3=%9|||%4,%5) EXTRY:%0#%1U"("#%9")"#,%2,%3|||%4|||%5)
#define string_EXTRO:%0#%1,%2|||%3[%7]=%9|||%4,%5) EXTRY:%0#%1S"("#%9")[*]",%2,(%7),%3|||%4|||%5)
#define __EXTRN:%0#%1,%2|||%3|||%4,%5) EXTRY:%0#%1i,%2,%3|||%4|||%5)
#define Float_EXTRN:%0#%1,%2|||%3|||%4,%5) EXTRY:%0#%1f,%2,%3|||%4|||%5)
#define player_EXTRN:%0#%1,%2|||%3|||%4,%5) EXTRY:%0#%1u,%2,%3|||%4|||%5)
#define __EXTRW:%0#%1,%2|||%3[%7]|||%4,%5) EXTRY:%0#%1a<i>[*],%2,(%7),%3|||%4|||%5)
#define Float_EXTRW:%0#%1,%2|||%3[%7]|||%4,%5) EXTRY:%0#%1a<f>[*],%2,(%7),%3|||%4|||%5)
#define player_EXTRW:%0#%1,%2|||%3[%7]|||%4,%5) EXTRY:%0#%1a<u>[*],%2,(%7),%3|||%4|||%5)
#define string_EXTRW:%0#%1,%2|||%3[%7]|||%4,%5) EXTRY:%0#%1s[*],%2,(%7),%3|||%4|||%5)
#define EXTRN%0new%1; new%1;
#if !defined string
#define string:
#endif
#define player:%0;UNFORMAT__(%1) %0;UNFORMAT__(%1)
#define hex:%0;UNFORMAT__(%1) %0;UNFORMAT__(%1)
#define hex_EXTRO:%0#%1,%2|||%3=%9|||%4,%5) EXTRY:%0#%1H"("#%9")"#,%2,%3|||%4|||%5)
#define hex_EXTRN:%0#%1,%2|||%3|||%4,%5) EXTRY:%0#%1h,%2,%3|||%4|||%5)
#define hex_EXTRW:%0#%1,%2|||%3[%7]|||%4,%5) EXTRY:%0#%1a<h>[*],%2,(%7),%3|||%4|||%5)
#define bin:%0;UNFORMAT__(%1) %0;UNFORMAT__(%1)
#define bin_EXTRO:%0#%1,%2|||%3=%9|||%4,%5) EXTRY:%0#%1B"("#%9")"#,%2,%3|||%4|||%5)
#define bin_EXTRN:%0#%1,%2|||%3|||%4,%5) EXTRY:%0#%1b,%2,%3|||%4|||%5)
#define bin_EXTRW:%0#%1,%2|||%3[%7]|||%4,%5) EXTRY:%0#%1a<b>[*],%2,(%7),%3|||%4|||%5)
#define colour:%0;UNFORMAT__(%1) %0;UNFORMAT__(%1)
#define colour_EXTRO:%0#%1,%2|||%3=%9|||%4,%5) EXTRY:%0#%1M"("#%9")"#,%2,%3|||%4|||%5)
#define colour_EXTRN:%0#%1,%2|||%3|||%4,%5) EXTRY:%0#%1m,%2,%3|||%4|||%5)
#define colour_EXTRW:%0#%1,%2|||%3[%7]|||%4,%5) EXTRY:%0#%1a<m>[*],%2,(%7),%3|||%4|||%5)
#define kustom:%0<%1> %0
#define kustom_EXTRO:%0#%1,%2|||%3<%8>=%9|||%4,%5) EXTRY:%0#%1K<%8>"("#%9")"#,%2,%3|||%4|||%5)
#define kustom_EXTRN:%0#%1,%2|||%3<%8>|||%4,%5) EXTRY:%0#%1k<%8>,%2,%3|||%4|||%5)
stock SSCANF_GetSimilarString(const input[], const candidates[][], Float:threshold = 0.111111, count = sizeof (candidates))
{
new
closest = cellmin,
Float:distance;
while (count--)
{
distance = SSCANF_TextSimilarity(input, candidates[count]);
if (distance >= threshold)
{
closest = count,
threshold = distance;
}
}
return closest;
}
stock SSCANF_GetSimilarValue(const input[], const candidates[][], const results[], fail = cellmin, Float:threshold = 0.111111, count = sizeof (candidates), check = sizeof (results))
{
assert(count == check);
new closest = SSCANF_GetSimilarString(input, candidates, threshold, count);
if (closest == cellmin)
{
return fail;
}
return results[closest];
}
#if defined __PawnBuild
#pragma warning push
#pragma warning disable 234
#endif
#pragma deprecated Use `SSCANF_GetSimilarString` for more human results.
stock SSCANF_GetClosestString(const input[], const candidates[][], threshold = cellmax, count = sizeof (candidates))
{
new
closest = cellmin,
distance;
while (count--)
{
distance = SSCANF_Levenshtein(input, candidates[count]);
if (distance < threshold)
{
closest = count,
threshold = distance;
}
}
return closest;
}
#if defined __PawnBuild
#pragma warning pop
#endif
#if defined __PawnBuild
#pragma warning push
#pragma warning disable 234
#endif
#pragma deprecated Use `SSCANF_GetSimilarValue` for more human results.
stock SSCANF_GetClosestValue(const input[], const candidates[][], const results[], fail = cellmin, threshold = cellmax, count = sizeof (candidates), check = sizeof (results))
{
assert(count == check);
new closest = SSCANF_GetClosestString(input, candidates, threshold, count);
if (closest == cellmin)
{
return fail;
}
return results[closest];
}
#if defined __PawnBuild
#pragma warning pop
#endif
#if defined SSCANF_NO_K_WEAPON
native SSCANF_no_k_weapon();
#define SSCANF_no_k_weapon()
#else
SSCANF:weapon(const string[])
{
static const results[] = {
0, 0, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25,
26, 27, 28, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46
};
static const candidates[][] = {
"Fists",
"Unarmed",
"Knuckles",
"Knuckledusters",
"Brass Knuckles",
"Golf Club",
"Night Stick",
"Knife",
"Baseball Bat",
"Shovel",
"Pool cue",
"Katana",
"Chainsaw",
"Purple Dildo",
"White Dildo",
"Long White Dildo",
"White Dildo 2",
"Flowers",
"Cane",
"Grenades",
"Tear Gas",
"Molotovs",
"Pistol",
"Silenced Pistol",
"Desert Eagle",
"Shotgun",
"Sawn Off Shotgun",
"Combat Shotgun",
"Micro Uzi",
"Mac 10",
"MP5",
"AK47",
"M4",
"Tec9",
"Rifle",
"Sniper Rifle",
"RPG",
"Missile Launcher",
"Flame Thrower",
"Minigun",
"Sachel Charges",
"Detonator",
"Spray Paint",
"Fire Extinguisher",
"Camera",
"Nightvision Goggles",
"Thermal Goggles",
"Parachute"
};
if ('0' <= string[0] <= '9')
{
new
ret = strval(string);
if (0 <= ret <= 18 || 22 <= ret <= 46)
{
return ret;
}
}
else
{
return SSCANF_GetSimilarValue(string, candidates, results, -1);
}
return -1;
}
#endif
#if defined SSCANF_NO_K_VEHICLE
native SSCANF_no_k_vehicle();
#define SSCANF_no_k_vehicle()
#else
SSCANF:vehicle(const string[])
{
static const results[] = {
400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417,
418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435,
436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453,
454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471,
472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489,
490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507,
508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525,
526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543,
544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561,
562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579,
580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597,
598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611
};
static const candidates[][] = {
"Landstalker",
"Bravura",
"Buffalo",
"Linerunner",
"Perennial",
"Sentinel",
"Dumper",
"Firetruck",
"Trashmaster",
"Stretch",
"Manana",
"Infernus",
"Voodoo",
"Pony",
"Mule",
"Cheetah",
"Ambulance",
"Leviathan",
"Moonbeam",
"Esperanto",
"Taxi",
"Washington",
"Bobcat",
"Mr Whoopee",
"BF Injection",
"Hunter",
"Premier",
"Enforcer",
"Securicar",
"Banshee",
"Predator",
"Bus",
"Rhino",
"Barracks",
"Hotknife",
"Article Trailer",
"Previon",
"Coach",
"Cabbie",
"Stallion",
"Rumpo",
"RC Bandit",
"Romero",
"Packer",
"Monster",
"Admiral",
"Squalo",
"Seasparrow",
"Pizzaboy",
"Tram",
"Article Trailer 2",
"Turismo",
"Speeder",
"Reefer",
"Tropic",
"Flatbed",
"Yankee",
"Caddy",
"Solair",
"Topfun Van (Berkley's RC)",
"Skimmer",
"PCJ-600",
"Faggio",
"Freeway",
"RC Baron",
"RC Raider",
"Glendale",
"Oceanic",
"Sanchez",
"Sparrow",
"Patriot",
"Quad",
"Coastguard",
"Dinghy",
"Hermes",
"Sabre",
"Rustler",
"ZR-350",
"Walton",
"Regina",
"Comet",
"BMX",
"Burrito",
"Camper",
"Marquis",
"Baggage",
"Dozer",
"Maverick",
"SAN News Maverick",
"Rancher",
"FBI Rancher",
"Virgo",
"Greenwood",
"Jetmax",
"Hotring Racer",
"Sandking",
"Blista Compact",
"Police Maverick",
"Boxville",
"Benson",
"Mesa",
"RC Goblin",
"Hotring Racer \"A\"",
"Hotring Racer \"B\"",
"Bloodring Banger",
"Rancher Lure",
"Super GT",
"Elegant",
"Journey",
"Bike",
"Mountain Bike",
"Beagle",
"Cropduster",
"Stuntplane",
"Tanker",
"Roadtrain",
"Nebula",
"Majestic",
"Buccaneer",
"Shamal",
"Hydra",
"FCR-900",
"NRG-500",
"HPV1000",
"Cement Truck",
"Towtruck",
"Fortune",
"Cadrona",
"FBI Truck",
"Willard",
"Forklift",
"Tractor",
"Combine Harvester",
"Feltzer",
"Remington",
"Slamvan",
"Blade",
"Freight (Train)",
"Brownstreak (Train)",
"Vortex",
"Vincent",
"Bullet",
"Clover",
"Sadler",
"Firetruck LA",
"Hustler",
"Intruder",
"Primo",
"Cargobob",
"Tampa",
"Sunrise",
"Merit",
"Utility Van",
"Nevada",
"Yosemite",
"Windsor",
"Monster \"A\"",
"Monster \"B\"",
"Uranus",
"Jester",
"Sultan",
"Stratum",
"Elegy",
"Raindance",
"RC Tiger",
"Flash",
"Tahoma",
"Savanna",
"Bandito",
"Freight Flat Trailer (Train)",
"Streak Trailer (Train)",
"Kart",
"Mower",
"Dune",
"Sweeper",
"Broadway",
"Tornado",
"AT400",
"DFT-30",
"Huntley",
"Stafford",
"BF-400",
"Newsvan",
"Tug",
"Petrol Trailer",
"Emperor",
"Wayfarer",
"Euros",
"Hotdog",
"Club",
"Freight Box Trailer (Train)",
"Article Trailer 3",
"Andromada",
"Dodo",
"RC Cam",
"Launch",
"Police Car (LSPD)",
"Police Car (SFPD)",
"Police Car (LVPD)",
"Police Ranger",
"Picador",
"S.W.A.T.",
"Alpha",
"Phoenix",
"Glendale Shit",
"Sadler Shit",
"Baggage Trailer \"A\"",
"Baggage Trailer \"B\"",
"Tug Stairs Trailer",
"Boxville",
"Farm Trailer",
"Utility Trailer"
};
if ('0' <= string[0] <= '9')
{
new
ret = strval(string);
if (400 <= ret <= 611)
{
return ret;
}
}
else
{
return SSCANF_GetSimilarValue(string, candidates, results, -1);
}
return -1;
}
#endif
#define SSCANF__(%0:...) BAD_sscanf(%0:...) |