Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This Filterscript was created by Sgt (Sascha).
- It was made for SA-MP.com.
- Everyone may use this script, however you may not claim it as your own!
- Editing or removing this credit lines is strictly forbidden!
- */
- #define FILTERSCRIPT
- #include <a_samp>
- #define COLOR_RED 0xAC0404AA
- #define COLOR_GREEN 0x39CC00AA
- #define COLOR_GREY 0x7F7F7FAA
- enum PlayerSaves
- {
- InPickUp,
- Step,
- Vehicle,
- Float:VH,
- CP
- }
- new PlayerData[MAX_PLAYERS][PlayerSaves];
- new sgt_vehicle[MAX_VEHICLES];
- new sgt_pickup;
- new Float:DLCP[][3] =
- {
- {-2139.1184,-67.6470,34.8747},
- {-2164.3535,-5.3747,34.8748},
- {-2147.4089,141.9391,34.8747},
- {-2145.1216,203.2645,34.9041},
- {-2240.3752,210.3592,34.8759},
- {-2249.6257,299.2788,34.8670},
- {-2267.1807,379.7694,33.6897},
- {-2226.7854,451.8703,34.7200},
- {-2224.2454,491.4290,34.7199},
- {-2203.1504,505.9410,34.7199},
- {-2017.6952,502.7208,34.7195},
- {-1999.1963,568.5953,34.7188},
- {-2001.2145,717.5591,45.0009},
- {-1921.2731,728.7740,44.9997},
- {-1786.3118,727.6964,34.6941},
- {-1717.1865,727.5161,24.4405},
- {-1576.4340,725.9528,6.9685},
- {-1562.2461,644.9578,6.7419},
- {-1561.7367,538.1397,6.7341},
- {-1623.6094,433.2332,6.7355},
- {-1735.0300,323.9233,6.7353},
- {-1797.1927,362.7714,16.7668},
- {-1828.9827,389.4973,16.7243},
- {-1864.4146,323.8641,25.1619},
- {-1893.4323,148.3535,37.9035},
- {-1908.6934,-61.4659,37.9390},
- {-1918.5394,-144.3143,37.9450},
- {-1957.4513,-280.2197,37.8157},
- {-2011.4530,-320.0841,34.8930},
- {-2013.9233,-303.9021,35.2562},
- {-2002.5878,-265.7924,35.0847},
- {-2003.1021,-125.2738,35.4138},
- {-2004.1389,-78.6670,34.8729},
- {-2028.7639,-67.5475,34.8747},
- {-2047.0619,-82.0102,34.8706},
- {-2084.7534,-95.2673,34.8683},
- {-2076.9590,-84.0764,34.8686}
- };
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("Driving License v0.6 by Sgt aka Sascha");
- print("--------------------------------------\n");
- sgt_pickup = CreatePickup(1239, 23, -2033.4329,-117.4139,1035.1719, -1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print("Shutting down Sgt's Driving License v0.6");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- PlayerData[playerid][InPickUp] = 0;
- PlayerData[playerid][Step] = 0;
- PlayerData[playerid][CP] = -1;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(PlayerData[playerid][Step] > 1)
- {
- SendClientMessage(playerid, COLOR_RED, "You've failed your driving test.");
- }
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- if(sgt_vehicle[vehicleid] == 1)
- {
- DestroyVehicle(vehicleid);
- }
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- if(sgt_vehicle[vehicleid] == 1)
- {
- DestroyVehicle(vehicleid);
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- if(PlayerData[playerid][Step] >= 1)
- {
- PlayerData[playerid][Vehicle] = GetPlayerVehicleID(playerid);
- GetVehicleHealth(GetPlayerVehicleID(playerid), PlayerData[playerid][VH]);
- SendClientMessage(playerid, COLOR_GREEN, "Drive to the first checkpoint and follow the following ones");
- PlayerData[playerid][Step] = 2;
- SetPlayerRaceCheckpoint(playerid, 0, -2048.1689,-83.5252,34.8684, -2139.1184,-67.6470,34.8747, 3.00);
- PlayerData[playerid][CP] = 0;
- return 1;
- }
- else if(PlayerData[playerid][Step] == 0)
- {
- if(!IsDLFree(GetPlayerVehicleID(playerid)))
- {
- new string[100], pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(string, sizeof(string), "SgtDL/%s.sgt", pname);
- if(!fexist(string))
- {
- RemovePlayerFromVehicle(playerid);
- SendClientMessage(playerid, COLOR_RED, "You need a driving license to drive the vehicle! (SF Driving School)");
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- if(PlayerData[playerid][Step] == 1 && !IsPlayerInAnyVehicle(playerid))
- {
- new v = CreateVehicle(551,-2026.1503,-94.4133,34.8685,90.0000,-1,-1,300);
- sgt_vehicle[v] = 1;
- SendClientMessage(playerid, COLOR_GREEN, "Get into the vehicle and follow the checkpoints.");
- DisablePlayerCheckpoint(playerid);
- }
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == PlayerData[playerid][Vehicle] && PlayerData[playerid][Step] >= 2)
- {
- if(PlayerData[playerid][CP] <= 35)
- {
- new n = PlayerData[playerid][CP];
- new n2 = PlayerData[playerid][CP] + 1;
- SetPlayerRaceCheckpoint(playerid, 0, DLCP[n][0], DLCP[n][1], DLCP[n][2], DLCP[n2][0], DLCP[n2][1], DLCP[n2][2], 2.00);
- PlayerData[playerid][CP]++;
- }
- else if(PlayerData[playerid][CP] == 36)
- {
- new n = PlayerData[playerid][CP];
- SetPlayerRaceCheckpoint(playerid, 1, DLCP[n][0], DLCP[n][1], DLCP[n][2], DLCP[n][0], DLCP[n][1], DLCP[n][2], 2.00);
- PlayerData[playerid][CP]++;
- }
- else
- {
- DisablePlayerRaceCheckpoint(playerid);
- new v = GetPlayerVehicleID(playerid);
- new Float:vhp;
- GetVehicleHealth(v, vhp);
- new Float:Dif = ((PlayerData[playerid][VH] / 10) - (vhp / 10));
- PlayerData[playerid][CP] = -1;
- if(Dif <= 2)
- {
- ShowPlayerDialog(playerid, 138, DIALOG_STYLE_MSGBOX, "Driving License", "Congratulations!\nYou have passed the test and are now\nthe owner of a driving license!", "Close", "");
- SetPVarInt(playerid, "SgtDL", 1);
- }
- else
- {
- ShowPlayerDialog(playerid, 138, DIALOG_STYLE_MSGBOX, "Driving License", "We are sorry.\nYou have failed the driving test.\nPlease try it again, later.", "Close", "");
- SetPVarInt(playerid, "SgtDL", 2);
- }
- }
- }
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- if(pickupid == sgt_pickup)
- {
- if(PlayerData[playerid][InPickUp] == 0)
- {
- PlayerData[playerid][InPickUp] = 1;
- SetTimerEx("OnPlayerLeavePickUp", 5000, false, "i", playerid);
- new pname[MAX_PLAYER_NAME], string[100];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(string, sizeof(string), "SgtDL/%s.sgt", pname);
- if(fexist(string)) return SendClientMessage(playerid, COLOR_GREY, "You already have a driving license.");
- else ShowPlayerDialog(playerid, 137, DIALOG_STYLE_MSGBOX, "Driving License", "Welcome Sir!\nYou don't have got a driving license yet.\nIf you would like to get one, click onto\n'Continue'", "Continue", "Cancel");
- }
- }
- return 1;
- }
- forward OnPlayerLeavePickUp(playerid);
- public OnPlayerLeavePickUp(playerid)
- {
- PlayerData[playerid][InPickUp] = 0;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 137)
- {
- if(response)
- {
- PlayerData[playerid][Step] = 1;
- SendClientMessage(playerid, COLOR_GREY, "Walk out onto the car park and go into the checkpoint.");
- SetPlayerCheckpoint(playerid, -2028.2227,-91.8504,33.3203, 2.00);
- }
- }
- else if(dialogid == 138)
- {
- if(GetPVarInt(playerid, "SgtDL") == 2)
- {
- SetPVarInt(playerid, "SgtDL", 0);
- PlayerData[playerid][Step] = 0;
- RemovePlayerFromVehicle(playerid);
- DestroyVehicle(PlayerData[playerid][Vehicle]);
- }
- else if(GetPVarInt(playerid, "SgtDL") == 1)
- {
- new pname[MAX_PLAYER_NAME], string[100];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(string, sizeof(string), "SgtDL/%s.sgt", pname);
- new File:sgt_file = fopen(string, io_write);
- new day, year, month;
- getdate(year, month, day);
- format(string, sizeof(string), "%s is owning this driving license since: %d/%d/%d\r\n", pname, day, month, year);
- fwrite(sgt_file, string);
- fclose(sgt_file);
- PlayerData[playerid][Step] = 0;
- RemovePlayerFromVehicle(playerid);
- DestroyVehicle(PlayerData[playerid][Vehicle]);
- }
- }
- return 1;
- }
- stock IsDLFree(vehicleid)
- {
- new m = GetVehicleModel(vehicleid);
- if(m == 509 || m == 481 || m == 510 || m == 462 || m == 448 || m == 592 || m == 577 || m == 511 || m == 512
- || m == 593 || m == 520 || m == 448 || m == 553 || m == 476 || m == 519 || m == 460 || m == 513 || m == 548
- || m == 425 || m == 417 || m == 487 || m == 488 || m == 497 || m == 469 || m == 563 || m == 447)
- {
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment