Advertisement
Hreesang

Untitled

Apr 25th, 2024
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.89 KB | None | 0 0
  1. main() {
  2.     yield 1;
  3.     wait_ms(3000);
  4.  
  5.     new List:strings1 = list_new();
  6.     new List:strings2 = list_new();
  7.  
  8.     print("Initializing...");
  9.     for (new i = 0; i < 5; i++) {
  10.         new String:string1 = str_acquire(str_format("[strings1] String %i", i));
  11.         list_add(strings1, string1);
  12.  
  13.         new String:string2 = str_acquire(str_format("[strings2] String %i", i));
  14.         list_add_str_s(strings2, string2);
  15.     }
  16.    
  17.     print("Initialized! Getting the first index of both lists...");
  18.    
  19.     new String:strings1At0 = String:list_get(strings1, 0);
  20.     print_s(str_format("strings1 at index 0: %S", strings1At0));
  21.  
  22.     new String:strings2At0 = list_get_str_s(strings2, 0);
  23.     print_s(str_format("strings2 at index 0: %S", strings2At0));
  24.  
  25.     print("Done! Deleting strings...");
  26.     str_delete(strings1At0);
  27.     str_delete(strings2At0);
  28.  
  29.     print("Ok! Running asynchronous...");
  30.     yield 1;
  31.     wait_ms(1000);
  32.  
  33.     print("Checking strings status...");
  34.     strings1At0 = String:list_get(strings1, 0);
  35.     print_s(str_format("strings1 at index 0 is %s", str_valid(strings1At0) ? "VALID" : "INVALID"));
  36.  
  37.     strings2At0 = list_get_str_s(strings2, 0);
  38.     print_s(str_format("strings2 at index 0 is %s", str_valid(strings2At0) ? "VALID" : "INVALID"));
  39. }
  40.  
  41. /* OUTPUT
  42.  
  43. [2024-04-26T10:51:17+0700] [Info] Initializing...
  44. [2024-04-26T10:51:17+0700] [Info] Initialized! Getting the first index of both lists...
  45. [2024-04-26T10:51:17+0700] [Info] strings1 at index 0: [strings1] String 0
  46. [2024-04-26T10:51:17+0700] [Info] strings2 at index 0: [strings2] String 0
  47. [2024-04-26T10:51:17+0700] [Info] Done! Deleting strings...
  48. [2024-04-26T10:51:17+0700] [Info] Ok! Running asynchronous...
  49. [2024-04-26T10:51:18+0700] [Info] Checking strings status...
  50. [2024-04-26T10:51:18+0700] [Info] strings1 at index 0 is INVALID
  51. [2024-04-26T10:51:18+0700] [Info] strings2 at index 0 is VALID
  52.  
  53. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement