Advertisement
Shiny_

RZOL

Sep 26th, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.07 KB | None | 0 0
  1. // Includes:
  2.     #include <a_samp>
  3.     #include <crashdetect>
  4.     #include <regex>
  5.     #include <sscanf2>
  6.     #include <YSF>
  7.     #include <YSI\y_iterate>
  8.     #include <zcmd>
  9.  
  10. // Macros:
  11.     #define function%0(%1)                          \
  12.             forward %0(%1);                         \
  13.             public %0(%1)
  14.     #define Timer::
  15.     #if !defined INTERPOLATIONTIME
  16.             #define INTERPOLATIONTIME                                                               \
  17.                     20000
  18.     #endif
  19.    
  20. // Variables:
  21.     new vehicle;
  22.     new text_[100];
  23.     new Float: Position[4];
  24.     new Name[MAX_PLAYER_NAME];
  25.     new RegEx: AntiAdvertisement;
  26.     new bool: Commanded[MAX_VEHICLES];
  27.     new Set_CameraPos_Timer[MAX_PLAYERS];
  28.     new PlayerText3D: Time3DText[MAX_PLAYERS];
  29.     new gVehicleNames[212][] = {
  30.         "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel", "Dumper",
  31.         "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus", "Voodoo", "Pony", "Mule",
  32.         "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi", "Washington",
  33.         "Bobcat", "Mr Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer", "Securicar",
  34.         "Banshee", "Predator", "Bus", "Rhino", "Barracks", "Hotknife", "Trailer 1", "Previon",
  35.         "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster",
  36.         "Admiral", "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer 2", "Turismo",
  37.         "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  38.         "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic",
  39.         "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre",
  40.         "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX", "Burrito", "Camper", "Marquis",
  41.         "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher", "FBI Rancher", "Virgo", "Greenwood",
  42.         "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick", "Boxville", "Benson",
  43.         "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher",
  44.         "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropdust", "Stunt",
  45.         "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900",
  46.         "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune", "Cadrona", "FBI Truck",
  47.         "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan",
  48.         "Blade", "Freight", "Streak", "Vortex", "Vincent", "Bullet", "Clover", "Sadler",
  49.         "Firetruck LA", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit",
  50.         "Utility", "Nevada", "Yosemite", "Windsor", "Monster A", "Monster B", "Uranus", "Jester",
  51.         "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna",
  52.         "Bandito", "Freight Flat", "Streak Carriage", "Kart", "Mower", "Duneride", "Sweeper",
  53.         "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400", "Newsvan",
  54.         "Tug", "Trailer 3", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Freight Carriage",
  55.         "Trailer 3", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LSPD)", "Police Car (SFPD)",
  56.         "Police Car (LVPD)", "Police Ranger", "Picador", "S.W.A.T. Van", "Alpha", "Phoenix", "Glendale",
  57.         "Sadler", "Luggage Trailer A", "Luggage Trailer B", "Stair Trailer", "Boxville", "Farm Plow",
  58.         "Utility Trailer"
  59.     };
  60.    
  61. // Static functions:
  62.     stock RespawnUnusedVehicles() {
  63.         new UsedVeh[MAX_VEHICLES] = {false, ...};
  64.         foreach(new playerid: Player) {
  65.             UsedVeh[GetPlayerVehicleID(playerid)] = true;
  66.         }
  67.        
  68.         for(new vehicleid = 1; vehicleid != MAX_VEHICLES; vehicleid++) {
  69.             if(UsedVeh[vehicleid]) continue;
  70.             if(Commanded[vehicleid]) {
  71.                 DestroyVehicle(vehicleid);
  72.                 Commanded[vehicleid] = false;
  73.             }
  74.             SetVehicleToRespawn(vehicleid);
  75.         }
  76.         return true;
  77.     }
  78.  
  79.     stock CreatePlayerVehicle(playerid, modelid) {
  80.         if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  81.             vehicle = GetPlayerVehicleID(playerid);
  82.             GetVehiclePos(vehicle, Position[0], Position[1], Position[2]);
  83.             GetVehicleZAngle(vehicle, Position[3]);
  84.             DestroyVehicle(vehicle);
  85.         } else {
  86.             GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
  87.             GetPlayerFacingAngle(playerid, Position[3]);
  88.         }
  89.         vehicle = AddStaticVehicle(modelid, Position[0], Position[1], Position[2] + 1, Position[3], -1, -1);
  90.         LinkVehicleToInterior(vehicle, GetPlayerInterior(playerid));
  91.         SetVehicleVirtualWorld(vehicle, GetPlayerVirtualWorld(playerid));
  92.         SetVehicleNumberPlate(vehicle, PlayerName(playerid));
  93.         PutPlayerInVehicle(playerid, vehicle, 0);
  94.         Commanded[vehicle] = true;
  95.         return true;
  96.     }
  97.    
  98.     stock GetVehicleModelIDByName(vehiclename[]) {
  99.         for(new i = 0; i < 211; i++) {
  100.             if(strfind(gVehicleNames[i], vehiclename, true) != -1) return i + 400;
  101.         }
  102.         return -1;
  103.     }
  104.    
  105.     stock delete_free_space(string[], character = ' ') {
  106.         new len = strlen(string);
  107.         if(len) {
  108.             new begin = -1, end = len;
  109.             while(string[++begin] == character) {}
  110.             if(string[begin] == EOS) {
  111.                 string[0] = false;
  112.                 return true;
  113.             }
  114.             while(string[--end] == character) {}
  115.             strmid(string, string, begin, end + 1, len + 1);
  116.         }
  117.         return true;
  118.     }
  119.    
  120.     stock PlayerName(playerid) {
  121.         GetPlayerName(playerid, Name, sizeof(Name));
  122.         return Name;
  123.     }
  124.    
  125. // Dynamic functions:  
  126.     function RespawnVehicles(vehicleid) {
  127.         RespawnUnusedVehicles();
  128.         SendClientMessageToAll(-1, "Auta stworzone za pomocą komendy /v zostały usunięte!");
  129.         return true;
  130.     }
  131.    
  132.     function Time(playerid) {
  133.         new time[3];
  134.         new string__[128];
  135.         gettime(time[0], time[1], time[2]);
  136.         format(string__, sizeof(string__), "[%02d:%02d:%02d]", time[0], time[1], time[2]);
  137.         UpdatePlayer3DTextLabelText(playerid, Time3DText[playerid], -1, string__);
  138.         return true;
  139.     }
  140.    
  141.     function SetCameraPosEx(playerid) {
  142.         SetPlayerInterior(playerid, 0);
  143.         SetPlayerFacingAngle(playerid, 90.0);
  144.         SetPlayerPos(playerid, -1399.0179, 2640.7385, 55.6875);
  145.         SetPlayerCameraPos(playerid, -1410.462402, 2640.7385, 55.6875);
  146.         SetPlayerCameraLookAt(playerid, -1410.462402, 2640.7385, 55.6875, CAMERA_CUT);
  147.         ApplyAnimation(playerid, "RAPPING", "RAP_B_Loop", 4.0, 1, 0, 0, 0, 0);
  148.     }
  149.        
  150. // Public functions:
  151.     main() {
  152.         AntiAdvertisement = regex_build("\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)+([(/|,.)?\\s]{1,})+(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)+([(/|,.)?\\s]{1,})+(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)+([(/|,.)?\\s]{1,})+(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
  153.         printf(regex_isvalid(AntiAdvertisement)? ("Kod regex antyreklamy jest poprawny!"): ("Kod regex antyreklamy jest niepoprawny!"));
  154.         SetTimer("RespawnVehicles", 15 * 60 * 1000, true);
  155.         SetModeRestartTime(0.1);
  156.         return false;
  157.     }
  158.    
  159.     public OnPlayerConnect(playerid) {
  160.         PlayAudioStreamForPlayer(playerid, "http://alldev.eu/mp3/april_showers.mp3");
  161.        
  162.         InterpolateCameraPos(playerid, -2662.6853, 1933.7972, 225.7578, -1409.489868, 2642.814697, 58.506492, INTERPOLATIONTIME, CAMERA_MOVE);
  163.         InterpolateCameraLookAt(playerid, -2662.6853, 1933.7972, 225.7578, -1404.622924, 2642.720458, 57.364322, INTERPOLATIONTIME, CAMERA_MOVE);
  164.  
  165.         ApplyAnimation(playerid, "RAPPING", "RAP_B_Loop", 4.0, 1, 0, 0, 0, 0);
  166.         Set_CameraPos_Timer[playerid] = SetTimerEx("SetCameraPosEx", INTERPOLATIONTIME, false, "d", playerid);
  167.        
  168.         SetTimerEx("Time", 999, true, "d", playerid);
  169.         return true;
  170.     }
  171.    
  172.     public OnPlayerSpawn(playerid) {
  173.         KillTimer(Set_CameraPos_Timer[playerid]);
  174.         SetCameraBehindPlayer(playerid);
  175.         StopAudioStreamForPlayer(playerid);
  176.         SetPlayerFacingAngle(playerid, 90.0);
  177.         SetPlayerPos(playerid, -1399.0179, 2640.7385, 55.6875);
  178.         SetPlayerWorldBounds(playerid, 20000.0000, -20000.0000, 20000.0000, -20000.0000);
  179.         return true;
  180.     }
  181.    
  182.     public OnPlayerText(playerid, text[]) {
  183.         new MSG_EX[180];
  184.         new STRING[180];
  185.         format(MSG_EX, sizeof(MSG_EX), "%s próbuje reklamować.", PlayerName(playerid));
  186.         regex_replace_exid(text, AntiAdvertisement, MSG_EX, STRING);
  187.        
  188.         format(STRING, sizeof(STRING), "(ID: %d): %s", playerid, text);
  189.         SendPlayerMessageToAll(playerid, STRING);
  190.         printf("%s: %s", PlayerName(playerid), text);
  191.         return false;
  192.     }
  193.    
  194.     public OnPlayerCommandPerformed(playerid, cmdtext[], success) {
  195.         if(!success) {
  196.             if(strlen(cmdtext) > 2) {
  197.                 strdel(cmdtext, 0, 1);
  198.                 for(new i = 400; i <= 611; i++) {
  199.                     if(strfind(gVehicleNames[i - 400], cmdtext, true) != -1) {
  200.                         CreatePlayerVehicle(playerid, i);
  201.                         format(text_, sizeof(text_), "Pojazd o nazwie {FF0000}%s{FFFFFF} zostaje utworzony.", gVehicleNames[i - 400]);
  202.                         SendClientMessage(playerid, -1, text_);
  203.                         return true;
  204.                     }
  205.                 }
  206.             }
  207.             format(text_, sizeof(text_), "Na serwerze nie ma takiej komendy jak /%s!", cmdtext);
  208.             SendClientMessage(playerid, -1, text_);
  209.             printf("%s wpisuje komendę: /%s", PlayerName(playerid), cmdtext);
  210.         }
  211.         return true;
  212.     }
  213.    
  214.     public OnPlayerStateChange(playerid, newstate, oldstate) {
  215.         format(text_, sizeof(text_), "%s", Time(playerid));
  216.         switch(newstate) {case PLAYER_STATE_DRIVER: Time3DText[playerid] = CreatePlayer3DTextLabel(playerid, text_, -1, 0, 0, 0, 15.0, INVALID_PLAYER_ID, GetPlayerVehicleID(playerid), 1);}
  217.         switch(oldstate) {case PLAYER_STATE_DRIVER: DeletePlayer3DTextLabel(playerid, Time3DText[playerid]);}
  218.         return true;
  219.     }
  220.  
  221.     public OnPlayerDisconnect(playerid, reason) {
  222.         if(!IsPlayerConnected(playerid)) return DeletePlayer3DTextLabel(playerid, Time3DText[playerid]), KillTimer(Set_CameraPos_Timer[playerid]);
  223.         return true;
  224.     }
  225.    
  226.     public OnGameModeExit() {
  227.         return regex_delete(AntiAdvertisement) && true;
  228.     }
  229.    
  230. // Commands:
  231.     CMD:v(playerid, params[]) {
  232.         new GetVehicleModelVariable = GetVehicleModelIDByName(params);
  233.         delete_free_space(params);
  234.         if(isnull(params)) return SendClientMessage(playerid, -1, "Wpisz /v nazwa_pojazdu");
  235.         else if(GetVehicleModelVariable != -1) CreatePlayerVehicle(playerid, GetVehicleModelVariable), format(text_, sizeof(text_), "Pojazd o nazwie {FF0000}%s{FFFFFF} zostaje utworzony.", gVehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400]), SendClientMessage(playerid, -1, text_);
  236.         else SendClientMessage(playerid, -1, "Zła nazwa pojazdu!");
  237.         return true;
  238.     }
  239.    
  240.     CMD:respawn(playerid) {
  241.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Tą komendę może wpisać tylko Administrator!");
  242.         RespawnUnusedVehicles();
  243.         return true;
  244.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement