Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #define COLOR_RED 0xC00000FF //Red Color
- #define COLOR_GREEN 0x009647FF //Green Color
- #define COLOR_BLUE 0x0093BBFF //Blue Color
- #define VEHICLE_ID 426 //Current Vehicle is Premier
- #define VEH_DAMAGE 900
- #define MINI_SPEED 50
- #define MAX_SPEEDING 5
- new ncar[MAX_PLAYERS];
- enum pinfo{
- bool:license,
- CP,
- speeding,
- };
- new gPlayer[MAX_PLAYERS][pinfo];
- new currenthealth[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n======================================");
- print(" TRL Driving Test By Rage Loaded!!");
- print("======================================\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n======================================");
- print(" TRL Driving Test By Rage UNLoaded!!");
- print("======================================\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- CMD:drivingtest(playerid,params[]){ //Making the command
- new money;
- money=GetPlayerMoney(playerid);
- if(gPlayer[playerid][license]==1) return SendClientMessage(playerid, COLOR_RED,"You already have a driving license");
- if(money<2000) return SendClientMessage(playerid, COLOR_RED,"You must have $2000 to begin driving test");
- gPlayer[playerid][CP]=1;
- SendClientMessage(playerid, COLOR_GREEN,"Instruction: Destination Saved. Make your way to the red marker to begin driving test.");
- SetPlayerCheckpoint(playerid,1271.5436,-1545.9067,13.5648,4.0);
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- if(gPlayer[playerid][CP]==1){
- DisablePlayerCheckpoint(playerid);
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Driving Test Approval","Are you sure you want to begin your driving test?","Yes","No");
- }
- else if(gPlayer[playerid][CP]==2){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=3;
- SetPlayerCheckpoint(playerid,1295.2511,-1602.4054,13.3828,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==3){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=4;
- SetPlayerCheckpoint(playerid,1295.0060,-1654.1892,13.3828,4.0);
- }
- else if(gPlayer[playerid][CP]==4){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=5;
- SetPlayerCheckpoint(playerid,1295.4152,-1708.8987,13.3828,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==5){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=6;
- SetPlayerCheckpoint(playerid,1256.7621,-1709.6104,13.3828,4.0);
- }
- else if(gPlayer[playerid][CP]==6){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=7;
- SetPlayerCheckpoint(playerid,1201.9366,-1709.9708,13.3828,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==7){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=8;
- SetPlayerCheckpoint(playerid,1156.5132,-1709.4323,13.7813,4.0);
- }
- else if(gPlayer[playerid][CP]==8){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=9;
- SetPlayerCheckpoint(playerid,1109.7393,-1709.3726,13.3828,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==9){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=10;
- SetPlayerCheckpoint(playerid,1040.7274,-1709.6338,13.3828,4.0);
- }
- else if(gPlayer[playerid][CP]==10){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=11;
- SetPlayerCheckpoint(playerid,1040.4951,-1673.3054,13.3828,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==11){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=12;
- SetPlayerCheckpoint(playerid,1039.7523,-1614.5819,13.3828,4.0);
- }
- else if(gPlayer[playerid][CP]==12){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=13;
- SetPlayerCheckpoint(playerid,1050.4260,-1574.9825,13.3892,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==13){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=14;
- SetPlayerCheckpoint(playerid,1118.1987,-1574.7905,13.3966,4.0);
- }
- else if(gPlayer[playerid][CP]==14){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=15;
- SetPlayerCheckpoint(playerid,1147.7310,-1584.6283,13.3395,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==15){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=16;
- SetPlayerCheckpoint(playerid,1147.5430,-1629.2367,13.7813,4.0);
- }
- else if(gPlayer[playerid][CP]==16){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=17;
- SetPlayerCheckpoint(playerid,1147.7458,-1704.4374,13.7813,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==17){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=18;
- SetPlayerCheckpoint(playerid,1181.2891,-1714.7313,13.5279,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==18){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=19;
- SetPlayerCheckpoint(playerid,1239.9648,-1715.3239,13.3828,4.0);
- }
- else if(gPlayer[playerid][CP]==19){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=20;
- SetPlayerCheckpoint(playerid,1286.8646,-1714.1796,13.3828,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==20){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=21;
- SetPlayerCheckpoint(playerid,1300.1241,-1670.1123,13.3828,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==21){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=22;
- SetPlayerCheckpoint(playerid,1300.7595,-1625.7065,13.3828,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==22){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=23;
- SetPlayerCheckpoint(playerid,1300.3802,-1570.8374,13.3828,4.0);
- }
- else if(gPlayer[playerid][CP]==23){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=24;
- SetPlayerCheckpoint(playerid,1271.1886,-1570.4200,13.3828,4.0);
- IsSpeeding(playerid);
- }
- else if(gPlayer[playerid][CP]==24){
- DisablePlayerCheckpoint(playerid);
- gPlayer[playerid][CP]=25;
- SetPlayerCheckpoint(playerid,1271.5436,-1545.9067,13.5648,4.0);
- }
- else if(gPlayer[playerid][CP]==25){
- DisablePlayerCheckpoint(playerid);
- new Float:health;
- currenthealth[playerid] = GetVehicleHealth(ncar[playerid],health);
- if(currenthealth[playerid]>VEH_DAMAGE && gPlayer[playerid][speeding]<MAX_SPEEDING){
- SendClientMessage(playerid, COLOR_BLUE,"Congratulations! You have successfully acquired your driving license");
- gPlayer[playerid][license] = true;
- }
- else{
- SendClientMessage(playerid, COLOR_RED,"Sorry! But you failed driving test, Try again to get your driving license");
- }
- return 1;
- }
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid==1){
- if(response){
- gPlayer[playerid][CP]=2;
- SetPlayerCheckpoint(playerid,1282.1848,-1574.9357,13.3828,4.0);
- ncar[playerid]=AddStaticVehicle(VEHICLE_ID,1271.5435,-1545.9233,13.1358,177.9724,3,8);
- PutPlayerInVehicle(playerid, ncar[playerid], 0);
- SendClientMessage(playerid, COLOR_GREEN,"Instruction: Your driving test has started. Drive carefully on the right lane(Make your way through Checkpoints)");
- }
- else{
- SendClientMessage(playerid,COLOR_RED,"Rejected: It seems you don't want to have driving test");
- }
- }
- return 1;
- }
- GetVehicleSpeed(vehicleid)
- {
- new Float:Vx, Float:Vy, Float:Vz;
- GetVehicleVelocity(vehicleid, Vx, Vy, Vz);
- new Float:rtn;
- rtn = floatsqroot(floatpower(Vx*100,2) + floatpower(Vy*100,2));
- rtn = floatsqroot(floatpower(rtn,2) + floatpower(Vz*100,2));
- return floatround(rtn);
- }
- stock IsSpeeding(playerid)
- {
- if(GetVehicleSpeed(ncar[playerid])>MINI_SPEED)
- {
- gPlayer[playerid][speeding]++;
- SendClientMessage(playerid, COLOR_RED, "Slow down! Or You will Fail your driving test!");
- }
- }
Add Comment
Please, Sign In to add comment