Advertisement
Dayrion

Untitled

May 7th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.14 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zmcd>
  3. #include <sscanf2>
  4.  
  5. #define DIALOG_PRENDRE_MOTO 283
  6. #define DIALOG_PRENDRE_VOITURE 284
  7. #define DIALOG_PRENDRE_CAMION 285
  8.  
  9. CMD:coffre(playerid, params[])
  10. {
  11.     new veh = GetPlayerVehicleID(playerid), pname[MPN],
  12.     Float:x, Float:y, Float:z, Float:dist, Float:closedist=4, closestveh;
  13.     GetPlayerName(playerid, pname, sizeof(pname));
  14.    
  15.     static faire[25];
  16.    
  17.     if(pInfo[playerid][VehicleOwner] == 9999 && pInfo[playerid][VehicleOwner2] == 9999 && pInfo[playerid][VehicleOwner3] == 9999) return SCM(playerid, -1, ROUGEC"> Erreur:"BLANC" Vous n'avez pas de véhicule.");
  18.     for(new i=1; i < MAX_CARS; i++)
  19.     {
  20.         if(i != veh && GetVehiclePos(i, x, y, z))
  21.         {
  22.             dist = GetPlayerDistanceFromPoint(playerid, x, y, z);
  23.             if(dist < closedist)
  24.             {
  25.                 closedist = dist;
  26.                 closestveh = i;
  27.             }
  28.         }
  29.     }
  30.     if(pInfo[playerid][VehicleOwner] == closestveh || pInfo[playerid][VehicleOwner2] == closestveh || pInfo[playerid][VehicleOwner3] == closestveh || pInfo[playerid][Admin] > 5)
  31.     {
  32.         new string[1032];
  33.         if(sscanf(params, "s[20]", faire)) return SCM(playerid, -1, BLEUC"> Utilisation:"BLANC" /coffre [(p)rendre(a)rme ; (d)eposer(a)rme ; (p)rendre(ca)nnabis ; (d)eposer(ca)nnabis]");
  34.         if(strcmp(faire, "info", true) == 0)
  35.         {
  36.             if(vTrunk[closestveh] == 0) return SCM(playerid, -1, ROUGEC"> Erreur:"BLANC" Le coffre n'est pas ouvert.");
  37.             if(Moto(veh))
  38.             {
  39.                 new stringPrendreArme[300];
  40.                 SCM(playerid, -1, "Voici le contenu de votre coffre:");
  41.                 format(string, sizeof(string), "Slot 1: %s - (Munitions: %d)", GunName[vInfo[closestveh][Slot1]], vInfo[closestveh][Muni1]);
  42.                 strcat(stringPrendreArmeVeh, string);
  43.                 SCM(playerid, -1, string);
  44.                 return 1;
  45.             }
  46.             if(Voiture(veh))
  47.             {
  48.                 new stringPrendreArme[300];
  49.                 SCM(playerid, -1, "Voici le contenu de votre coffre:");
  50.                 format(string, sizeof(string), "Slot 1: %s - (Munitions: %d)", GunName[vInfo[closestveh][Slot1]], vInfo[closestveh][Muni1]);
  51.                 SCM(playerid, -1, string);
  52.                 strcat(stringPrendreArmeVeh, string);
  53.                 format(string, sizeof(string), "Slot 2: %s - (Munitions: %d)", GunName[vInfo[closestveh][Slot2]], vInfo[closestveh][Muni2]);
  54.                 SCM(playerid, -1, string);
  55.                 strcat(stringPrendreArmeVeh, string);
  56.                 format(string, sizeof(string), "Slot 3: %s - (Munitions: %d)", GunName[vInfo[closestveh][Slot3]], vInfo[closestveh][Muni3]);
  57.                 SCM(playerid, -1, string);
  58.                 strcat(stringPrendreArmeVeh, string);
  59.                 format(string, sizeof(string), "Cannabis: %d Coke: %d Matos: %d", vInfo[closestveh][Cannabis], vInfo[closestveh][Cocaine], vInfo[closestveh][Matos]);
  60.                 SCM(playerid, -1, string);
  61.                 return 1;
  62.             }
  63.             if(Camion(veh))
  64.             {
  65.                 new stringPrendreArme[300];
  66.                 SCM(playerid, -1, "Voici le contenu de votre coffre:");
  67.                 format(string, sizeof(string), "Slot 1: %s - (Munitions: %d)", GunName[vInfo[closestveh][Slot1]], vInfo[closestveh][Muni1]);
  68.                 SCM(playerid, -1, string);
  69.                 strcat(stringPrendreArmeVeh, string);
  70.                 format(string, sizeof(string), "Slot 2: %s - (Munitions: %d)", GunName[vInfo[closestveh][Slot2]], vInfo[closestveh][Muni2]);
  71.                 SCM(playerid, -1, string);
  72.                 strcat(stringPrendreArmeVeh, string);
  73.                 format(string, sizeof(string), "Slot 3: %s - (Munitions: %d)", GunName[vInfo[closestveh][Slot3]], vInfo[closestveh][Muni3]);
  74.                 SCM(playerid, -1, string);
  75.                 strcat(stringPrendreArmeVeh, string);
  76.                 format(string, sizeof(string), "Slot 4: %s - (Munitions: %d)", GunName[vInfo[closestveh][Slot4]], vInfo[closestveh][Muni4]);
  77.                 SCM(playerid, -1, string);
  78.                 strcat(stringPrendreArmeVeh, string);
  79.                 format(string, sizeof(string), "Slot 5: %s - (Munitions: %d)", GunName[vInfo[closestveh][Slot5]], vInfo[closestveh][Muni5]);
  80.                 SCM(playerid, -1, string);
  81.                 strcat(stringPrendreArmeVeh, string);
  82.                 format(string, sizeof(string), "Cannabis: %d Coke: %d Matos: %d", vInfo[closestveh][Cannabis], vInfo[closestveh][Cocaine], vInfo[closestveh][Matos]);
  83.                 SCM(playerid, -1, string);
  84.                 strcat(stringPrendreArmeVeh, string);
  85.                 return 1;
  86.             }
  87.         if(strcmp(faire, "prendrearme", true) == 0)
  88.         {
  89.             if(Moto(veh))
  90.             {
  91.                 ShowPlayerDialog(playerid, DIALOG_PRENDRE_MOTO, DIALOG_STYLE_LIST, "Prendre une arme", stringPrendreArmeVeh, "Ok", "Quitter");
  92.             }
  93.             if(Voiture(veh))
  94.             {
  95.                 ShowPlayerDialog(playerid, DIALOG_PRENDRE_VOITURE, DIALOG_STYLE_LIST, "Prendre une arme", stringPrendreArmeVeh, "Ok", "Quitter");
  96.             }
  97.             if(Camion(veh))
  98.             {
  99.                 ShowPlayerDialog(playerid, DIALOG_PRENDRE_CAMION, DIALOG_STYLE_LIST, "Prendre une arme", stringPrendreArmeVeh, "Ok", "Quitter");
  100.             }
  101.         }
  102.     }
  103.     else SCM(playerid, -1, ROUGEC"> Erreur:"BLANC" Le véhicule ne vous appartient pas.");
  104.     return 1;
  105. }
  106.  
  107. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  108. {
  109.     if(dialogid==DIALOG_PRENDRE_VOITURE)
  110.     {
  111.         if(response == 1)
  112.         {
  113.             new Float:x, Float:y, Float:z, Float:dist, Float:closedist=4, closestveh;
  114.             for(new i=1; i < MAX_CARS; i++)
  115.             {
  116.                 if(i != veh && GetVehiclePos(i, x, y, z))
  117.                 {
  118.                     dist = GetPlayerDistanceFromPoint(playerid, x, y, z);
  119.                     if(dist < closedist)
  120.                     {
  121.                         closedist = dist;
  122.                         closestveh = i;
  123.                     }
  124.                 }
  125.             }
  126.             switch(listitem)
  127.             {
  128.                 case 0: GivePlayerWeapon(playerid, GunName[vInfo[closestveh][Slot1]], vInfo[closestveh][Muni1]);
  129.                 case 1: GivePlayerWeapon(playerid, GunName[vInfo[closestveh][Slot2]], vInfo[closestveh][Muni2]);
  130.                 case 2: GivePlayerWeapon(playerid, GunName[vInfo[closestveh][Slot3]], vInfo[closestveh][Muni3]);
  131.             }
  132.         }
  133.     }
  134.     if(dialogid==DIALOG_PRENDRE_CAMION)
  135.     {
  136.         if(response == 1)
  137.         {
  138.             new Float:x, Float:y, Float:z, Float:dist, Float:closedist=4, closestveh;
  139.             for(new i=1; i < MAX_CARS; i++)
  140.             {
  141.                 if(i != veh && GetVehiclePos(i, x, y, z))
  142.                 {
  143.                     dist = GetPlayerDistanceFromPoint(playerid, x, y, z);
  144.                     if(dist < closedist)
  145.                     {
  146.                         closedist = dist;
  147.                         closestveh = i;
  148.                     }
  149.                 }
  150.             }
  151.             switch(listitem)
  152.             {
  153.                 case 0: GivePlayerWeapon(playerid, GunName[vInfo[closestveh][Slot1]], vInfo[closestveh][Muni1]);
  154.                 case 1: GivePlayerWeapon(playerid, GunName[vInfo[closestveh][Slot2]], vInfo[closestveh][Muni2]);
  155.                 case 2: GivePlayerWeapon(playerid, GunName[vInfo[closestveh][Slot3]], vInfo[closestveh][Muni3]);
  156.                 case 1: GivePlayerWeapon(playerid, GunName[vInfo[closestveh][Slot4]], vInfo[closestveh][Muni4]);
  157.                 case 2: GivePlayerWeapon(playerid, GunName[vInfo[closestveh][Slot5]], vInfo[closestveh][Muni5]);
  158.             }
  159.         }
  160.     }
  161.     if(dialogid==DIALOG_PRENDRE_MOTO)
  162.     {
  163.         if(response == 1)
  164.         {
  165.             new Float:x, Float:y, Float:z, Float:dist, Float:closedist=4, closestveh;
  166.             for(new i=1; i < MAX_CARS; i++)
  167.             {
  168.                 if(i != veh && GetVehiclePos(i, x, y, z))
  169.                 {
  170.                     dist = GetPlayerDistanceFromPoint(playerid, x, y, z);
  171.                     if(dist < closedist)
  172.                     {
  173.                         closedist = dist;
  174.                         closestveh = i;
  175.                     }
  176.                 }
  177.             }
  178.             switch(listitem)
  179.             {
  180.                 case 0: GivePlayerWeapon(playerid, GunName[vInfo[closestveh][Slot1]], vInfo[closestveh][Muni1]);
  181.             }
  182.         }
  183.     }
  184.     return 1;
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement