Advertisement
Guest User

Untitled

a guest
Mar 14th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. timer startMatch[1000](id) {
  2. if(matchVariables[id][starting] == 0) {
  3. stop matchTimer[id];
  4. matchTimer[id] = Timer:-1;
  5. numberLopped[id] = -1;
  6. playingMatch[id] = repeat onMatch(id);
  7. matchVariables[id][onmatch] = true;
  8. }
  9. else matchVariables[id][starting]--;
  10. }
  11.  
  12. stock saveMatch(x) {
  13. if(strlen(matchVariables[x][nameplm])) {
  14. new string[356];
  15. mysql_format(con_handle, string, 256, "UPDATE `football_matches` SET `matchName` = '%e' WHERE `matchID` = '%d'", matchVariables[x][nameplm], matchVariables[x][mid]);
  16. mysql_tquery(con_handle, string);
  17. }
  18. return 1;
  19. }
  20.  
  21. function getMatchesData() {
  22. Iter_Clear(currentTeams);
  23.  
  24. for(new x, y = cache_num_rows(); x != y; x++) {
  25. cache_get_value_name_int(x, "matchID", matchVariables[x][mid]);
  26. cache_get_value_name(x, "matchName", matchVariables[x][nameplm], 56);
  27.  
  28. prepareTeams(x);
  29. if(!Iter_Contains(currentTeams, x)) Iter_Add(currentTeams, x);
  30. }
  31.  
  32. printf("- %d matches loaded.", Iter_Count(currentTeams));
  33. return 1;
  34. }
  35.  
  36. function addMatch(text[]) {
  37. foreach(new x : currentTeams)
  38. if(!strcmp(text, matchVariables[x][nameplm])) return 1;
  39.  
  40. new string[256];
  41. mysql_format(con_handle, string, 256, "INSERT INTO `football_matches` (`matchName`) VALUES ('%e')", text);
  42. mysql_tquery(con_handle, string);
  43.  
  44.  
  45. new x = Iter_Alloc(currentTeams);
  46. matchVariables[x][mid] = cache_insert_id();
  47. format(matchVariables[x][nameplm], 56, text);
  48.  
  49. prepareTeams(x);
  50. saveMatch(x);
  51.  
  52. return 1;
  53. }
  54.  
  55. function prepareTeams(x) {
  56. new Float:c1, Float:cX, Float:c2;
  57.  
  58. c1 = frandom(5.5, 1.0);
  59. cX = frandom(10.0, 2.0);
  60. c2 = frandom(5.5, 1.0);
  61.  
  62. goalsaway[x] = 0;
  63. goalshome[x] = 0;
  64.  
  65. matchVariables[x][cota1] = c1;
  66. matchVariables[x][cotaX] = cX;
  67. matchVariables[x][cota2] = c2;
  68.  
  69. matchVariables[x][starting] = 60 + random(40);
  70. matchVariables[x][onmatch] = false;
  71.  
  72. format(matchVariables[x][home], 26, teamHome(matchVariables[x][nameplm]));
  73. format(matchVariables[x][away], 26, teamAway(matchVariables[x][nameplm]));
  74.  
  75. matchTimer[x] = repeat startMatch(x);
  76. return 1;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement