Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*------------------------------------------------------------------------------
- ********************************
- SUMO - Mini-Game.
- ********************************
- Descrição:
- Um pequeno mini-game de estilo sumo.
- Versão:
- 1.0
- Desenvolvedor:
- Luke "Larceny" G.
- ChangeLOG:
- 05/10/2011:
- Primeiro lançamento.
- Agradecimentos:
- ZeeX - ZCMD Command Processor.
- Y_Less - foreach
- GhostRider - Mapping.
- Equipe SA-MP(past\present\future) - SAMP.
- ------------------------------------------------------------------------------*/
- #define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #tryinclude <foreach>
- new
- g_PLAYERS_TOTAL,
- g_COUNTIN_TIMER,
- g_SPAWNED_VEHICLE[MAX_PLAYERS];
- forward CreateSumoVehicle(playerid);
- forward OnClientUpdate();
- #define IsPlayerInSumo(%0) GetPVarInt(%0,"IsPlayerInSumo")
- #define SetPlayerSumo(%1,%2) SetPVarInt(%1,"IsPlayerInSumo",%2)
- #define GetPlayerSumoTime(%0) GetPVarInt(%0,"PlayerSumoTime")
- #define SetPlayerSumoAFK(%0,%1) SetPVarInt(%0,"SumoAFK",%1)
- #define AddPlayerSumoTime(%0,%1) SetPVarInt(%0,"PlayerSumoTime",GetPVarInt(%0,"PlayerSumoTime")+%1)
- #define SetPlayerSumoTime(%0,%1) SetPVarInt(%0,"PlayerSumoTime",%1)
- stock
- GetPlayerNameEx(playerid)
- {
- new
- string[MAX_PLAYER_NAME];
- GetPlayerName(playerid, string, MAX_PLAYER_NAME);
- return string;
- }
- stock
- CreateVehicleEx(playerid, modelid, Float:X, Float:Y, Float:Z, Float:A, color1, color2)
- {
- if (g_SPAWNED_VEHICLE[playerid] != 0) DestroyVehicle(g_SPAWNED_VEHICLE[playerid]);
- g_SPAWNED_VEHICLE[playerid] = CreateVehicle(modelid, X,Y,Z,A, color1, color2, -1);
- }
- new SUMO_CARS[17][1] =
- {
- {411},
- {541},
- {451},
- {602},
- {429},
- {402},
- {415},
- {587},
- {502},
- {503},
- {559},
- {603},
- {475},
- {506},
- {477},
- {504},
- {558}
- };
- new Float:SUMO_SPAWNS[11][4] =
- {
- {2913.7920,-3130.5566,107.2750,163.2152},
- {2901.9172,-3126.9749,107.2984,191.7273},
- {2888.5759,-3131.6440,107.3228,208.8633},
- {2876.4026,-3138.3540,107.3490,235.2153},
- {2869.5813,-3150.2598,107.3736,264.0153},
- {2869.2766,-3161.9634,107.3946,276.5433},
- {2872.5164,-3174.3484,107.4165,291.9513},
- {2878.2810,-3185.4270,107.4387,321.1833},
- {2887.4141,-3192.7739,107.4608,321.1833},
- {2897.9683,-3196.9666,107.4779,355.0377},
- {2911.6592,-3197.2813,107.5027,355.0377}
- };
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------------------------");
- print(" Iniciando \"SUMO_SCRIPT\" by Luke \"Larceny\" G...");
- print(" ...\"SUMO_SCRIPT\" iniciado com sucesso!");
- print("--------------------------------------------------------\n");
- CreateObject(13607,2905.9548339844,-3160.29296875,104.93536376953,0,0,0,300.0);
- CreateObject(18450,2958.955078125,-3215.8120117188,86.87939453125,359.58288574219,20.072540283203,314.08843994141,300.0);
- CreateObject(13607,3007.0251464844,-3267.2795410156,78.075241088867,0,0,306,300.0);
- CreateObject(1633,2931.97265625,-3195.7143554688,99.627136230469,11.920684814453,0,43.659301757813,300.0);
- CreateObject(1633,2940.1413574219,-3188.4636230469,99.581954956055,11.920166015625,0,43.654174804688,300.0);
- CreateObject(1633,2937.1958007813,-3191.3784179688,99.564033508301,11.920166015625,0,43.654174804688,300.0);
- CreateObject(1633,2934.4245605469,-3193.8444824219,99.583084106445,11.920166015625,0,43.654174804688,300.0);
- CreateObject(3864,2918.455078125,-3195.91796875,107.33255767822,0,0,0,300.0);
- CreateObject(3864,2904.1618652344,-3198.6179199219,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2891.4709472656,-3195.6599121094,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2882.2456054688,-3190.8923339844,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2873.7077636719,-3181.337890625,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2869.1154785156,-3168.7836914063,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2868.744140625,-3155.3662109375,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2871.6098632813,-3144.1569824219,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2879.5402832031,-3132.4753417969,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2893.7329101563,-3124.2341308594,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2908.5739746094,-3122.6245117188,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2923.6279296875,-3127.2817382813,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2936.5686035156,-3137.7502441406,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2941.8908691406,-3148.3449707031,107.49332427979,0,0,0,300.0);
- CreateObject(3864,2944.1440429688,-3162.4973144531,107.5002746582,0,0,0,300.0);
- CreateObject(3864,2940.5539550781,-3177.8244628906,107.49332427979,0,0,0,300.0);
- g_COUNTIN_TIMER = SetTimer("OnClientUpdate", 1000, true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- KillTimer(g_COUNTIN_TIMER);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if (IsPlayerInSumo(playerid))
- {
- new
- SUMO_STRING[58],
- RAND = random(sizeof(SUMO_SPAWNS)),
- RAND_CARS = random(sizeof(SUMO_CARS));
- format(SUMO_STRING, sizeof(SUMO_STRING), "[X]{FFFFFF} %s morreu no ringue.", GetPlayerNameEx(playerid));
- #if defined _foreach_included
- foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #else
- for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #endif
- SetPlayerSumoTime(playerid, 0);
- CreateVehicleEx(playerid, SUMO_CARS[RAND_CARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);
- PutPlayerInVehicle(playerid, g_SPAWNED_VEHICLE[playerid], 0);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if (IsPlayerInSumo(playerid))
- {
- g_PLAYERS_TOTAL--;
- #if defined _foreach_included
- foreach (Player, i)
- #else
- for (new i = 0; i < MAX_PLAYERS; i++)
- #endif
- {
- if (IsPlayerInSumo(i))
- {
- new
- STRING[75];
- format(STRING, sizeof STRING, "[X] {FFFFFF}%s desconectou e foi removido do ringue.", GetPlayerNameEx(playerid));
- SendClientMessage(i, 0x00FF33FF, STRING);
- /* strdel(STRING, 0, 12);
- printf("SUMO_SCRIPT: %s", STRING); */
- }
- }
- }
- return 1;
- }
- public OnClientUpdate()
- {
- #if defined _foreach_included
- foreach (Player, i)
- #else
- for (new i = 0; i < MAX_PLAYERS; i++)
- #endif
- {
- if (IsPlayerInSumo(i))
- {
- if (g_PLAYERS_TOTAL > 0 && GetPVarInt(i,"SumoAFK") < 15){ AddPlayerSumoTime(i, 1); }
- new
- SUMO_TIME[18],
- TEXT_TIME[90],
- Float:pPos[3];
- format(SUMO_TIME, sizeof SUMO_TIME, "%d {FFFFFF}/ 500", GetPlayerSumoTime(i));
- SetPlayerChatBubble(i, SUMO_TIME, 0x00FF33FF, 50.0, 1500);
- format(TEXT_TIME, sizeof TEXT_TIME, "~n~~n~~n~~n~~n~~n~~n~~n~ ~g~~h~~h~%i ~w~/ 500", GetPlayerSumoTime(i));
- GameTextForPlayer(i, TEXT_TIME, 2000, 3);
- GetPlayerPos(i, pPos[0], pPos[1], pPos[2]);
- if (GetPVarFloat(i,"SumoX") != pPos[0] || GetPVarFloat(i,"SumoY") != pPos[1] || GetPVarFloat(i,"SumoZ") != pPos[2])
- {// Caso o jogador ficar ausente
- SetPVarFloat(i, "SumoX", pPos[0]);
- SetPVarFloat(i, "SumoY", pPos[1]);
- SetPVarFloat(i, "SumoZ", pPos[2]);
- SetPVarInt(i, "SumoAFK", 0);
- }
- else
- {
- SetPVarInt(i, "SumoAFK", GetPVarInt(i,"SumoAFK")+1);
- if (GetPVarInt(i,"SumoAFK") == 15)
- {
- new
- SUMO_STRING[73];
- format(SUMO_STRING, sizeof(SUMO_STRING), "[X]{FFFFFF} %s está ausente e não ganhará pontos.", GetPlayerNameEx(i));
- #if defined _foreach_included
- foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #else
- for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #endif
- }
- }
- new
- Float:Saude;
- GetPlayerHealth(i, Saude);
- if (Saude < 1)
- {// Caso o jogador morrer
- return 1;
- }
- if (pPos[2] < 25.0)
- {// Caso o jogador cair do ringue
- new
- SUMO_STRING[55],
- RAND = random(sizeof(SUMO_SPAWNS)),
- RANDCARS = random(sizeof(SUMO_CARS));
- format(SUMO_STRING, sizeof(SUMO_STRING), "[X]{FFFFFF} %s caiu do ringue.", GetPlayerNameEx(i));
- #if defined _foreach_included
- foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #else
- for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #endif
- SetPlayerSumoTime(i, 0);
- CreateVehicleEx(i, SUMO_CARS[RANDCARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);
- PutPlayerInVehicle(i, g_SPAWNED_VEHICLE[i], 0);
- return 1;
- }
- if (GetPlayerState(i) != PLAYER_STATE_DRIVER && !GetPVarInt(i, "FirstSumo"))
- {// Caso o jogador sair do carro
- new
- SUMO_STRING[53],
- RAND = random(sizeof(SUMO_SPAWNS)),
- RANDCARS = random(sizeof(SUMO_CARS));
- format(SUMO_STRING, sizeof(SUMO_STRING), "[X]{FFFFFF} %s saiu do carro.", GetPlayerNameEx(i));
- #if defined _foreach_included
- foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #else
- for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #endif
- SetPlayerSumoTime(i, 0);
- CreateVehicleEx(i, SUMO_CARS[RANDCARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);
- PutPlayerInVehicle(i, g_SPAWNED_VEHICLE[i], 0);
- return 1;
- }
- if (GetPlayerSumoTime(i) == 399)
- {// Caso o jogador obter 400segundos sem cair
- new
- SUMO_STRING[70];
- format(SUMO_STRING, sizeof SUMO_STRING, "[X]{FFFFFF} %s está quase vencendo, derrube-o!", GetPlayerNameEx(i));
- #if defined _foreach_included
- foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS) && OTHERS != i){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #else
- for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS) && OTHERS != i){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
- #endif
- SendClientMessage(i, 0x00FF33FF, "[X]{FFFFFF} Você está quase vencendo!");
- }
- if (GetPlayerSumoTime(i) == 499)
- {// Caso o jogador obter 500segundos sem cair
- SendClientMessage(i, 0x00FF33FF, "[X]{FFFFFF} Você venceu o jogo e ganhou $6000!");
- GivePlayerMoney(i, 6000);
- new
- SUMO_STRING[60];
- format(SUMO_STRING, sizeof SUMO_STRING, "[X]{FFFFFF} %s é o vencedor do sumo.", GetPlayerNameEx(i));
- #if defined _foreach_included
- foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING); SetPlayerSumoTime(OTHERS, 0);}}
- #else
- for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING); SetPlayerSumoTime(OTHERS, 0);}}
- #endif
- }
- }
- }
- return 1;
- }
- public CreateSumoVehicle(playerid)
- {
- new
- RAND = random(sizeof(SUMO_SPAWNS)),
- RANDCARS = random(sizeof(SUMO_CARS));
- CreateVehicleEx(playerid, SUMO_CARS[RANDCARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);
- PutPlayerInVehicle(playerid, g_SPAWNED_VEHICLE[playerid], 0);
- if (GetPVarInt(playerid, "FirstSumo")) DeletePVar(playerid, "FirstSumo");
- }
- CMD:sumo( playerid, params[] )
- {
- if (IsPlayerInSumo(playerid))
- {
- SetPlayerSumo(playerid, 0);
- SetPlayerSumoTime(playerid, 0);
- g_PLAYERS_TOTAL--;
- SendClientMessage(playerid, 0x00FF33FF, "[X]{FFFFFF} Você saiu do jogo: \"{00FF33}Sumo{FFFFFF}\"");
- SetPlayerPos(playerid, 1642.3619, -2333.0234, 13.5469);
- SetPlayerFacingAngle(playerid, 356.8151);
- SetCameraBehindPlayer(playerid);
- DestroyVehicle(g_SPAWNED_VEHICLE[playerid]);
- }
- else
- {
- g_PLAYERS_TOTAL++;
- SetPlayerPos(playerid, 2924.0842,-3189.0569,102.2883);
- SetPlayerFacingAngle(playerid, 174.5274);
- SetTimerEx("CreateSumoVehicle", 1200, false, "i", playerid);
- SetPlayerInterior(playerid, 0);
- SetPlayerVirtualWorld(playerid, 0);
- SendClientMessage(playerid, 0x00FF33FF, "[X]{FFFFFF} Você agora está jogando: \"{00FF33}Sumo{FFFFFF}\"");
- SetPlayerSumo(playerid, 1);
- SetPVarInt(playerid, "FirstSumo", 1);
- }
- return 1;
- }
- CMD:sumotime( playerid, params[] )
- {
- if (!IsPlayerInSumo(playerid))
- return SendClientMessage(playerid, 0x00FF33FF, "[X]{FFFFFF} Você não está no ringue.");
- new
- e_STRING[61];
- format(e_STRING, sizeof e_STRING, "[X]{FFFFFF} Seu tempo no sumo é de {00FF33}%d{FFFFFF}/500.", GetPlayerSumoTime(playerid));
- SendClientMessage(playerid, 0x00FF33FF, e_STRING);
- return 1;
- }
- CMD:sumoplayers( playerid, params[] )
- {
- new
- e_STRING[70];
- format(e_STRING, sizeof e_STRING, "[X]{FFFFFF} Jogadores atualmente no sumo {00FF33}%d{FFFFFF}/%i.", g_PLAYERS_TOTAL, GetMaxPlayers());
- SendClientMessage(playerid, 0x00FF33FF, e_STRING);
- return 1;
- }
- CMD:ajudasumo( playerid, params[] )
- return SendClientMessage(playerid, 0x00FF33FF, "[X]{FFFFFF} /sumo - /sumotime - /sumoplayers");
Add Comment
Please, Sign In to add comment