Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define SMO_INDEX_FILE "Sumo/index.ini"
- #define SMO_DATA_FILE "Sumo/%s.dat"
- #define SMO_CAM_FILE "smocam.%s"
- #define SMO_MAX_ARENA (16)
- #define SMO_MAX_NAME (32)
- #define SMO_MAX_SPAWN (8)
- #define SMO_SPAWN_ZOFFSET (5.0)
- #define SMO_SPEC_NONE (-1)
- #define SMO_SPEC_ARENA (-2)
- enum E_SMO_ARENA_DATA
- {
- smo_Name[SMO_MAX_NAME],
- smo_MaxSpawns,
- smo_Camera,
- Float:smo_Base,
- Float:smo_SpawnX[SMO_MAX_SPAWN],
- Float:smo_SpawnY[SMO_MAX_SPAWN],
- Float:smo_SpawnZ[SMO_MAX_SPAWN],
- Float:smo_SpawnR[SMO_MAX_SPAWN]
- }
- new
- smo_Data[SMO_MAX_ARENA][E_SMO_ARENA_DATA],
- smo_CurrentArena;
- new
- PlayerText:smo_TdBack,
- PlayerText:smo_TdText,
- PlayerText:smo_TdVehicle,
- PlayerText:smo_TdSpawn,
- smo_TimesFallen[MAX_PLAYERS],
- smo_SpawnCount[MAX_PLAYERS],
- smo_PlayerVehicleID[MAX_PLAYERS],
- smo_PlayerVehicleModel[MAX_PLAYERS],
- smo_Spectating[MAX_PLAYERS],
- Timer:smo_SpawnTimer[MAX_PLAYERS],
- Iterator:smo_SpawnedIndex<MAX_PLAYERS>;
- new
- smo_Vehicles[19]=
- {
- 504,
- 498,
- 502,
- 503,
- 475,
- 470,
- 478,
- 571,
- 471,
- 479,
- 482,
- 483,
- 489,
- 494,
- 495,
- 496,
- 542,
- 530,
- 572
- };
- CMD:sumo(playerid, params[])
- {
- if(bServerGlobalSettings & rc_Started)
- {
- msg(playerid, YELLOW, " > You can't start a minigame while a race is active.");
- return 1;
- }
- if(gCurrentChallenge != CHALLENGE_NONE)
- {
- msg(playerid, YELLOW, " > You can't start a minigame while a challenge is active.");
- return 1;
- }
- if(gCurrentMinigame[playerid] == MINIGAME_CARSUMO)
- {
- smo_Quit(playerid);
- }
- else if(gCurrentMinigame[playerid] == MINIGAME_NONE)
- {
- smo_CurrentArena = 0;
- smo_Join(playerid);
- msgaF(YELLOW, " > %P"#C_YELLOW" has gone to the "#C_BLUE"Sumo "#C_YELLOW"minigame! Type "#C_ORANGE"/sumo "#C_YELLOW"to join.", playerid);
- }
- else
- {
- msg(playerid, YELLOW, " > Please exit your current minigame before joining another");
- }
- return 1;
- }
- smo_Join(playerid)
- {
- gCurrentMinigame[playerid] = MINIGAME_CARSUMO;
- smo_FormatVehicleList(playerid);
- if(Iter_Contains(smo_SpawnedIndex, playerid))Iter_Remove(smo_SpawnedIndex, playerid);
- PlayerTextDrawSetString(playerid, smo_TdSpawn, "5");
- PlayerTextDrawSetSelectable(playerid, smo_TdSpawn, false);
- smo_SpawnTimer[playerid] = defer smo_UpdateSpawnButton(playerid);
- smo_SpawnCount[playerid] = 4;
- smo_Spectate(playerid);
- }
- smo_Spawn(playerid)
- {
- new spawn = random(3);
- ExitCamera(playerid);
- TogglePlayerSpectating(playerid, false);
- TogglePlayerControllable(playerid, true);
- SetPlayerPos(playerid,
- smo_Data[smo_CurrentArena][smo_SpawnX][spawn],
- smo_Data[smo_CurrentArena][smo_SpawnY][spawn],
- smo_Data[smo_CurrentArena][smo_SpawnZ][spawn] + SMO_SPAWN_ZOFFSET);
- smo_PlayerVehicleID[playerid] = CreateVehicle(smo_PlayerVehicleModel[playerid],
- smo_Data[smo_CurrentArena][smo_SpawnX][spawn],
- smo_Data[smo_CurrentArena][smo_SpawnY][spawn],
- smo_Data[smo_CurrentArena][smo_SpawnZ][spawn] + SMO_SPAWN_ZOFFSET,
- smo_Data[smo_CurrentArena][smo_SpawnR][spawn], -1, -1, -1);
- SetVehicleParamsEx(smo_PlayerVehicleID[playerid], 1, 1, 0, 0, 0, 0, 0);
- PutPlayerInVehicle(playerid, smo_PlayerVehicleID[playerid], 0);
- PlayerTextDrawShow(playerid, smo_TdBack);
- PlayerTextDrawShow(playerid, smo_TdText);
- smo_HideLobbyControls(playerid);
- Iter_Add(smo_SpawnedIndex, playerid);
- smo_Spectating[playerid] = SMO_SPEC_NONE;
- }
- script_sumo_Update(playerid)
- {
- if(Iter_Contains(smo_SpawnedIndex, playerid))
- {
- new
- iVehicle = GetPlayerVehicleID(playerid),
- Float:z;
- GetPlayerPos(playerid, z, z, z);
- if(z < smo_Data[smo_CurrentArena][smo_Base])smo_Out(playerid);
- if(!IsValidVehicle(iVehicle))
- PutPlayerInVehicle(playerid, smo_PlayerVehicleID[playerid], 0);
- }
- return 1;
- }
- smo_Out(playerid)
- {
- Iter_Remove(smo_SpawnedIndex, playerid);
- smo_TimesFallen[playerid]++;
- smo_UpdateTextDraw(playerid);
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i) || playerid == i || gCurrentMinigame[i] != MINIGAME_CARSUMO)continue;
- if(smo_Spectating[i] == playerid)
- {
- smo_Spectate(i);
- }
- }
- smo_Spectate(playerid);
- DestroyVehicle(smo_PlayerVehicleID[playerid]);
- PlayerTextDrawSetString(playerid, smo_TdSpawn, "5");
- PlayerTextDrawSetSelectable(playerid, smo_TdSpawn, false);
- smo_SpawnTimer[playerid] = defer smo_UpdateSpawnButton(playerid);
- smo_SpawnCount[playerid] = 4;
- return 1;
- }
- smo_ShowLobbyControls(playerid)
- {
- PlayerTextDrawShow(playerid, smo_TdVehicle);
- PlayerTextDrawShow(playerid, smo_TdSpawn);
- SelectTextDraw(playerid, YELLOW);
- }
- smo_HideLobbyControls(playerid)
- {
- PlayerTextDrawHide(playerid, smo_TdVehicle);
- PlayerTextDrawHide(playerid, smo_TdSpawn);
- CancelSelectTextDraw(playerid);
- }
- timer smo_UpdateSpawnButton[1000](playerid)
- {
- if(smo_SpawnCount[playerid] <= 0)
- {
- PlayerTextDrawSetString(playerid, smo_TdSpawn, "Spawn");
- PlayerTextDrawSetSelectable(playerid, smo_TdSpawn, true);
- }
- else
- {
- new
- tmpStr[2];
- valstr(tmpStr, smo_SpawnCount[playerid]);
- PlayerTextDrawSetString(playerid, smo_TdSpawn, tmpStr);
- smo_SpawnCount[playerid]--;
- smo_SpawnTimer[playerid] = defer smo_UpdateSpawnButton(playerid);
- }
- smo_ShowLobbyControls(playerid);
- }
- script_Sumo_ClickPTD(playerid, PlayerText:playertextid)
- {
- if(playertextid == smo_TdVehicle)
- {
- smo_FormatVehicleList(playerid);
- }
- if(playertextid == smo_TdSpawn)
- {
- smo_Spawn(playerid);
- }
- }
- smo_Spectate(playerid)
- {
- if(Iter_Count(smo_SpawnedIndex) == 0)
- {
- msg(playerid, YELLOW, " > You are now spectating: "#C_BLUE"Arena");
- PlayCameraMover(playerid, smo_Data[smo_CurrentArena][smo_Camera], .loop = true);
- smo_Spectating[playerid] = SMO_SPEC_ARENA;
- }
- else
- {
- new randomPlayer = Iter_Random(smo_SpawnedIndex);
- while(randomPlayer == playerid)randomPlayer = Iter_Random(smo_SpawnedIndex);
- msgF(playerid, YELLOW, " > You are now spectating: %P", randomPlayer);
- TogglePlayerSpectating(playerid, true);
- PlayerSpectateVehicle(playerid, GetPlayerVehicleID(randomPlayer));
- smo_Spectating[playerid] = randomPlayer;
- }
- }
- smo_UpdateTextDraw(playerid)
- {
- new str[11];
- format(str, 11, "Falls: %d", smo_TimesFallen[playerid]);
- PlayerTextDrawSetString(playerid, smo_TdText, str);
- PlayerTextDrawShow(playerid, smo_TdBack);
- PlayerTextDrawShow(playerid, smo_TdText);
- }
- smo_Quit(playerid, msg= true)
- {
- gCurrentMinigame[playerid] = MINIGAME_NONE;
- if(smo_Spectating[playerid] != SMO_SPEC_NONE)
- {
- if(smo_Spectating[playerid] == SMO_SPEC_ARENA)ExitCamera(playerid);
- TogglePlayerSpectating(playerid, false);
- SpawnPlayer(playerid);
- }
- stop smo_SpawnTimer[playerid];
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i))continue;
- if(smo_Spectating[i] == playerid && playerid != i)
- {
- smo_Spectate(i);
- }
- }
- Iter_Remove(smo_SpawnedIndex, playerid);
- DestroyVehicle(smo_PlayerVehicleID[playerid]);
- PlayerTextDrawHide(playerid, smo_TdBack);
- PlayerTextDrawHide(playerid, smo_TdText);
- smo_HideLobbyControls(playerid);
- if(msg)msgaF(YELLOW, " > %P"#C_YELLOW" has left the "#C_BLUE"/sumo "#C_YELLOW"minigame.", playerid);
- new count;
- PlayerLoop(i)
- if(gCurrentMinigame[i] == MINIGAME_CARSUMO)count++;
- if(count == 0)for(new i;i<MAX_PLAYERS;i++)
- smo_TimesFallen[i] = 0;
- return 0;
- }
- smo_FormatVehicleList(playerid)
- {
- new
- list[256];
- for(new i;i<sizeof(smo_Vehicles);i++)
- {
- strcat(list, VehicleNames[smo_Vehicles[i]-400]);
- strcat(list, "\n");
- }
- ShowPlayerDialog(playerid, d_SumoList, DIALOG_STYLE_LIST, "Choose a vehicle", list, "Accept", "Cancel");
- }
- script_sumo_DialogResponse(playerid, dialogid, response, listitem)
- {
- if(dialogid == d_SumoList && response)
- {
- smo_PlayerVehicleModel[playerid] = smo_Vehicles[listitem];
- }
- }
- smo_LoadArenas()
- {
- new
- File:idxFile,
- File:dataFile,
- line[128],
- data[128],
- str[42],
- spawnIdx,
- idx;
- if(!fexist(SMO_INDEX_FILE))return print("ERROR: Car-Sumo Arena Index Not Found");
- idxFile = fopen(SMO_INDEX_FILE, io_read);
- while(fread(idxFile, line))
- {
- line[strlen(line)-2] = EOS;
- if(sscanf(line, "p<=>s[32]f", smo_Data[idx][smo_Name], smo_Data[idx][smo_Base]))print("ERROR: Arena Data Corrupted");
- format(str, 42, SMO_DATA_FILE, smo_Data[idx][smo_Name]);
- if(!fexist(str))
- {
- printf("ERROR: Arena data file '%s' not found", str);
- continue;
- }
- dataFile = fopen(str, io_read);
- while(fread(dataFile, data))
- {
- sscanf(data, "p<,>ffff",
- smo_Data[idx][smo_SpawnX][spawnIdx],
- smo_Data[idx][smo_SpawnY][spawnIdx],
- smo_Data[idx][smo_SpawnZ][spawnIdx],
- smo_Data[idx][smo_SpawnR][spawnIdx]);
- spawnIdx++;
- }
- format(str, 42, SMO_CAM_FILE, smo_Data[idx][smo_Name]);
- smo_Data[idx][smo_MaxSpawns] = spawnIdx;
- smo_Data[idx][smo_Camera] = LoadCameraMover(str);
- fclose(dataFile);
- idx++;
- }
- return 1;
- }
- smo_LoadTextDraws(playerid)
- {
- smo_TdBack =CreatePlayerTextDraw(playerid, 19.000000, 309.000000, "____");
- PlayerTextDrawBackgroundColor (playerid, smo_TdBack, 255);
- PlayerTextDrawFont (playerid, smo_TdBack, 1);
- PlayerTextDrawLetterSize (playerid, smo_TdBack, 0.319999, 1.899999);
- PlayerTextDrawColor (playerid, smo_TdBack, -1);
- PlayerTextDrawSetOutline (playerid, smo_TdBack, 0);
- PlayerTextDrawSetProportional (playerid, smo_TdBack, 1);
- PlayerTextDrawSetShadow (playerid, smo_TdBack, 1);
- PlayerTextDrawUseBox (playerid, smo_TdBack, 1);
- PlayerTextDrawBoxColor (playerid, smo_TdBack, 0xFFFFFFFF);
- PlayerTextDrawTextSize (playerid, smo_TdBack, 81.000000, 0.000000);
- smo_TdText =CreatePlayerTextDraw(playerid, 20.000000, 310.000000, "Falls: 0");
- PlayerTextDrawBackgroundColor (playerid, smo_TdText, 255);
- PlayerTextDrawFont (playerid, smo_TdText, 1);
- PlayerTextDrawLetterSize (playerid, smo_TdText, 0.300000, 1.699998);
- PlayerTextDrawColor (playerid, smo_TdText, -1);
- PlayerTextDrawSetOutline (playerid, smo_TdText, 0);
- PlayerTextDrawSetProportional (playerid, smo_TdText, 1);
- PlayerTextDrawSetShadow (playerid, smo_TdText, 1);
- PlayerTextDrawUseBox (playerid, smo_TdText, 1);
- PlayerTextDrawBoxColor (playerid, smo_TdText, 0x000000A0);
- PlayerTextDrawTextSize (playerid, smo_TdText, 80.000000, 0.000000);
- smo_TdVehicle =CreatePlayerTextDraw(playerid, 320.000000, 320.000000, "Change Vehicle");
- PlayerTextDrawAlignment (playerid, smo_TdVehicle, 2);
- PlayerTextDrawBackgroundColor (playerid, smo_TdVehicle, 255);
- PlayerTextDrawFont (playerid, smo_TdVehicle, 1);
- PlayerTextDrawLetterSize (playerid, smo_TdVehicle, 0.400000, 2.000000);
- PlayerTextDrawColor (playerid, smo_TdVehicle, -1);
- PlayerTextDrawSetOutline (playerid, smo_TdVehicle, 0);
- PlayerTextDrawSetProportional (playerid, smo_TdVehicle, 1);
- PlayerTextDrawSetShadow (playerid, smo_TdVehicle, 1);
- PlayerTextDrawUseBox (playerid, smo_TdVehicle, 1);
- PlayerTextDrawBoxColor (playerid, smo_TdVehicle, 100);
- PlayerTextDrawTextSize (playerid, smo_TdVehicle, 18.000000, 110.000000);
- PlayerTextDrawSetSelectable (playerid, smo_TdVehicle, true);
- smo_TdSpawn =CreatePlayerTextDraw(playerid, 320.000000, 344.000000, "5");
- PlayerTextDrawAlignment (playerid, smo_TdSpawn, 2);
- PlayerTextDrawBackgroundColor (playerid, smo_TdSpawn, 255);
- PlayerTextDrawFont (playerid, smo_TdSpawn, 1);
- PlayerTextDrawLetterSize (playerid, smo_TdSpawn, 0.400000, 2.000000);
- PlayerTextDrawColor (playerid, smo_TdSpawn, -1);
- PlayerTextDrawSetOutline (playerid, smo_TdSpawn, 0);
- PlayerTextDrawSetProportional (playerid, smo_TdSpawn, 1);
- PlayerTextDrawSetShadow (playerid, smo_TdSpawn, 1);
- PlayerTextDrawUseBox (playerid, smo_TdSpawn, 1);
- PlayerTextDrawBoxColor (playerid, smo_TdSpawn, 100);
- PlayerTextDrawTextSize (playerid, smo_TdSpawn, 18.000000, 110.000000);
- }
- smo_UnloadTextDraws(playerid)
- {
- PlayerTextDrawDestroy(playerid, smo_TdBack);
- PlayerTextDrawDestroy(playerid, smo_TdText);
- PlayerTextDrawDestroy(playerid, smo_TdVehicle);
- PlayerTextDrawDestroy(playerid, smo_TdSpawn);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement