Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Includes:
- #include <a_samp>
- #include <crashdetect>
- #include <mapandreas>
- #include <regex>
- #include <sscanf2>
- #include <YSF>
- #include <YSI\y_ini>
- #include <YSI\y_iterate>
- #include <zcmd>
- native WP_Hash(buffer[], len, const str[]);
- // Macros:
- #undef INI_String
- #if defined _inc_sscanf && 0
- #define INI_String(%1,%2,%3) \
- if(!strcmp((%1), name, false) && !sscanf(value, "s["#%3"]", %2)) return;
- #else
- #define INI_String(%1,%2,%3) \
- if(!strcmp((%1), name, false)) return strcpy(%2, value, %3)
- #endif
- #define function%0(%1) \
- forward %0(%1); \
- public %0(%1)
- #define Timer::
- #if !defined INTERPOLATIONTIME
- #define INTERPOLATIONTIME \
- 8000
- #endif
- #if !defined INI_WriteOneThing_INT
- #define INI_WriteOneThing_INT(%0,%1,%2,%3) \
- new INI: %0; \
- %0 = INI_Open(Path(playerid)); \
- INI_SetTag(%0, %1); \
- INI_WriteInt(%0, %2, %3); \
- INI_Close(%0)
- #endif
- #define PATH \
- "/Users/%s.ini"
- enum {
- DIALOG_REG = 50,
- DIALOG_LOGIN,
- DIALOG_SUCC,
- };
- enum pInfo {
- pCash,
- pAdmin,
- pKills,
- pDeaths,
- pPass[129],
- };
- // Variables:
- new vehicle;
- new STR_[128];
- new STR_2[128];
- new text_[100];
- new Float: Position[4];
- new Name[MAX_PLAYER_NAME];
- new RegEx: AntiAdvertisement;
- new bool: IsPlayerLoggedIn[MAX_PLAYERS];
- new bool: IsPlayerRegistered[MAX_PLAYERS];
- new bool: Commanded[MAX_VEHICLES];
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new Set_CameraPos_Timer[MAX_PLAYERS];
- new PlayerText3D: Time3DText[MAX_PLAYERS];
- new gVehicleNames[212][] = {
- "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perennial", "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 1", "Previon",
- "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster",
- "Admiral", "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer 2", "Turismo",
- "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
- "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic",
- "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre",
- "Rustler", "ZR-350", "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 A", "Hotring Racer B", "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", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan",
- "Blade", "Freight", "Streak", "Vortex", "Vincent", "Bullet", "Clover", "Sadler",
- "Firetruck LA", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit",
- "Utility", "Nevada", "Yosemite", "Windsor", "Monster A", "Monster B", "Uranus", "Jester",
- "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna",
- "Bandito", "Freight Flat", "Streak Carriage", "Kart", "Mower", "Duneride", "Sweeper",
- "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400", "Newsvan",
- "Tug", "Trailer 3", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Freight Carriage",
- "Trailer 3", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LSPD)", "Police Car (SFPD)",
- "Police Car (LVPD)", "Police Ranger", "Picador", "S.W.A.T. Van", "Alpha", "Phoenix", "Glendale",
- "Sadler", "Luggage Trailer A", "Luggage Trailer B", "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;
- if(Commanded[vehicleid]) {
- 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;
- }
- stock Path(playerid) {
- new STR[128];
- format(STR, sizeof(STR), PATH, PlayerName(playerid));
- return STR;
- }
- stock CheckLoginOrRegister(playerid) {
- format(STR_, sizeof(STR_), "Witaj z powrotem %s.\nMasz już konto na tym serwerze, więc pozostaje Ci tylko wpisanie hasła w polu poniżej.", PlayerName(playerid));
- format(STR_2, sizeof(STR_2), "Witaj %s.\nNie masz konta na tym serwerze, więc musisz wpisać hasło w polu poniżej aby kontynuować grę.", PlayerName(playerid));
- switch(fexist(Path(playerid))) {
- case 0: ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "Rejestracja", STR_2, "Zarejestruj", "Wyjdź");
- case 1: {
- INI_ParseFile(Path(playerid), "Load_User_%s", .bExtra = true, .extra = playerid);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Logowanie", STR_, "Zaloguj", "Wyjdź");
- }
- }
- }
- // 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__);
- INI_WriteOneThing_INT(File_, "Dane Graczy", "Cash", GetPlayerMoney(playerid));
- return true;
- }
- function SetCameraPosEx(playerid) {
- SetPlayerInterior(playerid, 0);
- SetPlayerFacingAngle(playerid, 90.0);
- SetPlayerPos(playerid, -1399.0179, 2640.7385, 55.6875);
- SetPlayerCameraPos(playerid, -1410.462402, 2640.7385, 55.6875);
- SetPlayerCameraLookAt(playerid, -1410.462402, 2640.7385, 55.6875, CAMERA_CUT);
- ApplyAnimation(playerid, "RAPPING", "RAP_B_Loop", 4.0, 1, 0, 0, 0, 0);
- }
- function Load_User_Data(playerid, name[], value[]) {
- INI_Int("Cash", PlayerInfo[playerid][pCash]);
- INI_Int("Admin", PlayerInfo[playerid][pAdmin]);
- INI_Int("Kills", PlayerInfo[playerid][pKills]);
- INI_Int("Deaths", PlayerInfo[playerid][pDeaths]);
- INI_String("Password", PlayerInfo[playerid][pPass], 129);
- return true;
- }
- // 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 OnPlayerConnect(playerid) {
- PlayAudioStreamForPlayer(playerid, "http://alldev.eu/mp3/GTAV_Intro.mp3");
- InterpolateCameraPos(playerid, -2662.6853, 1933.7972, 225.7578, -1409.489868, 2642.814697, 58.506492, INTERPOLATIONTIME, CAMERA_MOVE);
- InterpolateCameraLookAt(playerid, -2662.6853, 1933.7972, 225.7578, -1404.622924, 2642.720458, 57.364322, INTERPOLATIONTIME, CAMERA_MOVE);
- ApplyAnimation(playerid, "RAPPING", "RAP_B_Loop", 4.0, 1, 0, 0, 0, 0);
- Set_CameraPos_Timer[playerid] = SetTimerEx("SetCameraPosEx", INTERPOLATIONTIME, false, "d", playerid);
- SetTimerEx("Time", 999, true, "d", playerid);
- SendDeathMessage(INVALID_PLAYER_ID, playerid, 200);
- CheckLoginOrRegister(playerid);
- // SendClientMessage(playerid, -1, "W każdej chwili możesz zalogować się lub zarejestrować. Wystarczy, że wpiszesz /zaloguj bądź /zarejestruj.");
- return true;
- }
- public OnPlayerSpawn(playerid) {
- if(strfind(PlayerName(playerid), "Cynka", true) != -1) {
- SetPlayerSkin(playerid, 233);
- }
- 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_EX[180];
- new STRING[180];
- format(MSG_EX, sizeof(MSG_EX), "%s próbuje reklamować.", PlayerName(playerid));
- regex_replace_exid(text, AntiAdvertisement, MSG_EX, STRING);
- format(STRING, sizeof(STRING), "(ID: %d): %s", playerid, text);
- SendPlayerMessageToAll(playerid, STRING);
- printf("%s: %s", PlayerName(playerid), text);
- return false;
- // Kolory:
- // - zielony: #339933
- // - pomarańczowy: #FF5917
- // - bordowy: #BB0000
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
- format(STR_, sizeof(STR_), "Witaj z powrotem %s.\nMasz już konto na tym serwerze, więc pozostaje Ci tylko wpisanie hasła w polu poniżej.", PlayerName(playerid));
- format(STR_2, sizeof(STR_2), "Witaj %s.\nNie masz konta na tym serwerze, więc musisz wpisać hasło w polu poniżej aby kontynuować grę.", PlayerName(playerid));
- switch(dialogid) {
- case DIALOG_REG: {
- switch(response) {
- case 0: Kick(playerid);
- case 1: {
- new HashPass[129];
- new INI: File_;
- WP_Hash(HashPass, sizeof(HashPass), inputtext);
- File_ = INI_Open(Path(playerid));
- INI_SetTag(File_, "Dane Graczy");
- INI_WriteInt(File_, "Cash", 0);
- INI_WriteInt(File_, "Admin", 0);
- INI_WriteInt(File_, "Kills", 0);
- INI_WriteInt(File_, "Deaths", 0);
- INI_WriteString(File_, "Password", HashPass);
- INI_Close(File_);
- if(!strlen(inputtext)) {
- return ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "Rejestracja", STR_2, "Zarejestruj", "Wyjdź");
- }
- SendClientMessage(playerid, -1, "Rejestracja przebiegła pomyślnie.");
- }
- }
- IsPlayerRegistered[playerid] = true;
- IsPlayerLoggedIn[playerid] = true;
- }
- case DIALOG_LOGIN: {
- switch(response) {
- case 0: Kick(playerid);
- case 1: {
- new HashPass[129];
- WP_Hash(HashPass, sizeof(HashPass), inputtext);
- if(!strcmp(HashPass, PlayerInfo[playerid][pPass], false)) {
- GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
- INI_ParseFile(Path(playerid), "Load_User_%s", .bExtra = true, .extra = playerid);
- SendClientMessage(playerid, -1, "Zalogowano poprawnie.");
- } else {
- return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Logowanie", STR_, "Zaloguj", "Wyjdź");
- }
- }
- }
- IsPlayerRegistered[playerid] = true;
- IsPlayerLoggedIn[playerid] = true;
- }
- }
- return true;
- }
- public OnPlayerCommandPerformed(playerid, cmdtext[], success) {
- if(!success) {
- if(strlen(cmdtext) > 2) {
- strdel(cmdtext, 0, 1);
- for(new i = 400; i <= 611; i++) {
- if(strfind(gVehicleNames[i - 400], cmdtext, true) != -1) {
- CreatePlayerVehicle(playerid, i);
- format(text_, sizeof(text_), "Pojazd o nazwie {FF0000}%s{FFFFFF} zostaje utworzony.", gVehicleNames[i - 400]);
- 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 OnPlayerDeath(playerid, killerid, reason) {
- SendDeathMessage(killerid, playerid, reason);
- /*PlayerInfo[killerid][pKills]++;
- PlayerInfo[playerid][pDeaths]++;*/
- new INI: File_;
- File_ = INI_Open(Path(playerid));
- INI_SetTag(File_, "Dane Graczy");
- if(killerid != INVALID_PLAYER_ID) {
- INI_WriteInt(File_, "Kills", PlayerInfo[killerid][pKills]++);
- SetPlayerScore(killerid, PlayerInfo[killerid][pKills]);
- PlayerInfo[killerid][pCash] += 100;
- GivePlayerMoney(killerid, 100);
- }
- INI_WriteInt(File_, "Deaths", PlayerInfo[playerid][pDeaths]++);
- INI_Close(File_);
- PlayerInfo[playerid][pCash] -= 100;
- GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
- SetPlayerAmmo(playerid, 223, 0);
- return true;
- }
- public OnPlayerDisconnect(playerid, reason) {
- // new INI: File_;
- // File_ = INI_Open(Path(playerid));
- if(!IsPlayerConnected(playerid)) {
- DeletePlayer3DTextLabel(playerid, Time3DText[playerid]), KillTimer(Set_CameraPos_Timer[playerid]);
- // INI_SetTag(File_, "Dane Graczy");
- // INI_WriteInt(File_, "Cash", GetPlayerMoney(playerid));
- // INI_Close(File_);
- }
- // else {
- // INI_WriteOneThing_INT(File_, "Dane Graczy", "Cash", GetPlayerMoney(playerid));
- // }
- // IsPlayerLoggedIn[playerid] = false;
- // IsPlayerRegistered[playerid] = false;
- SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
- return true;
- }
- public OnGameModeExit() {
- return regex_delete(AntiAdvertisement) && true;
- }
- // Commands:
- // CMD:zaloguj(playerid) {
- // if(IsPlayerLoggedIn[playerid] == true) {
- // return SendClientMessage(playerid, -1, "Komenda /zaloguj została już przez Ciebie wpisana. Chcesz zalogować się jeszcze raz?");
- // }
- // CheckLoginOrRegister(playerid);
- // return true;
- // }
- // CMD:zarejestruj(playerid) {
- // if(IsPlayerRegistered[playerid] == true) {
- // return SendClientMessage(playerid, -1, "Komenda /zarejestruj została już przez Ciebie wpisana. Chcesz zarejestrować się jeszcze raz?");
- // }
- // CheckLoginOrRegister(playerid);
- // return true;
- // }
- CMD:v(playerid, params[]) {
- new GetVehicleModelVariable;
- GetVehicleModelVariable = GetVehicleModelIDByName(params);
- delete_free_space(params);
- if(isnull(params)) return SendClientMessage(playerid, -1, "Wpisz /v nazwa_pojazdu");
- 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_);
- else SendClientMessage(playerid, -1, "Zła nazwa pojazdu!");
- return true;
- }
- CMD:respawn(playerid) {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Tą komendę może wpisać tylko Administrator!");
- // else if(strfind(PlayerName(playerid), "Shiny", true) != -1) {
- RespawnUnusedVehicles();
- // }
- return true;
- }
- CMD:flip(playerid) {
- new Float: x, Float: y, Float: z, Float: Angle;
- if(IsPlayerInAnyVehicle(playerid)) {
- GetPlayerPos(playerid, x, y, z);
- GetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
- SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z + 1);
- SetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement