Advertisement
Gireada09

Sistem Control Complex

Dec 31st, 2012
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.60 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. #define Dialog_Control 999999
  5. #define Dialog_Radio5 999998
  6.  
  7. forward TimerBaterie(playerid);
  8. forward RadioUpdate(vehicleid, station);
  9. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  10.  
  11. new Baterie[MAX_VEHICLES];
  12. new motor[MAX_VEHICLES], lumini[MAX_VEHICLES], alarma[MAX_VEHICLES], capota[MAX_VEHICLES], portbagaj[MAX_VEHICLES], radiostation[MAX_VEHICLES];
  13. new Menu:RadioMenu;
  14. new engine,lights,alarm,doors,bonnet,boot,objective;
  15. new updatebaterie;
  16.  
  17. #pragma tabsize 0
  18. public OnFilterScriptInit()
  19. {
  20.     ManualVehicleEngineAndLights();
  21.     RadioMenu = CreateMenu("RadioMenu", 2, 200.0, 100.0, 150.0, 150.0);
  22.     AddMenuItem(RadioMenu, 0, "1");
  23.     AddMenuItem(RadioMenu, 0, "2");
  24.     AddMenuItem(RadioMenu, 0, "3");
  25.     AddMenuItem(RadioMenu, 0, "4");
  26.     AddMenuItem(RadioMenu, 0, "5");
  27.     AddMenuItem(RadioMenu, 0, "6");
  28.  
  29.     AddMenuItem(RadioMenu, 1, "Radio Hit");
  30.     AddMenuItem(RadioMenu, 1, "Radio Wish");
  31.     AddMenuItem(RadioMenu, 1, "Contact FM");
  32.     AddMenuItem(RadioMenu, 1, "R Hip-Hop");
  33.     AddMenuItem(RadioMenu, 1, "R Populara");
  34.     AddMenuItem(RadioMenu, 1, "Stop");
  35.     for(new carid=0;carid<MAX_VEHICLES;carid++)
  36.     {
  37.         Baterie[carid] = 200;
  38.         motor[carid] = 0;
  39.         lumini[carid] = 0;
  40.         alarma[carid] = 0;
  41.         capota[carid] = 0;
  42.         portbagaj[carid] = 0;
  43.     }
  44.     updatebaterie = SetTimer("TimerBaterie", 30000, 1);
  45.     print("\n--------------------------------------");
  46.     print(" Baterie Vehicul by Gireada");
  47.     print("--------------------------------------\n");
  48.     return 1;
  49. }
  50.  
  51. public OnFilterScriptExit()
  52. {
  53.     KillTimer(updatebaterie);
  54.     return 1;
  55. }
  56.  
  57. CMD:baterie(playerid, params[])
  58. {
  59.     new carid = GetPlayerVehicleID(playerid), string[256];
  60.     format(string, sizeof(string), "* {FF0000}%d %{C2A2DA} Baterie.", Baterie[carid]);
  61.     ProxDetector(30.0, playerid, string, 0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
  62.     return 1;
  63. }
  64.  
  65. CMD:controlv(playerid, params[])
  66. {
  67.     if(!IsPlayerInAnyVehicle(playerid))
  68.     {
  69.         SendClientMessage(playerid, 0xCC0000FF, "EROARE : Trebuie sa fii intr-un vehicul pentru a folosi aceasta comanda.");
  70.     }
  71.     else
  72.     {
  73.         SendClientMessage(playerid, 0xCC0000FF, "Comenzi : /alarma /motor /lumini /radio /portbagaj /capota.");
  74.     }
  75.     return 1;
  76. }
  77.  
  78. CMD:radio(playerid, params[])
  79. {
  80.     if(!IsPlayerInAnyVehicle(playerid))
  81.     {
  82.         SendClientMessage(playerid, 0xCC0000FF, "EROARE : Trebuie sa fii intr-un vehicul pentru a folosi aceasta comanda.");
  83.     }
  84.     else
  85.     {
  86.         ShowMenuForPlayer(RadioMenu, playerid);
  87.     }
  88.     return 1;
  89. }
  90.  
  91. CMD:motor(playerid, params[])
  92. {
  93.     new veh = GetPlayerVehicleID(playerid);
  94.     if(motor[veh] == 0)
  95.     {
  96.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  97.         SetVehicleParamsEx(veh,true,lights,alarm,doors,bonnet,boot,objective);
  98.         motor[veh] = 1;
  99.     }
  100.     else if(motor[veh] == 1)
  101.     {
  102.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  103.         SetVehicleParamsEx(veh,false,lights,alarm,doors,bonnet,boot,objective);
  104.         motor[veh] = 0;
  105.     }
  106.     return 1;
  107. }
  108.  
  109. CMD:lumini(playerid, params[])
  110. {
  111.     new veh = GetPlayerVehicleID(playerid);
  112.     if(lumini[veh] == 0)
  113.     {
  114.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  115.         SetVehicleParamsEx(veh,engine,true,alarm,doors,bonnet,boot,objective);
  116.         lumini[veh] = 1;
  117.     }
  118.     else if(lumini[veh] == 1)
  119.     {
  120.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  121.         SetVehicleParamsEx(veh,engine,false,alarm,doors,bonnet,boot,objective);
  122.         lumini[veh] = 0;
  123.     }
  124.     return 1;
  125. }
  126.  
  127. CMD:capota(playerid, params[])
  128. {
  129.     new veh = GetPlayerVehicleID(playerid);
  130.     if(capota[veh] == 0)
  131.     {
  132.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  133.         SetVehicleParamsEx(veh,engine,lights,alarm,doors,true,boot,objective);
  134.         capota[veh] = 1;
  135.     }
  136.     else if(capota[veh] == 1)
  137.     {
  138.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  139.         SetVehicleParamsEx(veh,engine,lights,alarm,doors,false,boot,objective);
  140.         capota[veh] = 0;
  141.     }
  142.     return 1;
  143. }
  144.  
  145. CMD:portbagaj(playerid, params[])
  146. {
  147.     new veh = GetPlayerVehicleID(playerid);
  148.     if(portbagaj[veh] == 0)
  149.     {
  150.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  151.         SetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,true,objective);
  152.         portbagaj[veh] = 1;
  153.     }
  154.     else if(portbagaj[veh] == 1)
  155.     {
  156.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  157.         SetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,false,objective);
  158.         portbagaj[veh] = 0;
  159.     }
  160.     return 1;
  161. }
  162.  
  163. CMD:alarma(playerid, params[])
  164. {
  165.     new veh = GetPlayerVehicleID(playerid);
  166.     if(alarma[veh] == 0)
  167.     {
  168.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  169.         SetVehicleParamsEx(veh,engine,lights,true,doors,bonnet,boot,objective);
  170.         alarma[veh] = 1;
  171.     }
  172.     else if(alarma[veh] == 1)
  173.     {
  174.         GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  175.         SetVehicleParamsEx(veh,engine,lights,false,doors,bonnet,boot,objective);
  176.         alarma[veh] = 0;
  177.     }
  178.     return 1;
  179. }
  180.  
  181. public RadioUpdate(vehicleid, station)
  182. {
  183.     for(new p=0; p<MAX_PLAYERS; p++)
  184.     {
  185.         if(IsPlayerInVehicle(p, vehicleid))
  186.         {
  187.             if(station == 0)
  188.             {
  189.                 StopAudioStreamForPlayer(p);
  190.             }
  191.             if(station == 1)
  192.             {
  193.                 PlayAudioStreamForPlayer(p, "http://www.radio-hit.ro/asculta.m3u");
  194.             }
  195.             if(station == 2)
  196.             {
  197.                 PlayAudioStreamForPlayer(p, "http://www.radiowish.ro/live.m3u");
  198.             }
  199.             if(station == 3)
  200.             {
  201.                 PlayAudioStreamForPlayer(p, "http://www.contactfm.ro/listen.pls");
  202.             }
  203.             if(station == 4)
  204.             {
  205.                 PlayAudioStreamForPlayer(p, "http://radioromanian.net/hiphop.pls");
  206.             }
  207.             if(station == 5)
  208.             {
  209.                 PlayAudioStreamForPlayer(p, "http://radioromanian.net/popular.pls");
  210.             }
  211.         }
  212.         return 1;
  213.     }
  214.     return 1;
  215. }
  216.  
  217. public TimerBaterie(playerid)
  218. {
  219.     new veh = GetPlayerVehicleID(playerid);
  220.    // new engine,lights,alarm,doors,bonnet,boot,objective;
  221.     GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
  222.     for(new carid=0;carid<MAX_VEHICLES;carid++)
  223.     {
  224.         if(motor[carid] == 1)
  225.         {
  226.             Baterie[veh] += 1;
  227.         }
  228.         else if(lumini[carid] == 1 && motor[carid] == 1)
  229.         {
  230.             Baterie[veh] -= 4;Baterie[veh] += 1;
  231.         }
  232.     }
  233.     return 1;
  234. }
  235.  
  236. stock IsVehicleOccupied(vehicleid)
  237. {
  238.   for(new i = 0; i < MAX_PLAYERS; i++)
  239.     if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
  240.       return 1;
  241.   return 0;
  242.  
  243. }
  244.  
  245. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  246. {
  247.     if(IsPlayerConnected(playerid))
  248.     {
  249.         new Float:posx, Float:posy, Float:posz;
  250.         new Float:oldposx, Float:oldposy, Float:oldposz;
  251.         new Float:tempposx, Float:tempposy, Float:tempposz;
  252.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  253.         for(new i = 0; i < MAX_PLAYERS; i++)
  254.         {
  255.             if(IsPlayerConnected(i))
  256.             {
  257.                 GetPlayerPos(i, posx, posy, posz);
  258.                 tempposx = (oldposx -posx);
  259.                 tempposy = (oldposy -posy);
  260.                 tempposz = (oldposz -posz);
  261.                 if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
  262.                 {
  263.                     if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  264.                     {
  265.                         SendClientMessage(i, col1, string);
  266.                     }
  267.                     else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  268.                     {
  269.                         SendClientMessage(i, col2, string);
  270.                     }
  271.                     else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  272.                     {
  273.                         SendClientMessage(i, col3, string);
  274.                     }
  275.                     else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  276.                     {
  277.                         SendClientMessage(i, col4, string);
  278.                     }
  279.                     else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  280.                     {
  281.                         SendClientMessage(i, col5, string);
  282.                     }
  283.                 }
  284.             }
  285.         }
  286.     }
  287.     return 1;
  288. }
  289.  
  290. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  291. {
  292.     if(radiostation[vehicleid] == 1)
  293.     {
  294.         PlayAudioStreamForPlayer(playerid, "http://www.radio-hit.ro/asculta.m3u");
  295.     }
  296.     if(radiostation[vehicleid] == 2)
  297.     {
  298.         PlayAudioStreamForPlayer(playerid, "http://www.radiowish.ro/live.m3u");
  299.     }
  300.     if(radiostation[vehicleid] == 3)
  301.     {
  302.         PlayAudioStreamForPlayer(playerid, "http://www.contactfm.ro/listen.pls");
  303.     }
  304.     if(radiostation[vehicleid] == 4)
  305.     {
  306.         PlayAudioStreamForPlayer(playerid, "http://radioromanian.net/hiphop.pls");
  307.     }
  308.     if(radiostation[vehicleid] == 5)
  309.     {
  310.         PlayAudioStreamForPlayer(playerid, "http://radioromanian.net/popular.pls");
  311.     }
  312.     return 1;
  313. }
  314.  
  315. public OnPlayerExitVehicle(playerid, vehicleid)
  316. {
  317.     StopAudioStreamForPlayer(playerid);
  318.     return 1;
  319. }
  320.  
  321. public OnVehicleDeath(vehicleid, killerid)
  322. {
  323.     radiostation[vehicleid] = 0;
  324.     return 1;
  325. }
  326.  
  327. public OnPlayerDeath(playerid, killerid, reason)
  328. {
  329.     StopAudioStreamForPlayer(playerid);
  330.     return 1;
  331. }
  332.  
  333. public OnPlayerSelectedMenuRow(playerid, row)
  334. {
  335.     new veh = GetPlayerVehicleID(playerid), sendername[50], string[256];
  336.     if(GetPlayerMenu(playerid) == RadioMenu)
  337.     {
  338.         switch(row)
  339.         {
  340.             case 0:
  341.             {
  342.                 radiostation[veh] = 1;
  343.                 GetPlayerName(playerid, sendername, sizeof(sendername));
  344.                 format(string, sizeof(string), "* {FF0000}%s{C2A2DA} Comuta radioul pe postul Radio Hit.", sendername);
  345.                 ProxDetector(30.0, playerid, string, 0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
  346.                 RadioUpdate(veh, 1);
  347.                 HideMenuForPlayer(RadioMenu, playerid);
  348.             }
  349.             case 1:
  350.             {
  351.                 radiostation[veh] = 2;
  352.                 GetPlayerName(playerid, sendername, sizeof(sendername));
  353.                 format(string, sizeof(string), "* {FF0000}%s{C2A2DA} Comuta radioul pe postul Radio WISH.", sendername);
  354.                 ProxDetector(30.0, playerid, string, 0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
  355.                 RadioUpdate(veh, 2);
  356.                 HideMenuForPlayer(RadioMenu, playerid);
  357.             }
  358.             case 2:
  359.             {
  360.                 radiostation[veh] = 3;
  361.                 GetPlayerName(playerid, sendername, sizeof(sendername));
  362.                 format(string, sizeof(string), "* {FF0000}%s{C2A2DA} Comuta radioul pe postul Contact FM.", sendername);
  363.                 ProxDetector(30.0, playerid, string, 0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
  364.                 RadioUpdate(veh, 3);
  365.                 HideMenuForPlayer(RadioMenu, playerid);
  366.             }
  367.             case 3:
  368.             {
  369.                 radiostation[veh] = 4;
  370.                 GetPlayerName(playerid, sendername, sizeof(sendername));
  371.                 format(string, sizeof(string), "* {FF0000}%s{C2A2DA} Comuta radioul pe postul Radio Romania Hip-Hop.", sendername);
  372.                 ProxDetector(30.0, playerid, string, 0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
  373.                 RadioUpdate(veh, 4);
  374.                 HideMenuForPlayer(RadioMenu, playerid);
  375.             }
  376.             case 4:
  377.             {
  378.                 radiostation[veh] = 5;
  379.                 GetPlayerName(playerid, sendername, sizeof(sendername));
  380.                 format(string, sizeof(string), "* {FF0000}%s{C2A2DA} Comuta radioul pe postul Radio Romania Populara.", sendername);
  381.                 ProxDetector(30.0, playerid, string, 0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
  382.                 RadioUpdate(veh, 5);
  383.                 HideMenuForPlayer(RadioMenu, playerid);
  384.             }
  385.             case 5:
  386.             {
  387.                 radiostation[veh] = 0;
  388.                 format(string, sizeof(string), "* {FF0000}%s{C2A2DA} Opreste Radioul.", sendername);
  389.                 ProxDetector(30.0, playerid, string, 0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA,0xC2A2DAAA);
  390.                 RadioUpdate(veh, 0);
  391.                 HideMenuForPlayer(RadioMenu, playerid);
  392.             }
  393.         }
  394.     }
  395.     return 1;
  396. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement