Advertisement
Gireada

Sistem de permis

Sep 18th, 2016
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.58 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <zcmd>
  4.  
  5. #define Permise "Permise/%s.ini"
  6.  
  7. new Permis[MAX_PLAYERS], Exam[MAX_PLAYERS], examveh[MAX_PLAYERS];
  8. new Float:Scoala[] = {1025.4070,-1551.1061,13.5502}; //Coordonatele scolii
  9.  
  10. new Float:ExamCP[0][3] =
  11. {
  12.     {0.000, 0.000, 0.000},
  13.     {1034.9841,-1559.0972,12.9315},
  14.     {1034.8450,-1708.3129,12.9540},
  15.     {1295.3475,-1713.5033,12.9473},
  16.     {1295.5015,-1848.9913,12.9391},
  17.     {1184.2592,-1850.2012,12.9736},
  18.     {1062.6892,-1838.3940,13.0227},
  19.     {919.1100,-1766.6110,12.9547},
  20.     {919.1310,-1577.0212,12.9465},
  21.     {1031.4899,-1570.5385,12.9359},
  22.     {1019.7754,-1540.8235,13.0815}
  23.  
  24. };
  25.  
  26. forward TimerVehicul();
  27.  
  28. public OnFilterScriptInit()
  29. {
  30.     SetTimer("TimerVehicul", 1000, 1);
  31.     return 1;
  32. }
  33.  
  34. public OnPlayerConnect(playerid)
  35. {
  36.     new file[MAX_PLAYER_NAME+13];
  37.     format(file, MAX_PLAYER_NAME, "Permise/%s.ini", pName(playerid));
  38.     if(!dini_Exists(file))
  39.     {
  40.         dini_Create(file);
  41.         dini_IntSet(file,"Permis",0);
  42.         Permis[playerid] = 0;
  43.     }
  44.     if(dini_Exists(file))
  45.     {
  46.         Permis[playerid] = dini_Int(file,"Permis");
  47.     }
  48.     return 1;
  49. }
  50.  
  51. public OnPlayerStateChange(playerid, newstate, oldstate)
  52. {
  53.     if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
  54.     {
  55.         if(Permis[playerid] == 0 && Exam[playerid] == 0)
  56.         {
  57.             SendClientMessage(playerid, -1, "Nu stii sa conduci. Nu ai permis. Dute la scoala de soferi");
  58.             RemovePlayerFromVehicle(playerid);
  59.             SetPlayerCheckpoint(playerid, Scoala[0], Scoala[1], Scoala[2], 3.0);
  60.         }
  61.     }
  62.     if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
  63.     {
  64.         if(Exam[playerid] >= 1)
  65.         {
  66.             Picat(playerid);
  67.         }  
  68.     }  
  69.     return 1;
  70. }
  71.  
  72. stock Picat(playerid)
  73. {
  74.     Exam[playerid] = 0;
  75.     SendClientMessage(playerid, -1, "Ai picat examenul ca te-ai dat jos din vehicul");
  76.     DestroyVehicle(examveh[playerid]);
  77.     DisablePlayerCheckpoint(playerid);
  78. }
  79.  
  80. stock pName(playerid)
  81. {
  82.     new name[MAX_PLAYER_NAME];
  83.     GetPlayerName(playerid,name,sizeof(name));
  84.     return name;
  85. }
  86.  
  87. CMD:exam(playerid,command[])
  88. {
  89.     if(!(IsPlayerInRangeOfPoint(playerid, 2.0, Scoala[0], Scoala[1], Scoala[2]))) return SendClientMessage(playerid, -1, "Nu esti la scoala de soferi");
  90.     if(Permis[playerid] != 0) return SendClientMessage(playerid, -1, "Ai deja premis");
  91.     new Float:x, Float:y, Float:z;
  92.     GetPlayerPos(playerid, x, y, z);
  93.     examveh[playerid] = CreateVehicle(405, x, y, z, 0.000, -1, -1, -1);
  94.     Exam[playerid] = 1;
  95.     PutPlayerInVehicle(playerid, examveh[playerid], 0);
  96.     SetPlayerCheckpoint(playerid, ExamCP[Exam[playerid]][0], ExamCP[Exam[playerid]][1], ExamCP[Exam[playerid]][2], 2.0);
  97.     SendClientMessage(playerid, -1, "Ai inceput examenul pentru permis. Urmareste checkpoint-urile cu atentie");
  98.     return 1;
  99. }
  100.  
  101. public OnPlayerEnterCheckpoint(playerid)
  102. {
  103.     if(Exam[playerid] >= 1)
  104.     {
  105.         if(Exam[playerid] == sizeof(ExamCP))
  106.         {
  107.             new file[MAX_PLAYER_NAME+13];
  108.             format(file, MAX_PLAYER_NAME, "Permise/%s.ini", pName(playerid));
  109.             DisablePlayerCheckpoint(playerid);
  110.             SendClientMessage(playerid, -1, "Felicitari. Ai luat permisul de conducere");
  111.             Permis[playerid] = 1;
  112.             dini_IntSet(file,"Permis",Permis[playerid]);
  113.             RemovePlayerFromVehicle(playerid);
  114.             DestroyVehicle(examveh[playerid]);
  115.             Exam[playerid] = 0;
  116.             return 1;
  117.         }
  118.         Exam[playerid]++;
  119.         SetPlayerCheckpoint(playerid, ExamCP[Exam[playerid]][0], ExamCP[Exam[playerid]][1], ExamCP[Exam[playerid]][2], 2.0);
  120.     }
  121.     return 1;
  122. }
  123. public TimerVehicul()
  124. {
  125.     for(new i = 0; i < MAX_PLAYERS; i++)
  126.     {
  127.         if(Exam[i] > 0)
  128.         {
  129.             new Float:Vviata;
  130.             GetVehicleHealth(examveh[i], Vviata);
  131.             if(Vviata < 750)
  132.             {
  133.                 Picat(i);
  134.             }
  135.         }
  136.     }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement