Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- timer startMatch[1000](id) {
- if(matchVariables[id][starting] == 0) {
- stop matchTimer[id];
- matchTimer[id] = Timer:-1;
- numberLopped[id] = -1;
- playingMatch[id] = repeat onMatch(id);
- matchVariables[id][onmatch] = true;
- }
- else matchVariables[id][starting]--;
- }
- stock saveMatch(x) {
- if(strlen(matchVariables[x][nameplm])) {
- new string[356];
- mysql_format(con_handle, string, 256, "UPDATE `football_matches` SET `matchName` = '%e' WHERE `matchID` = '%d'", matchVariables[x][nameplm], matchVariables[x][mid]);
- mysql_tquery(con_handle, string);
- }
- return 1;
- }
- function getMatchesData() {
- Iter_Clear(currentTeams);
- for(new x, y = cache_num_rows(); x != y; x++) {
- cache_get_value_name_int(x, "matchID", matchVariables[x][mid]);
- cache_get_value_name(x, "matchName", matchVariables[x][nameplm], 56);
- prepareTeams(x);
- if(!Iter_Contains(currentTeams, x)) Iter_Add(currentTeams, x);
- }
- printf("- %d matches loaded.", Iter_Count(currentTeams));
- return 1;
- }
- function addMatch(text[]) {
- foreach(new x : currentTeams)
- if(!strcmp(text, matchVariables[x][nameplm])) return 1;
- new string[256];
- mysql_format(con_handle, string, 256, "INSERT INTO `football_matches` (`matchName`) VALUES ('%e')", text);
- mysql_tquery(con_handle, string);
- new x = Iter_Alloc(currentTeams);
- matchVariables[x][mid] = cache_insert_id();
- format(matchVariables[x][nameplm], 56, text);
- prepareTeams(x);
- saveMatch(x);
- return 1;
- }
- function prepareTeams(x) {
- new Float:c1, Float:cX, Float:c2;
- c1 = frandom(5.5, 1.0);
- cX = frandom(10.0, 2.0);
- c2 = frandom(5.5, 1.0);
- goalsaway[x] = 0;
- goalshome[x] = 0;
- matchVariables[x][cota1] = c1;
- matchVariables[x][cotaX] = cX;
- matchVariables[x][cota2] = c2;
- matchVariables[x][starting] = 60 + random(40);
- matchVariables[x][onmatch] = false;
- format(matchVariables[x][home], 26, teamHome(matchVariables[x][nameplm]));
- format(matchVariables[x][away], 26, teamAway(matchVariables[x][nameplm]));
- matchTimer[x] = repeat startMatch(x);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement