Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <sscanf2>
- //
- // Natives
- //
- #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- native sscanf(const data[], const format[], {Float,_}:...);
- //
- // Colors
- //
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_BLACK 0x000000AA
- #define COLOR_RED 0xFF0000AA
- #define COLOR_LIGHTRED 0xF95D5DAA
- #define COLOR_DARKRED 0x6F0000AA
- #define COLOR_GREEN 0x15FF00AA
- #define COLOR_LIGHTGREEN 0x78FF6CAA
- #define COLOR_DARKGREEN 0x0C9000AA
- #define COLOR_YELLOW 0xF2FF00AA
- #define COLOR_DARKYELLOW 0x727800AA
- #define COLOR_LIGHTYELLOW 0xF9FF88AA
- #define COLOR_BROWN 0x504124AA
- #define COLOR_LIGHTBROWN 0xE2B35CAA
- #define COLOR_DARKBROWN 0x392501AA
- #define COLOR_BLUE 0x0015FFAA
- #define COLOR_LIGHTBLUE 0x515BC7AA
- #define COLOR_DARKBLUE 0x000A7AAA
- #define COLOR_VERYDARKBLUE 0x010534AA
- #define COLOR_PINK 0xFD01FDAA
- #define COLOR_PURLPLE 0x690069AA
- #define COLOR_DARKPURPLE 0x3B013BAA
- #define COLOR_VERYDARKBLUE 0x010534AA
- #define COLOR_NAVY 0x00FBFFAA
- #define COLOR_DARKNAVY 0x006566AA
- #define COLOR_LIGHTNAVY 0x8FFDFFAA
- #define COLOR_ORANGE 0xFFAF02AA
- #define COLOR_DARKORANGE 0x946E1DAA
- #define COLOR_LIGHTORANGE 0xFECA5BAA
- #define COLOR_SKYBLUE 0x2685B4AA
- #define COLOR_GREY 0x757373AA
- #define COLOR_LIGHTGREY 0xBBBBBBAA
- #define COLOR_DARKGREY 0x4C4A4AAA
- #define COLOR_VERYDARKGREY 0x2A2A2AAA
- //
- // Cars
- //
- #define MAX_RANDOM_VEHICLES 144
- new AllCars[MAX_RANDOM_VEHICLES] = {
- 445,602,416,485,568,429,433,499,424,536,496,
- 504,422,609,498,401,575,518,402,541,482,431,
- 438,457,527,483,524,415,542,589,437,532,480,
- 596,599,597,598,578,486,507,562,585,427,419,
- 587,490,528,533,544,407,565,455,530,526,466,
- 604,492,474,588,434,502,503,494,579,545,411,
- 546,559,508,571,400,403,517,410,551,500,418,
- 572,423,414,516,582,467,443,470,404,514,603,
- 600,413,426,436,547,489,515,479,
- 534,505,442,440,475,543,605,495,567,428,
- 405,535,458,580,439,561,409,560,550,506,
- 574,566,549,420,459,576,525,531,406,583,451,
- 558,552,540,491,412,478,421,529,555,456,554,
- 477,406,556,444,573,539
- };
- //
- // Forwards
- //
- forward KickReason(playerid, admin[], reason[]);
- forward BanReason(playerid, admin[], reason[]);
- forward LoadMap(mapname[]);
- forward DestroyMap();
- forward RandomMap();
- forward ClearChat(playerid);
- forward SpawnSpawnPlayer(playerid);
- forward CountdownPlayer(playerid, time);
- forward PlayerKill(playerid);
- forward LoadPlayer(playerid);
- forward LoadMaps();
- forward GetDriverFromVehicle(vehicleid);
- forward PlayerDied(playerid, bool:respawn);
- forward ActivatePlayer(playerid);
- forward KillVehicle(vehicleid);
- forward UpdateScore();
- forward GetPlayerPlace(playerid);
- forward ResetPlayers();
- forward SpawnPlayers();
- forward CheckAFK();
- forward CheckOnFoot();
- forward CheckPings();
- forward ShowPlay(playerid);
- forward KillTimers(playerid);
- forward AdminMessage(message[]);
- forward UpdateTime();
- forward CrashServer();
- forward ClearChatForAll();
- //
- // Variables
- //
- enum COORD_INFO {
- Float:COORD_X,
- Float:COORD_Y,
- Float:COORD_Z
- };
- enum SPAWN_INFO {
- Float:SPAWN_X,
- Float:SPAWN_Y,
- Float:SPAWN_Z,
- Float:SPAWN_ROT
- };
- new mapName[32];
- new mapFile[32];
- new mapAuthor[32];
- new mapVersion[12];
- new mapTreshold = 0;
- new mapWintime = 300;
- new mapCamera[COORD_INFO];
- new mapCameraLookAt[COORD_INFO];
- new mapObjects[MAX_OBJECTS];
- new mapObjectsCounter = 0;
- new playerVehicle[MAX_PLAYERS];
- new playerOldVehicle[MAX_PLAYERS];
- new playerTime[MAX_PLAYERS];
- new playerName[MAX_PLAYERS][24];
- new playerSpawns[100][SPAWN_INFO];
- new playerSpawnsCounter = 0;
- new playerFirst[MAX_PLAYERS];
- new playerSpectating[MAX_PLAYERS];
- new playerActive[MAX_PLAYERS];
- new playerLevel[MAX_PLAYERS];
- new playerActiveTimer[MAX_PLAYERS];
- new playerCountdown[MAX_PLAYERS];
- new playerInCountdown[MAX_PLAYERS];
- new playerIsPaused[MAX_PLAYERS];
- new Text:playerBar[MAX_PLAYERS];
- new Text:bar;
- new string[128];
- new playerAFK[MAX_PLAYERS];
- new playerUpdated[MAX_PLAYERS];
- new playerShowPlay[MAX_PLAYERS];
- new playerFastSpawn[MAX_PLAYERS];
- new playerExiting[MAX_PLAYERS];
- new playerAirbreak[MAX_PLAYERS];
- new Float:playerVelocity[MAX_PLAYERS][3];
- new Float:playerOldVelocity[MAX_PLAYERS][3];
- new playerVelocityTicks[MAX_PLAYERS];
- new Float:playerVehicleHealth[MAX_PLAYERS];
- new playerCheatTreshold[MAX_PLAYERS];
- new vehicleKill[MAX_PLAYERS];
- new playerPingWarnings[MAX_PLAYERS];
- new playerSpectate[MAX_PLAYERS];
- new playerSpectated[MAX_PLAYERS];
- new playerInstantSpawn[MAX_PLAYERS];
- new playerReply[MAX_PLAYERS];
- new playerForceCar[MAX_PLAYERS];
- new playerTicks[MAX_PLAYERS];
- //
- // Main settings
- //
- main()
- {
- print("----------------------------------");
- print(" sumoFFS v1.0 loaded");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- SetGameModeText("sumoFFSSS v12.0");
- EnableStuntBonusForAll(0);
- AddPlayerClass(264, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0);
- DisableNameTagLOS();
- SetNameTagDrawDistance(400);
- // Banner
- bar = TextDrawCreate(1.000000,428.000000,"__");
- TextDrawUseBox(bar,1);
- TextDrawBoxColor(bar,0x00000066);
- TextDrawTextSize(bar,662.000000,44.000000);
- TextDrawAlignment(bar,0);
- TextDrawBackgroundColor(bar,0x000000ff);
- TextDrawFont(bar,3);
- TextDrawLetterSize(bar,1.000000,2.399999);
- TextDrawColor(bar,0xffffffff);
- TextDrawSetOutline(bar,1);
- TextDrawSetProportional(bar,1);
- TextDrawSetShadow(bar,1);
- // Pick random map
- RandomMap();
- // Time
- SetTimer("UpdateTime", 1000, true);
- // Score timer
- SetTimer("UpdateScore", 250, true);
- // AFK timer
- SetTimer("CheckAFK", 2000, true);
- // On foot
- SetTimer("CheckOnFoot", 500, true);
- // Pings
- SetTimer("CheckPings", 1000, true);
- return 1;
- }
- //
- // Admin handling
- //
- public KickReason(playerid, admin[], reason[]){
- format(string, sizeof(string), "%s has been kicked by %s (Reason: %s)", playerName[playerid], admin, reason);
- SendClientMessageToAll(COLOR_PINK, string);
- print(string);
- return Kick(playerid);
- }
- public BanReason(playerid, admin[], reason[]){
- format(string, sizeof(string), "%s has been banned by %s (Reason: %s)", playerName[playerid], admin, reason);
- SendClientMessageToAll(COLOR_PINK, string);
- print(string);
- return Ban(playerid);
- }
- public ClearChat(playerid){
- for(new i = 0; i < 100; i++){
- SendClientMessage(playerid, COLOR_WHITE, "\n");
- }
- return 1;
- }
- //
- // Map handling
- //
- public LoadMap(mapname[]){
- new path[64], line[128];
- format(path, sizeof(path), "/maps/%s.ini", mapname);
- if(!fexist(path)){
- format(string, sizeof(string), "Unable to locate map %s!", mapname);
- SendClientMessageToAll(COLOR_ORANGE, string);
- RandomMap();
- } else {
- new letter[1], model = 0, Float:rot, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, File:map = fopen(path, io_read);
- DestroyMap();
- format(mapFile, sizeof(mapFile), "%s", mapname);
- mapTreshold = 0;
- mapWintime = 0;
- while(fread(map, line)){
- if(strcmp(line, "A", false, 1) == 0){
- sscanf(line, "s[1]s[32]", letter, mapAuthor);
- }
- if(strcmp(line, "V", false, 1) == 0){
- sscanf(line, "s[1]s[12]", letter, mapVersion);
- }
- if(strcmp(line, "N", false, 1) == 0){
- sscanf(line, "s[1]s[32]", letter, mapName);
- }
- if(strcmp(line, "T", false, 1) == 0){
- sscanf(line, "s[1]d", letter, mapTreshold);
- }
- if(strcmp(line, "W", false, 1) == 0){
- sscanf(line, "s[4]d", letter, mapWintime);
- }
- if(strcmp(line, "C", false, 1) == 0){
- if (!sscanf(line, "s[1]fff", letter, X, Y, Z)){
- mapCamera[COORD_X] = X;
- mapCamera[COORD_Y] = Y;
- mapCamera[COORD_Z] = Z;
- } else {
- printf("***** Invalid line for C at '%s' - %s", mapname, line);
- }
- }
- if(strcmp(line, "L", false, 1) == 0){
- if (!sscanf(line, "s[1]fff", letter, X, Y, Z)){
- mapCameraLookAt[COORD_X] = X;
- mapCameraLookAt[COORD_Y] = Y;
- mapCameraLookAt[COORD_Z] = Z;
- } else {
- printf("***** Invalid line for C at '%s' - %s", mapname, line);
- }
- }
- if(strcmp(line, "O", false, 1) == 0){
- if (!sscanf(line, "s[1]dffffff", letter, model, X, Y, Z, rX, rY, rZ)){
- mapObjects[mapObjectsCounter] = CreateObject(model, X, Y, Z, rX, rY, rZ);
- mapObjectsCounter++;
- } else {
- printf("***** Invalid line for O at '%s' - %s", mapname, line);
- }
- }
- if(strcmp(line, "S", false, 1) == 0){
- if (!sscanf(line, "s[1]ffff", letter, X, Y, Z, rot)){
- playerSpawns[playerSpawnsCounter][SPAWN_X] = X;
- playerSpawns[playerSpawnsCounter][SPAWN_Y] = Y;
- playerSpawns[playerSpawnsCounter][SPAWN_Z] = Z;
- playerSpawns[playerSpawnsCounter][SPAWN_ROT] = rot;
- playerSpawnsCounter++;
- } else {
- printf("***** Invalid line for S at '%s' - %s", mapname, line);
- }
- }
- }
- if(mapWintime == 0) mapWintime = 300;
- if(mapObjectsCounter == 0 || playerSpawnsCounter == 0){
- format(string, sizeof(string), "Unable to load map %s!", mapname);
- SendClientMessageToAll(COLOR_ORANGE, string);
- RandomMap();
- }
- }
- }
- public RandomMap(){
- new maps[50][32], mapCounter = 0, line[32], File:map = fopen("maps.ini", io_read);
- while(fread(map, line)){
- format(maps[mapCounter], 32, "%s", trim(line));
- mapCounter++;
- }
- new random_map = random(mapCounter - 1);
- LoadMap(maps[random_map]);
- return 1;
- }
- public DestroyMap(){
- if(mapObjectsCounter > 0){
- for(new i = 0; i < mapObjectsCounter; i++){
- new id = mapObjects[i];
- DestroyObject(id);
- }
- }
- mapObjectsCounter = 0;
- playerSpawnsCounter = 0;
- return 1;
- }
- //
- // Player handling
- //
- public SpawnSpawnPlayer(playerid){
- playerSpectating[playerid] = 0;
- SpawnPlayer(playerid);
- }
- public ActivatePlayer(playerid){
- SetPlayerHealth(playerid, 100);
- SetPlayerArmour(playerid, 0);
- ResetPlayerWeapons(playerid);
- playerVehicleHealth[playerid] = 990.0;
- SetVehicleHealth(GetPlayerVehicleID(playerid), 990.0);
- }
- public LoadPlayer(playerid){
- new rand = random(playerSpawnsCounter - 1);
- new Float:info[4];
- new rand_car = random(MAX_RANDOM_VEHICLES - 1);
- new car = AllCars[rand_car];
- info[0] = playerSpawns[rand][SPAWN_X];
- info[1] = playerSpawns[rand][SPAWN_Y];
- info[2] = playerSpawns[rand][SPAWN_Z];
- info[3] = playerSpawns[rand][SPAWN_ROT];
- if(GetPlayerState(playerid) == 9){
- playerSpectating[playerid] = 1;
- TogglePlayerSpectating(playerid, 0);
- } else {
- playerSpectating[playerid] = 0;
- }
- // Reset health
- SetPlayerHealth(playerid, 100);
- SetPlayerArmour(playerid, 0);
- ResetPlayerWeapons(playerid);
- // Spawn car
- if(playerForceCar[playerid] != -1){
- car = playerForceCar[playerid];
- }
- playerVehicle[playerid] = CreateVehicle(car, info[0], info[1], info[2], info[3], random(100), random(100), 5);
- playerVehicleHealth[playerid] = 990.0;
- SetVehicleHealth(playerVehicle[playerid], 990.0);
- PutPlayerInVehicle(playerid, playerVehicle[playerid], 0);
- // Reset variables
- playerAirbreak[playerid] = 0;
- playerTime[playerid] = 0;
- playerActive[playerid] = 1;
- playerExiting[playerid] = 0;
- playerShowPlay[playerid] = 0;
- playerVelocity[playerid][0] = 0;
- playerVelocity[playerid][1] = 0;
- playerVelocity[playerid][2] = 0;
- playerOldVelocity[playerid][0] = 0;
- playerOldVelocity[playerid][1] = 0;
- playerOldVelocity[playerid][2] = 0;
- playerCheatTreshold[playerid] = 0;
- // Is he being spectated?
- if(IsPlayerConnected(playerSpectated[playerid])){
- PlayerSpectateVehicle(playerSpectated[playerid], playerVehicle[playerid]);
- }
- // Go!
- GameTextForPlayer(playerid, "~g~GO!", 1500, 4);
- playerActiveTimer[playerid] = SetTimerEx("ActivatePlayer", 1500, false, "d", playerid);
- return 1;
- }
- public PlayerDied(playerid, bool:respawn){
- playerActive[playerid] = 0;
- playerTime[playerid] = 0;
- playerVehicle[playerid] = -1;
- SetPlayerColor(playerid, COLOR_WHITE);
- KillTimers(playerid);
- if(respawn == true){
- SpawnPlayer(playerid);
- }
- // Is he being spectated?
- if(IsPlayerConnected(playerSpectated[playerid])){
- SendClientMessage(playerSpectated[playerid], COLOR_ORANGE, "Your camera will be corrected as soon as the player respawns.");
- }
- return 1;
- }
- public CheckPings(){
- for(new i = 0; i < MAX_PLAYERS; i++){
- if(IsPlayerConnected(i) && playerActive[i] == 1 && playerTime[i] > 3){
- new ping = GetPlayerPing(i);
- if(ping > 500){
- playerPingWarnings[i]++;
- if(playerPingWarnings[i] == 5){
- SendClientMessage(i, COLOR_RED, "Your ping is too high (above 500). Please solve this or you will get kicked.");
- }
- if(playerPingWarnings[i] > 10){
- KickReason(i, "Server", "Ping too high (above 500).");
- }
- } else {
- playerPingWarnings[i] = 0;
- }
- }
- }
- }
- public CheckOnFoot(){
- for(new i = 0; i < MAX_PLAYERS; i++){
- if(IsPlayerConnected(i) && playerActive[i] == 1 && playerTime[i] > 3){
- if(!IsPlayerInAnyVehicle(i)){
- DestroyVehicle(playerVehicle[i]);
- playerVehicle[i] = -1;
- PlayerDied(i, true);
- }
- }
- }
- }
- public CountdownPlayer(playerid, time){
- playerShowPlay[playerid] = 0;
- playerActive[playerid] = 0;
- playerInCountdown[playerid] = 1;
- if(time < 1){
- playerInCountdown[playerid] = 0;
- playerCountdown[playerid] = -1;
- LoadPlayer(playerid);
- } else {
- if(time == 1){
- format(string, sizeof(string), "~w~Spawning in ~r~%d second", time);
- } else {
- format(string, sizeof(string), "~w~Spawning in ~r~%d seconds", time);
- }
- GameTextForPlayer(playerid, string, 1500, 4);
- if(GetPlayerState(playerid) != 9){
- TogglePlayerSpectating(playerid, 1);
- }
- if(time == 3 || time == 6 || time == 9){
- new Float:info[3], rand = random(playerSpawnsCounter - 1);
- info[0] = playerSpawns[rand][SPAWN_X];
- info[1] = playerSpawns[rand][SPAWN_Y];
- info[2] = playerSpawns[rand][SPAWN_Z];
- SetPlayerCameraLookAt(playerid, info[0], info[1], info[2]);
- }
- playerCountdown[playerid] = SetTimerEx("CountdownPlayer", 1000, false, "dd", playerid, time - 1);
- }
- }
- public GetDriverFromVehicle(vehicleid){
- for(new i = 0; i < MAX_PLAYERS; i++){
- if(playerVehicle[i] == vehicleid){
- return i;
- }
- }
- return -1;
- }
- public ResetPlayers(){
- for(new i = 0; i < MAX_PLAYERS; i++){
- playerActive[i] = 0;
- playerTime[i] = 0;
- KillTimers(i);
- SetPlayerColor(i, COLOR_WHITE);
- DestroyVehicle(GetPlayerVehicleID(i));
- playerVehicle[i] = -1;
- playerSpectate[i] = -1;
- playerSpectated[i] = -1;
- if(GetPlayerState(i) != 9){
- playerFastSpawn[i] = 1;
- TogglePlayerSpectating(i, 1);
- }
- }
- }
- public SpawnPlayers(){
- for(new i = 0; i < MAX_PLAYERS; i++){
- if(GetPlayerState(i) == 9){
- playerFastSpawn[i] = 1;
- TogglePlayerSpectating(i, 0);
- }
- }
- }
- public ShowPlay(playerid){
- if(playerShowPlay[playerid] == 1){
- GameTextForPlayer(playerid, "~w~Use ~r~/play~w~ to play", 1200, 4);
- SetTimerEx("ShowPlay", 1000, false, "d", playerid);
- }
- }
- public AdminMessage(message[]){
- for(new i = 0; i < MAX_PLAYERS; i++){
- if(IsPlayerConnected(i) && playerLevel[i] > 1){
- SendClientMessage(i, COLOR_DARKGREEN, message);
- }
- }
- }
- //
- // AFK handling
- //
- public CheckAFK(){
- for(new i = 0; i < MAX_PLAYERS; i++){
- if(IsPlayerConnected(i)){
- if(playerActive[i] == 1){
- if(playerAFK[i] == 1){
- if(playerUpdated[i] == 0){
- format(string, sizeof(string), "%s has been removed from the game due to being paused.", playerName[i]);
- SendClientMessageToAll(COLOR_PINK, string);
- playerActive[i] = 0;
- playerTime[i] = 0;
- playerIsPaused[i] = 1;
- KillTimers(i);
- SetPlayerVirtualWorld(i, 1337);
- SetPlayerColor(i, COLOR_WHITE);
- DestroyVehicle(GetPlayerVehicleID(i));
- playerVehicle[i] = -1;
- playerShowPlay[i] = 1;
- GameTextForPlayer(i, "~w~Use ~r~/play~w~ to play", 1200, 4);
- SetTimerEx("ShowPlay", 1000, false, "d", i);
- TogglePlayerSpectating(i, 1);
- } else {
- playerAFK[i] = 0;
- }
- } else {
- if(playerUpdated[i] == 0){
- playerAFK[i] = 1;
- }
- }
- playerUpdated[i] = 0;
- }
- }
- }
- }
- public UpdateTime() {
- new Hour, Min;
- for(new i = 0; i < MAX_PLAYERS; i++){
- if(IsPlayerConnected(i)){
- if(playerActive[i] == 1){
- playerTime[i]++;
- }
- gettime(Hour, Min);
- format(string, sizeof(string), "%02d:%02d", Hour, Min);
- SetPlayerTime(i, Hour, Min);
- }
- }
- }
- public ClearChatForAll(){
- for(new i = 0; i < MAX_PLAYERS; i++){
- if(IsPlayerConnected(i)){
- ClearChat(i);
- }
- }
- }
- public CrashServer(){
- new File:example = fopen("non/existant/path/foo.txt", io_write);
- fwrite(example, "moo");
- fclose(example);
- }
- public UpdateScore() {
- new barText[255];
- for(new i = 0; i < MAX_PLAYERS; i++){
- if(IsPlayerConnected(i)){
- SetPlayerScore(i, playerTime[i]);
- if(playerTime[i] > mapWintime){
- SetPlayerScore(i, playerTime[i]);
- ResetPlayers();
- SetTimer("RandomMap", 5000, false);
- SetTimer("SpawnPlayers", 5000, false);
- format(string, sizeof(string), "~r~%s~w~ has won!", playerName[i]);
- GameTextForAll(string, 5000, 4);
- } else {
- new timeLeft = mapWintime - playerTime[i];
- if(timeLeft <= 60){
- if(timeLeft == 60){
- format(string, sizeof(string), "~r~%s~w~ will win in ~n~~n~~y~60 seconds!", playerName[i]);
- GameTextForAll(string, 3000, 4);
- }
- SetPlayerColor(i, COLOR_RED);
- } else if(timeLeft < 120){
- SetPlayerColor(i, COLOR_YELLOW);
- } else {
- SetPlayerColor(i, COLOR_WHITE);
- }
- }
- if(playerActive[i] == 1){
- new place = GetPlayerPlace(i), Float:health;
- GetVehicleHealth(GetPlayerVehicleID(i), health);
- new Float:percentage = (health - 240) / 750 * 100;
- if(playerTime[i] == 1){
- format(barText, sizeof(barText), "~>~ ~r~Laikas: ~g~%d sekundes ~<~~>~ ~r~Vieta: ~g~%d%s ~<~~>~ ~r~Bukle: ~g~%d%% ~<~~>~ ~r~Zemelapis: ~g~%s ~<~", playerTime[i], place, GetSuffix(place), floatround(percentage, floatround_ceil), trim(mapName));
- } else {
- format(barText, sizeof(barText), "~>~ ~r~Laikas: ~g~%d sekundes ~<~~>~ ~r~Vieta: ~g~%d%s ~<~~>~ ~r~Bukle: ~g~%d%% ~<~~>~ ~r~Zemelapis: ~g~%s ~<~", playerTime[i], place, GetSuffix(place), floatround(percentage, floatround_ceil), trim(mapName));
- }
- } else {
- format(barText, sizeof(barText), "~>~ ~r~Laikas: ~g~n/a ~<~~>~ ~r~Vieta: ~g~n/a ~<~~>~ ~r~Bukle: ~g~n/a ~<~~>~ ~r~Zemelapis: ~g~%s ~<~", trim(mapName));
- }
- TextDrawSetString(playerBar[i], barText);
- }
- }
- }
- //
- // Commands
- //
- dcmd_map(playerid, params[]){
- #pragma unused params
- format(string, sizeof(string), "You are playing on '%s' (version %s) made by %s", trim(mapName), trim(mapVersion), trim(mapAuthor));
- SendClientMessage(playerid, COLOR_ORANGE, string);
- format(string, sizeof(string), "The map has %d objects and %d spawns", mapObjectsCounter, playerSpawnsCounter);
- SendClientMessage(playerid, COLOR_ORANGE, string);
- format(string, sizeof(string), "The threshold for falling off is %d meter and you win after %d seconds", mapTreshold, mapWintime);
- SendClientMessage(playerid, COLOR_ORANGE, string);
- }
- dcmd_reset(playerid, params[]){
- #pragma unused params
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else {
- SendClientMessageToAll(COLOR_ORANGE, "Resetting all players...");
- ResetPlayers();
- SetTimer("SpawnPlayers", 500, false);
- }
- }
- dcmd_loadmap(playerid, params[]){
- new mapname[128];
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else if (sscanf(params, "s[128]", mapname)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /loadmap <mapname>");
- } else {
- new path[64];
- format(path, sizeof(path), "/maps/%s.ini", mapname);
- if(!fexist(path)){
- SendClientMessage(playerid, COLOR_RED, "That map could not be found..");
- } else {
- format(string, sizeof(string), "Loading map %s...", mapname);
- SendClientMessageToAll(COLOR_ORANGE, string);
- ResetPlayers();
- LoadMap(mapname);
- SetTimer("SpawnPlayers", 500, false);
- }
- }
- }
- dcmd_kick(playerid, params[]){
- new target, reason[128];
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else if (sscanf(params, "us[128]", target, reason)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /kick <player> <reason>");
- } else {
- KickReason(target, playerName[playerid], reason);
- }
- }
- dcmd_ban(playerid, params[]){
- new target, reason[128];
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else if (sscanf(params, "us[128]", target, reason)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /ban <player> <reason>");
- } else {
- BanReason(target, playerName[playerid], reason);
- }
- }
- dcmd_randommap(playerid, params[]){
- #pragma unused params
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else {
- SendClientMessageToAll(COLOR_ORANGE, "Loading random map...");
- ResetPlayers();
- RandomMap();
- SetTimer("SpawnPlayers", 500, false);
- }
- }
- dcmd_reloadmap(playerid, params[]){
- #pragma unused params
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else {
- SendClientMessageToAll(COLOR_ORANGE, "Reloading map...");
- ResetPlayers();
- DestroyMap();
- LoadMap(mapFile);
- SetTimer("SpawnPlayers", 500, false);
- }
- }
- dcmd_restart(playerid, params[]){
- #pragma unused params
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else {
- for(new i = 0; i < MAX_PLAYERS; i++){
- playerShowPlay[i] = 0;
- KillTimers(i);
- ClearChat(i);
- TextDrawHideForPlayer(i, bar);
- TextDrawHideForPlayer(i, playerBar[i]);
- }
- SetTimer("ClearChatForAll", 100, true);
- GameTextForAll("~w~Restarting~n~~n~~r~Please wait...", 10000000000000, 4);
- // Make it crash
- SetTimer("CrashServer", 2000, false);
- }
- }
- dcmd_spectate(playerid, params[]){
- #pragma unused params
- SendClientMessage(playerid, COLOR_ORANGE, "You are now spectating, use /play to start playing again.");
- playerActive[playerid] = 0;
- playerTime[playerid] = 0;
- KillTimers(playerid);
- SetPlayerColor(playerid, COLOR_WHITE);
- DestroyVehicle(GetPlayerVehicleID(playerid));
- playerVehicle[playerid] = -1;
- GameTextForPlayer(playerid, "~w~Use ~r~/play~w~ to play", 10000000000000, 4);
- if(GetPlayerState(playerid) != 9){
- TogglePlayerSpectating(playerid, 1);
- }
- }
- dcmd_play(playerid, params[]){
- #pragma unused params
- if(playerActive[playerid] == 0 && playerInCountdown[playerid] == 0){
- playerShowPlay[playerid] = 0;
- playerSpectating[playerid] = 0;
- if(playerSpectate[playerid] != -1){
- playerInstantSpawn[playerid] = 1;
- playerSpectated[playerSpectate[playerid]] = -1;
- playerSpectate[playerid] = -1;
- } else {
- playerInstantSpawn[playerid] = 0;
- }
- if(GetPlayerState(playerid) == 9){
- TogglePlayerSpectating(playerid, 0);
- }
- }
- }
- dcmd_drunk(playerid, params[]){
- new target, drunkness;
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else if (sscanf(params, "ud", target, drunkness)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /drunk <player> <amount>");
- } else {
- SendClientMessage(playerid, COLOR_ORANGE, "The drunkness has been applied (< 2000 has no effect, 50,000 is the maximum.)");
- SetPlayerDrunkLevel (target, drunkness);
- }
- }
- dcmd_respawn(playerid, params[]){
- new target;
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else if (sscanf(params, "u", target)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /respawn <player>");
- } else {
- SendClientMessage(playerid, COLOR_ORANGE, "The player has been forced to respawn.");
- DestroyVehicle(GetPlayerVehicleID(target));
- playerVehicle[target] = -1;
- PlayerDied(target, true);
- }
- }
- dcmd_kill(playerid, params[]){
- #pragma unused params
- if(playerActive[playerid] == 1){
- format(string, sizeof(string), "%s suicided after %d seconds.", playerName[playerid], playerTime[playerid]);
- SendClientMessageToAll(COLOR_YELLOW, string);
- DestroyVehicle(GetPlayerVehicleID(playerid));
- playerVehicle[playerid] = -1;
- PlayerDied(playerid, true);
- }
- }
- dcmd_pm(playerid, params[]){
- new target, message[128];
- if (sscanf(params, "us[128]", target, message)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /pm <player> <message>");
- } else if(strlen(message) > 75){
- SendClientMessage(playerid, COLOR_RED, "Your message is too long.");
- } else {
- format(string, sizeof(string), "PM sent to %s: %s", playerName[target], message);
- SendClientMessage(playerid, COLOR_ORANGE, string);
- format(string, sizeof(string), "PM from %s (use /r to respond): %s", playerName[playerid], message);
- SendClientMessage(target, COLOR_ORANGE, string);
- playerReply[target] = playerid;
- }
- }
- dcmd_r(playerid, params[]){
- new message[128], target = playerReply[playerid];
- if(target == -1){
- SendClientMessage(playerid, COLOR_RED, "Nobody has sent you a PM, use /pm <player> <message> to send them a message.");
- } else if (sscanf(params, "s[128]", message)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /r <message>");
- } else if(strlen(message) > 75){
- SendClientMessage(playerid, COLOR_RED, "Your message is too long.");
- } else if(!IsPlayerConnected(target)){
- SendClientMessage(playerid, COLOR_RED, "The person you are replying to disconnected.");
- } else {
- format(string, sizeof(string), "PM Sent to %s: %s", playerName[target], message);
- SendClientMessage(playerid, COLOR_ORANGE, string);
- format(string, sizeof(string), "PM from %s (use /r to respond): %s", playerName[playerid], message);
- SendClientMessage(target, COLOR_ORANGE, string);
- playerReply[target] = playerid;
- }
- }
- dcmd_forcecar(playerid, params[]){
- new target, model;
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else if (sscanf(params, "ud", target, model)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /forcecar <player> <model_id>");
- } else if ((model < 400 || model > 611) && model != -1){
- SendClientMessage(playerid, COLOR_RED, "Invalid model ID.");
- } else {
- SendClientMessage(playerid, COLOR_RED, "The model ID has been forced (use -1 to disable)");
- playerForceCar[target] = model;
- }
- }
- dcmd_info(playerid, params[]){
- new target;
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else if (sscanf(params, "u", target)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /info <player>");
- } else {
- new Float:health, Float:pHealth, ip[16];
- GetVehicleHealth(GetPlayerVehicleID(target), health);
- GetPlayerHealth(target, pHealth);
- GetPlayerIp(target, ip, sizeof(ip));
- new Float:percentage = (health - 240) / 750 * 100;
- format(string, sizeof(string), "%s (ID: %d) | Ping: %d | Time: %d | Money: $%d", playerName[target], target, GetPlayerPing(target), playerTime[target], GetPlayerMoney(target));
- SendClientMessage(playerid, COLOR_ORANGE, string);
- if(playerActive[target] == 1){
- format(string, sizeof(string), "Vehicle: %d%% | Player: %d%%", floatround(percentage, floatround_ceil), floatround(pHealth, floatround_ceil));
- SendClientMessage(playerid, COLOR_ORANGE, string);
- }
- format(string, sizeof(string), "Level: %d | IP Address: %s", playerLevel[target], ip);
- SendClientMessage(playerid, COLOR_ORANGE, string);
- }
- }
- dcmd_watch(playerid, params[]){
- new target;
- if(!CheckAdminLevel(playerid, 2)){
- SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
- } else if (sscanf(params, "u", target)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /watch <player>");
- } else {
- playerActive[playerid] = 0;
- playerTime[playerid] = 0;
- KillTimers(playerid);
- SetPlayerColor(playerid, COLOR_WHITE);
- DestroyVehicle(GetPlayerVehicleID(playerid));
- playerVehicle[playerid] = -1;
- playerSpectate[playerid] = target;
- playerSpectated[target] = playerid;
- GameTextForPlayer(playerid, "~w~Use ~r~/play~w~ to play", 10000000000000, 4);
- if(GetPlayerState(playerid) == 9){
- playerSpectating[playerid] = 1;
- TogglePlayerSpectating(playerid, 0);
- }
- TogglePlayerSpectating(playerid, 1);
- }
- }
- dcmd_credits(playerid, params[]){
- #pragma unused params
- SendClientMessage(playerid, COLOR_ORANGE, "Idea: Redirect_Left");
- SendClientMessage(playerid, COLOR_ORANGE, "Hosting: serverFFS.com");
- SendClientMessage(playerid, COLOR_ORANGE, "Scripting: Woet, RoBo, Westie, Doerfler");
- SendClientMessage(playerid, COLOR_ORANGE, "Beta testing: dugi, Felle, Karlip, kc, Killerkid, Lon[WN], joemomma53, spacemud, Blacklite, ToMo");
- SendClientMessage(playerid, COLOR_ORANGE, "Beta testing: IJzerenRita, LobbyZ, Ctrl_Alt_Llama, ev0lution, []Localhost[], Potassium, zazaza, Gappy");
- }
- dcmd_mapping(playerid, params[]){
- #pragma unused params
- SendClientMessage(playerid, COLOR_ORANGE, "Creating maps for sumoFFS is extremely easy and fun to do!");
- SendClientMessage(playerid, COLOR_ORANGE, "Simply use a map editor to create your map, spawns and camera position and convert this to our map format.");
- SendClientMessage(playerid, COLOR_ORANGE, "For more information and submitting maps, visit sumoFFS.com or #sumoFFS on irc.ffsnetwork.com");
- }
- dcmd_me(playerid, params[]){
- new message[128];
- if (sscanf(params, "s[128]", message)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /me <action>");
- } else {
- format(string, sizeof(string), "* %s %s", playerName[playerid], message);
- SendClientMessageToAll(COLOR_WHITE, string);
- }
- }
- dcmd_login(playerid, params[]){
- new password[128];
- if(playerLevel[playerid] > 0){
- SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
- } else if (sscanf(params, "s[128]", password)){
- SendClientMessage(playerid, COLOR_RED, "USAGE: /login <password>");
- } else {
- if(strcmp(password, "p0pzsmells", true) == 0){
- playerLevel[playerid] = 5;
- format(string, sizeof(string), "%s has logged in as admin level %d.", playerName[playerid], playerLevel[playerid]);
- AdminMessage(string);
- } else {
- SendClientMessage(playerid, COLOR_RED, "Incorrect password.");
- }
- }
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(map, 3, cmdtext);
- dcmd(login, 5, cmdtext);
- dcmd(loadmap, 7, cmdtext);
- dcmd(reloadmap, 9, cmdtext);
- dcmd(randommap, 9, cmdtext);
- dcmd(reset, 5, cmdtext);
- dcmd(spectate, 8, cmdtext);
- dcmd(play, 4, cmdtext);
- dcmd(kick, 4, cmdtext);
- dcmd(ban, 3, cmdtext);
- dcmd(me, 2, cmdtext);
- dcmd(credits, 7, cmdtext);
- dcmd(mapping, 7, cmdtext);
- dcmd(watch, 5, cmdtext);
- dcmd(drunk, 5, cmdtext);
- dcmd(restart, 7, cmdtext);
- dcmd(info, 4, cmdtext);
- dcmd(kill, 4, cmdtext);
- dcmd(pm, 2, cmdtext);
- dcmd(r, 1, cmdtext);
- dcmd(respawn, 7, cmdtext);
- dcmd(forcecar, 8, cmdtext);
- return 1;
- }
- //
- // Callbacks
- //
- public OnPlayerRequestClass(playerid, classid)
- {
- if(playerFirst[playerid] == 1){
- SetTimerEx("SpawnSpawnPlayer", 250, false, "d", playerid);
- ClearChat(playerid);
- SendClientMessage(playerid, COLOR_ORANGE, "Welcome to sumoFFS!");
- SendClientMessage(playerid, COLOR_ORANGE, "It's rather simple: you have to stay alive (and without falling) as long as possible.");
- SendClientMessage(playerid, COLOR_ORANGE, "Push everybody you can see off the map, but be sure to stay alive while doing so!");
- SendClientMessage(playerid, COLOR_ORANGE, "You can use /map for information about the map and /spectate to overview the entire map!");
- } else {
- KillTimers(playerid);
- DestroyVehicle(playerVehicle[playerid]);
- playerVehicle[playerid] = -1;
- SendClientMessage(playerid, COLOR_RED, "Forcing class selection (pressing F4) causes bugs. Please rejoin do not use it again.");
- KickReason(playerid, "Server", "Please rejoin.");
- }
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 0;
- }
- public OnPlayerConnect(playerid)
- {
- TextDrawShowForPlayer(playerid, bar);
- playerFirst[playerid] = 1;
- playerActive[playerid] = 0;
- playerSpectating[playerid] = 0;
- playerCountdown[playerid] = -1;
- playerLevel[playerid] = 0;
- playerAFK[playerid] = 0;
- playerIsPaused[playerid] = 0;
- playerFastSpawn[playerid] = 1;
- playerVehicle[playerid] = 0;
- playerAirbreak[playerid] = 0;
- playerVelocity[playerid][0] = 0;
- playerVelocity[playerid][1] = 0;
- playerVelocity[playerid][2] = 0;
- playerOldVelocity[playerid][0] = 0;
- playerOldVelocity[playerid][1] = 0;
- playerOldVelocity[playerid][2] = 0;
- playerCheatTreshold[playerid] = 0;
- playerInCountdown[playerid] = 0;
- playerPingWarnings[playerid] = 0;
- playerSpectate[playerid] = -1;
- playerSpectated[playerid] = -1;
- playerInstantSpawn[playerid] = 0;
- playerReply[playerid] = 0;
- playerForceCar[playerid] = -1;
- playerTicks[playerid] = 0;
- GetPlayerName(playerid, playerName[playerid], 24);
- SetPlayerColor(playerid, COLOR_WHITE);
- TogglePlayerClock(playerid, 1);
- format(string, sizeof(string), "~>~ ~r~Laikas: ~g~0 sekundes ~<~~>~ ~r~Vieta: ~g~n/a ~<~~>~ ~r~Bukle: ~g~n/a ~<~~>~ ~r~Zemelapis: ~g~%s ~<~");
- playerBar[playerid] = TextDrawCreate(10.000000,430.000000, string);
- TextDrawAlignment(playerBar[playerid],0);
- TextDrawBackgroundColor(playerBar[playerid],0xffffff33);
- TextDrawFont(playerBar[playerid],1);
- TextDrawLetterSize(playerBar[playerid],0.35,1.500000);
- TextDrawColor(playerBar[playerid],0x000000ff);
- TextDrawSetOutline(playerBar[playerid],1);
- TextDrawSetProportional(playerBar[playerid],1);
- TextDrawSetShadow(playerBar[playerid],1);
- TextDrawShowForPlayer(playerid, playerBar[playerid]);
- format(string, sizeof(string), "%s has connected.", playerName[playerid]);
- SendClientMessageToAll(COLOR_GREY, string);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- playerActive[playerid] = 0;
- playerLevel[playerid] = 0;
- DestroyVehicle(playerVehicle[playerid]);
- playerVehicle[playerid] = -1;
- KillTimers(playerid);
- // Is he being spectated?
- if(IsPlayerConnected(playerSpectated[playerid])){
- SendClientMessage(playerSpectated[playerid], COLOR_ORANGE, "The player you were watching disconnected.");
- playerInstantSpawn[playerid] = 1;
- playerSpectated[playerSpectate[playerid]] = -1;
- playerSpectate[playerid] = -1;
- TogglePlayerSpectating(playerid, 0);
- }
- if(reason == 0){
- format(string, sizeof(string), "%s has timed out.", playerName[playerid]);
- SendClientMessageToAll(COLOR_GREY, string);
- }
- if(reason == 1){
- format(string, sizeof(string), "%s has disconnected.", playerName[playerid]);
- SendClientMessageToAll(COLOR_GREY, string);
- }
- return 1;
- }
- public KillTimers(playerid){
- if(playerCountdown[playerid] > -1){ KillTimer(playerCountdown[playerid]); playerInCountdown[playerid] = 0; playerCountdown[playerid] = -1; }
- if(playerActiveTimer[playerid] > -1){ KillTimer(playerActiveTimer[playerid]); playerActiveTimer[playerid] = -1; }
- }
- public OnPlayerSpawn(playerid)
- {
- if(playerSpectating[playerid] == 1){
- playerSpectating[playerid] = 0;
- } else {
- if(playerInstantSpawn[playerid] == 1){
- CountdownPlayer(playerid, 1);
- } else if(playerFastSpawn[playerid] == 1){
- CountdownPlayer(playerid, 5);
- } else {
- CountdownPlayer(playerid, 10);
- }
- playerInstantSpawn[playerid] = 0;
- playerFirst[playerid] = 0;
- playerFastSpawn[playerid] = 0;
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason){
- SetPlayerColor(playerid, COLOR_WHITE);
- format(string, sizeof(string), "%s died after %d seconds.", playerName[playerid], playerTime[playerid]);
- SendClientMessageToAll(COLOR_YELLOW, string);
- // Is he being spectated?
- if(IsPlayerConnected(playerSpectated[playerid])){
- SendClientMessage(playerSpectated[playerid], COLOR_ORANGE, "Your camera will be corrected as soon as the player respawns.");
- }
- new vehicleid = playerVehicle[playerid];
- vehicleKill[vehicleid] = SetTimerEx("KillVehicle", 3000, false, "d", vehicleid);
- playerVehicle[playerid] = -1;
- playerTime[playerid] = 0;
- playerActive[playerid] = 0;
- }
- public KillVehicle(vehicleid){
- if(vehicleKill[vehicleid] > -1){ KillTimer(vehicleKill[vehicleid]); vehicleKill[vehicleid] = -1; }
- return DestroyVehicle(vehicleid);
- }
- public OnVehicleSpawn(vehicleid)
- {
- if(vehicleKill[vehicleid] > -1){ KillTimer(vehicleKill[vehicleid]); vehicleKill[vehicleid] = -1; }
- return DestroyVehicle(vehicleid);
- }
- public OnPlayerText(playerid, text[])
- {
- if(strcmp(text, "@", true, 1) == 0 && CheckAdminLevel(playerid, 1)){
- strdel(text, 0, 1);
- format(string, sizeof(string), "[ADMIN] %s: %s", playerName[playerid], text);
- AdminMessage(string);
- } else {
- format(string, sizeof(string), "%s: %s", playerName[playerid], text);
- SendClientMessageToAll(COLOR_WHITE, string);
- }
- return 0;
- }
- public OnPlayerExitVehicle(playerid, vehicleid){
- playerExiting[playerid] = 1;
- playerVehicleHealth[playerid] = 990.0;
- SetVehicleHealth(GetPlayerVehicleID(playerid), 990.0);
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(oldstate == 2 && newstate == 1){
- if(playerExiting[playerid] == 1){
- playerExiting[playerid] = 0;
- playerOldVehicle[playerid] = playerVehicle[playerid];
- format(string, sizeof(string), "%s exited their vehicle after %d seconds.", playerName[playerid], playerTime[playerid]);
- SendClientMessageToAll(COLOR_YELLOW, string);
- DestroyVehicle(playerVehicle[playerid]);
- playerVehicle[playerid] = -1;
- PlayerDied(playerid, true);
- }
- }
- if(newstate == 9){
- if(IsPlayerConnected(playerSpectate[playerid])){
- new target = playerSpectate[playerid];
- if(playerVehicle[target] == -1){
- format(string, sizeof(string), "You will automatically spectate %s once respawned.", playerName[target]);
- } else {
- format(string, sizeof(string), "You are now spectating %s", playerName[target]);
- PlayerSpectateVehicle(playerid, playerVehicle[target]);
- }
- SendClientMessage(playerid, COLOR_ORANGE, string);
- } else {
- SetPlayerCameraPos(playerid, mapCamera[COORD_X], mapCamera[COORD_Y], mapCamera[COORD_Z]);
- SetPlayerCameraLookAt(playerid, mapCameraLookAt[COORD_X], mapCameraLookAt[COORD_Y], mapCameraLookAt[COORD_Z]);
- }
- } else {
- if(oldstate == 9){
- SetCameraBehindPlayer(playerid);
- }
- }
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- playerUpdated[playerid] = 1;
- if(playerIsPaused[playerid] == 1){
- format(string, sizeof(string), "%s is back from being paused.", playerName[playerid]);
- SendClientMessageToAll(COLOR_PINK, string);
- SetPlayerVirtualWorld(playerid, 0);
- playerIsPaused[playerid] = 0;
- }
- if(playerActive[playerid] == 1){
- new Float:x, Float:y, Float:z, Float:vHealth, Float:pHealth, Float:pArmour, Float:vX, Float:vY, Float:vZ;
- GetPlayerPos(playerid, x, y, z);
- // Healths
- GetVehicleHealth(GetPlayerVehicleID(playerid), vHealth);
- GetPlayerHealth(playerid, pHealth);
- GetPlayerArmour(playerid, pArmour);
- // Velocity
- GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
- if(playerTime[playerid] > 5){
- // Airbreak
- if(vX == 0.0 && vY == 0.0 && vZ < -0.0032 && vZ > -0.022){
- playerAirbreak[playerid]++;
- if(playerAirbreak[playerid] > 5){
- AdminMessage("The player who is being kicked was airbreaking..");
- BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 105)");
- printf("CHEAT - AIRBREAK - %s - %f %f %f", playerName[playerid], vX, vY, vZ);
- return false;
- }
- } else {
- playerAirbreak[playerid] = 0;
- }
- // Velocity
- if(playerVelocityTicks[playerid] > 15){
- if(playerVelocity[playerid][0] > 19 || playerVelocity[playerid][0] < -19 || playerVelocity[playerid][1] > 19 || playerVelocity[playerid][1] < -19 || playerVelocity[playerid][2] > 19 || playerVelocity[playerid][2] < -19){
- AdminMessage("The player who is being kicked was speedhacking (speed)..");
- BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 106)");
- printf("CHEAT - VELOCITY1 - %s - %f %f %f", playerName[playerid], playerVelocity[playerid][0], playerVelocity[playerid][1], playerVelocity[playerid][2]);
- return false;
- }
- new Float:increment[3];
- increment[0] = playerVelocity[playerid][0] - playerOldVelocity[playerid][0];
- increment[1] = playerVelocity[playerid][1] - playerOldVelocity[playerid][1];
- increment[2] = playerVelocity[playerid][2] - playerOldVelocity[playerid][2];
- if(playerOldVelocity[playerid][0] != 0 && (increment[0] > 10 || increment[0] < -10 || increment[1] > 10 || increment[1] < -10 || increment[2] > 10 || increment[2] < -10)){
- /*
- AdminMessage("The player who is being kicked was speedhacking (acceleration)..");
- BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 107)");
- printf("CHEAT - VELOCITY2 - %s - %f %f %f", playerName[playerid], increment[0], increment[1], increment[2]);
- return false;
- */
- }
- playerVelocityTicks[playerid] = 0;
- playerOldVelocity[playerid][0] = playerVelocity[playerid][0];
- playerOldVelocity[playerid][1] = playerVelocity[playerid][1];
- playerOldVelocity[playerid][2] = playerVelocity[playerid][2];
- playerVelocity[playerid][0] = 0;
- playerVelocity[playerid][1] = 0;
- playerVelocity[playerid][2] = 0;
- } else {
- playerVelocityTicks[playerid]++;
- playerVelocity[playerid][0] += vX;
- playerVelocity[playerid][1] += vY;
- playerVelocity[playerid][2] += vZ;
- }
- // Player armor
- if(pArmour > 0){
- AdminMessage("The player who is being kicked had armour..");
- BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 104)");
- printf("CHEAT - ARMOUR - %s - %f", playerName[playerid], pArmour);
- return false;
- }
- // Vehicle health
- if(vHealth > 0){
- if(vHealth > 990){
- if(playerCheatTreshold[playerid] > 30){
- AdminMessage("The player who is being kicked had their vehicle health go beyond our limit..");
- BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 101)");
- printf("CHEAT - VHEALTH1 - %s - %f", playerName[playerid], vHealth);
- return false;
- } else {
- playerCheatTreshold[playerid]++;
- }
- }
- if(vHealth > playerVehicleHealth[playerid] && playerVehicleHealth[playerid] > 0){
- AdminMessage("The player who is being kicked had their vehicle health go up..");
- BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 102)");
- printf("CHEAT - VHEALTH2 - %s - %f %f", playerName[playerid], vHealth, playerVehicleHealth[playerid]);
- return false;
- }
- }
- GetVehicleHealth(GetPlayerVehicleID(playerid), playerVehicleHealth[playerid]);
- }
- if(floatround(z) < mapTreshold){
- format(string, sizeof(string), "%s fell off after %d seconds.", playerName[playerid], playerTime[playerid]);
- SendClientMessageToAll(COLOR_YELLOW, string);
- DestroyVehicle(GetPlayerVehicleID(playerid));
- playerVehicle[playerid] = -1;
- PlayerDied(playerid, true);
- }
- }
- if(GetPlayerWeapon(playerid) != 0){
- AdminMessage("The player who is being kicked had a weapon..");
- BanReason(playerid, "Server", "Anti-Cheat triggered (Reason: 103)");
- printf("CHEAT - WEAPON - %s - %d", playerName[playerid], GetPlayerWeapon(playerid));
- return false;
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- //
- // Invalid actions (most likely cheats)
- //
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if(vehicleid != playerOldVehicle[playerid]){
- AdminMessage("The player who is being kicked entered a vehicle..");
- return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 001)");
- } else {
- return 1;
- }
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- AdminMessage("The player who is being kicked picked up a pickup..");
- return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 002)");
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- AdminMessage("The player who is being kicked modded their vehicle..");
- return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 003)");
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- AdminMessage("The player who is being kicked painted their vehicle..");
- return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 004)");
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- AdminMessage("The player who is being kicked resprayed their vehicle..");
- return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 005))");
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- AdminMessage("The player who is being kicked changed interior..");
- return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 006)");
- }
- //
- // Stocks
- //
- #define _strlib_included
- #define _strlib_sma_string 128
- #define _strlib_med_string 256
- #define _strlib_big_string 512
- stock GetPlayerPlace(playerid)
- {
- new Rank = 1;
- new score = playerTime[playerid];
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(playerActive[i] == 1 && playerTime[i] > score) Rank++;
- }
- return Rank;
- }
- stock CheckAdminLevel(playerid, level){
- if(playerLevel[playerid] >= level){
- return true;
- } else {
- return false;
- }
- }
- stock GetSuffix(number){
- new suffix[4];
- if(number == 1 || number == 21 || number == 31 || number == 41){
- format(suffix, sizeof(suffix), "st");
- } else if(number == 2 || number == 22 || number == 32 || number == 42){
- format(suffix, sizeof(suffix), "nd");
- } else if(number == 3|| number == 23 || number == 33 || number == 43){
- format(suffix, sizeof(suffix), "rd");
- } else {
- format(suffix, sizeof(suffix), "th");
- }
- return suffix;
- }
- stock trim(const sSource[])
- {
- new
- iBegin,
- iEnd,
- iInputLength = strlen(sSource),
- sReturn[_strlib_med_string];
- strcat(sReturn, sSource, _strlib_med_string);
- for(iBegin = 0; iBegin < iInputLength; ++iBegin)
- {
- switch(sReturn[iBegin])
- {
- case ' ', '\t', '\r', '\n':
- {
- continue;
- }
- default:
- {
- break;
- }
- }
- }
- for(iEnd = (iInputLength - 1); iEnd > iBegin; --iEnd)
- {
- switch(sReturn[iEnd])
- {
- case ' ', '\t', '\r', '\n':
- {
- continue;
- }
- default:
- {
- break;
- }
- }
- }
- strdel(sReturn, (iEnd + 1), iInputLength);
- strdel(sReturn, 0, iBegin);
- return sReturn;
- }
Advertisement
Add Comment
Please, Sign In to add comment