Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Includes:
- #include <a_samp>
- #include <crashdetect>
- #include <regex>
- #include <YSF>
- #include <YSI\y_iterate>
- #include <zcmd>
- // Macros:
- #define function%0(%1) \
- forward %0(%1); \
- public %0(%1)
- #define Timer::
- // Variables:
- new vehicle;
- new text_[100];
- new Float: Position[4];
- new Name[MAX_PLAYER_NAME];
- new RegEx: AntiAdvertisement;
- new bool: Commanded[MAX_VEHICLES];
- new PlayerText3D: Time3DText[MAX_PLAYERS];
- new Timer:: Set_CameraPos_Timer[MAX_PLAYERS];
- new gVehicleNames[212][] = {
- "Landstalker", "Bravura", "Buffalo", "Linerunner", "Pereniel", "Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana",
- "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi", "Washington", "Bobcat",
- "Mr Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks",
- "Hotknife", "Trailer", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
- "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy",
- "Solair", "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Harley", "RC Baron", "RC Raider", "Glendale", "Oceanic",
- "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR3 50", "Walton", "Regina",
- "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher", "FBI Rancher",
- "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa",
- "RC Goblin", "Hotring Racer", "Hotring Racer", "Bloodring Banger", "Rancher", "Super GT", "Elegant", "Journey", "Bike",
- "Mountain Bike", "Beagle", "Cropdust", "Stunt", "Tanker", "RoadTrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
- "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune", "Cadrona", "FBI Truck", "Willard", "Forklift", "Traktor",
- "Combine", "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent", "Bullet", "Clover", "Sadler",
- "Firetruck", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor",
- "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna",
- "Bandito", "Freight", "Trailer", "Kart", "Mower", "Duneride", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley",
- "Stafford", "BF-400", "Newsvan", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Trailer", "Trailer",
- "Andromeda", "Dodo", "RC Cam", "Launch", "Radiowoz", "Radiowoz", "Radiowoz", "Radiowoz", "Picador", "S.W.A.T. Van",
- "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer", "Luggage Trailer", "Stair Trailer", "Boxville", "Farm Plow", "Utility Trailer"
- };
- // Static functions:
- stock RespawnUnusedVehicles() {
- new UsedVeh[MAX_VEHICLES] = {false, ...};
- foreach(new playerid: Player) {
- UsedVeh[GetPlayerVehicleID(playerid)] = true;
- }
- for(new vehicleid = 1; vehicleid != MAX_VEHICLES; vehicleid++) {
- if(UsedVeh[vehicleid]) continue;
- else if(Commanded[vehicleid]) return DestroyVehicle(vehicleid), Commanded[vehicleid] = false;
- SetVehicleToRespawn(vehicleid);
- }
- return true;
- }
- stock CreatePlayerVehicle(playerid, modelid) {
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
- vehicle = GetPlayerVehicleID(playerid);
- GetVehiclePos(vehicle, Position[0], Position[1], Position[2]);
- GetVehicleZAngle(vehicle, Position[3]);
- DestroyVehicle(vehicle);
- } else {
- GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
- GetPlayerFacingAngle(playerid, Position[3]);
- }
- vehicle = AddStaticVehicle(modelid, Position[0], Position[1], Position[2] + 1, Position[3], -1, -1);
- LinkVehicleToInterior(vehicle, GetPlayerInterior(playerid));
- SetVehicleVirtualWorld(vehicle, GetPlayerVirtualWorld(playerid));
- SetVehicleNumberPlate(vehicle, PlayerName(playerid));
- PutPlayerInVehicle(playerid, vehicle, 0);
- Commanded[vehicle] = true;
- return true;
- }
- stock GetVehicleModelIDByName(vehiclename[]) {
- for(new i = 0; i < 211; i++) {
- if(strfind(gVehicleNames[i], vehiclename, true) != -1) return i + 400;
- }
- return -1;
- }
- stock delete_free_space(string[], character = ' ') {
- new len = strlen(string);
- if(len) {
- new begin = -1, end = len;
- while(string[++begin] == character) {}
- if(string[begin] == EOS) {
- string[0] = false;
- return true;
- }
- while(string[--end] == character) {}
- strmid(string, string, begin, end + 1, len + 1);
- }
- return true;
- }
- stock PlayerName(playerid) {
- GetPlayerName(playerid, Name, sizeof(Name));
- return Name;
- }
- // Dynamic functions:
- function RespawnVehicles(vehicleid) {
- RespawnUnusedVehicles();
- SendClientMessageToAll(-1, "Auta stworzone za pomocą komendy /v zostały usunięte!");
- return true;
- }
- function Time(playerid) {
- new time[3];
- new string__[128];
- gettime(time[0], time[1], time[2]);
- format(string__, sizeof(string__), "[%02d:%02d:%02d]", time[0], time[1], time[2]);
- UpdatePlayer3DTextLabelText(playerid, Time3DText[playerid], -1, string__);
- return true;
- }
- function Set_CameraPos(playerid) {
- SetPlayerCameraPos(playerid, -1410.462402, 2639.478271, 55.434036);
- SetPlayerCameraLookAt(playerid, -1405.579956, 2639.294677, 56.371879);
- SetPlayerPos(playerid, -1399.0179, 2640.7385, 55.6875);
- SetPlayerFacingAngle(playerid, 90.0);
- }
- // Public functions:
- main() {
- 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");
- printf(regex_isvalid(AntiAdvertisement)? ("Kod regex antyreklamy jest poprawny!"): ("Kod regex antyreklamy jest niepoprawny!"));
- SetTimer("RespawnVehicles", 15 * 60 * 1000, true);
- SetModeRestartTime(0.1);
- return false;
- }
- public OnGameModeInit() {
- for(new i; i <= 299; i++) {
- AddPlayerClass(i, -1399.0179, 2640.7385, 55.6875, 0.0, 0, 0, 0, 0, 0, 0);
- }
- return true;
- }
- public OnPlayerConnect(playerid) {
- PlayAudioStreamForPlayer(playerid, "http://alldev.eu/mp3/april_showers.mp3");
- InterpolateCameraPos(playerid, -1635.208984, 2274.272460, 101.468925, -1428.462402, 2642.478271, 66.434036, 9000);
- InterpolateCameraLookAt(playerid, -1633.167846, 2278.822753, 101.109863, -1423.579956, 2642.294677, 65.371879, 8000);
- ApplyAnimation(playerid, "RAPPING", "RAP_B_Loop", 4.0, 1, 0, 0, 0, 0);
- Set_CameraPos_Timer[playerid] = SetTimerEx("Set_CameraPos", 9000, true, "d", playerid);
- SetTimerEx("Time", 999, true, "d", playerid);
- return true;
- }
- public OnPlayerRequestClass(playerid, classid) {
- switch(GetPVarInt(playerid, "Dance")) {
- /*case 0: ApplyAnimation(playerid, "DANCING", "DAN_Down_A", 4.000000, 1, 1, 1, 1, 1);
- case 1: ApplyAnimation(playerid, "DANCING", "DAN_Left_A", 4.000000, 1, 1, 1, 1, 1);
- case 2: ApplyAnimation(playerid, "DANCING", "DAN_Right_A", 4.000000, 1, 1, 1, 1, 1);
- case 3: ApplyAnimation(playerid, "DANCING", "DAN_Up_A", 4.000000, 1, 1, 1, 1, 1);
- case 4: ApplyAnimation(playerid, "DANCING", "dnce_M_a", 4.000000, 1, 1, 1, 1, 1);
- case 5: ApplyAnimation(playerid, "RAPPING", "Laugh_01", 4.0, 1, 0, 0, 0, 0);
- case 6: ApplyAnimation(playerid, "RAPPING", "RAP_B_Loop", 4.0, 1, 0, 0, 0, 0);
- case 7: ApplyAnimation(playerid, "DANCING", "DAN_Right_A", 4.000000, 1, 1, 1, 1, 1);*/
- case 0: ApplyAnimation(playerid, "DANCING", "dnce_M_a", 4.1, 1, 1, 1, 1, 1, 1);
- case 1: ApplyAnimation(playerid, "DANCING", "dnce_M_b", 4.1, 1, 1, 1, 1, 1, 1);
- case 2: ApplyAnimation(playerid, "DANCING", "dnce_M_c", 4.1, 1, 1, 1, 1, 1, 1);
- case 3: ApplyAnimation(playerid, "DANCING", "dnce_M_d", 4.1, 1, 1, 1, 1, 1, 1);
- case 4: ApplyAnimation(playerid, "DANCING", "dnce_M_e", 4.1, 1, 1, 1, 1, 1, 1);
- }
- SetPVarInt(playerid, "Dance", GetPVarInt(playerid, "Dance") < /*7*/ 4? GetPVarInt(playerid, "Dance") + 1: 0);
- return true;
- }
- public OnPlayerSpawn(playerid) {
- KillTimer(Set_CameraPos_Timer[playerid]);
- SetCameraBehindPlayer(playerid);
- StopAudioStreamForPlayer(playerid);
- SetPlayerFacingAngle(playerid, 90.0);
- SetPlayerPos(playerid, -1399.0179, 2640.7385, 55.6875);
- SetPlayerWorldBounds(playerid, 20000.0000, -20000.0000, 20000.0000, -20000.0000);
- return true;
- }
- public OnPlayerText(playerid, text[]) {
- new MSG[180];
- new MSG_EX[180];
- format(MSG_EX, sizeof(MSG_EX), "%s próbuje reklamować.", PlayerName(playerid));
- regex_replace_exid(text, AntiAdvertisement, MSG_EX, MSG);
- SendPlayerMessageToAll(playerid, MSG);
- return false;
- }
- public OnPlayerCommandPerformed(playerid, cmdtext[], success) {
- if(!success) {
- for(new i; i < sizeof(gVehicleNames); i++) {
- if(strlen(cmdtext) > 2 && !strcmp(cmdtext[1], gVehicleNames[i], true)) {
- delete_free_space(cmdtext);
- CreatePlayerVehicle(playerid, i + 400);
- format(text_, sizeof(text_), "Pojazd o nazwie {FF0000}%s{FFFFFF} zostaje utworzony.", gVehicleNames[i]);
- SendClientMessage(playerid, -1, text_);
- return true;
- }
- }
- }
- format(text_, sizeof(text_), "Na serwerze nie ma takiej komendy jak %s!", cmdtext);
- SendClientMessage(playerid, -1, text_);
- printf("%s wpisuje komendę: %s", PlayerName(playerid), cmdtext);
- return true;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate) {
- format(text_, sizeof(text_), "%s", Time(playerid));
- switch(newstate) {case PLAYER_STATE_DRIVER: Time3DText[playerid] = CreatePlayer3DTextLabel(playerid, text_, -1, 0, 0, 0, 15.0, INVALID_PLAYER_ID, GetPlayerVehicleID(playerid), 1);}
- switch(oldstate) {case PLAYER_STATE_DRIVER: DeletePlayer3DTextLabel(playerid, Time3DText[playerid]);}
- return true;
- }
- public OnPlayerDisconnect(playerid, reason) {
- if(!IsPlayerConnected(playerid)) return DeletePlayer3DTextLabel(playerid, Time3DText[playerid]), KillTimer(Set_CameraPos_Timer[playerid]);
- return true;
- }
- public OnGameModeExit() {
- return regex_delete(AntiAdvertisement) && true;
- }
- // Commands:
- CMD:v(playerid, params[]) {
- delete_free_space(params);
- if(isnull(params)) return SendClientMessage(playerid, -1, "Wpisz /v nazwa_pojazdu");
- else if(GetVehicleModelIDByName(params) != -1) CreatePlayerVehicle(playerid, GetVehicleModelIDByName(params));
- else return SendClientMessage(playerid, -1, "Zła nazwa pojazdu!");
- return true;
- }
- CMD:respawn(playerid) {
- (!IsPlayerAdmin(playerid)? SendClientMessage(playerid, -1, "Tą komendę może wpisać tylko Administrator!"): SendClientMessage(playerid, -1, "Auta stworzone za pomocą komendy /v zostały usunięte!"),
- RespawnUnusedVehicles());
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement