Advertisement
Guest User

OxiSpray Version 1.0

a guest
Sep 17th, 2014
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.36 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <sscanf2>
  6.  
  7.  
  8. new bool:g_Timer;
  9. new bool:ASpray[MAX_PLAYERS];
  10. new bool:OSpray[MAX_PLAYERS];
  11. new bool:SentSpray[MAX_PLAYERS];
  12. new SenderID;
  13. new id;
  14.  
  15. enum {
  16.  
  17.     DIALOG_CAR_SPRAY
  18. }
  19.  
  20.  
  21. public OnFilterScriptInit()
  22. {
  23.     print("  **************************");
  24.     print(" ");
  25.     print("  Successfully Loaded");
  26.     print("  OxiSprays Version 1.0");
  27.     print(" ");
  28.     print("  Created by OxigEN.");
  29.     print("  19/09/2014");
  30.     print(" ");
  31.     print("  **************************");
  32.     return 1;
  33. }
  34.  
  35. public OnFilterScriptExit()
  36. {
  37.     print("  **************************");
  38.     print(" ");
  39.     print("  Successfully UNLoaded");
  40.     print("  OxiSprays Version 1.0");
  41.     print(" ");
  42.     print("  Created by OxigEN.");
  43.     print("  19/09/2014");
  44.     print(" ");
  45.     print("  **************************");
  46.     return 1;
  47. }
  48.  
  49.  
  50. CMD:spray(playerid, params[])
  51. {
  52.     if(!IsPlayerAdmin(playerid)) return 0;
  53.     else GivePlayerWeapon(playerid, 41, 99999);
  54.     return 1;
  55. }
  56.  
  57. forward SprayTimer(playerid);
  58. public SprayTimer(playerid)
  59. {
  60.     for(new i = 0; i < MAX_VEHICLES; i++)
  61.     {
  62.         new Float:x, Float:y, Float:z;
  63.         if(!GetVehiclePos(i, x, y, z)) continue;
  64.         if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
  65.         {
  66.             g_Timer = false;
  67.             return ShowPlayerDialog(playerid, DIALOG_CAR_SPRAY, DIALOG_STYLE_LIST, "Vehicle Color Change", "Color White\nColor White\nColor Red\nColor Green\nColor Blue\nColor Yellow\nColor Orange\n", "Change", "Exit");
  68.         }
  69.     }
  70.     SendClientMessage(playerid, 0xFF0000FF, "You are not near the vehicle therefore you didn't get the color changing dialog.");
  71.     g_Timer = false;
  72.     ASpray[id] = false;
  73.     SentSpray[id] = false;
  74.     OSpray[playerid] = false;
  75.     return 1;
  76. }
  77.  
  78. CMD:ospray(playerid, params[])
  79. {
  80.     new string[128];
  81.     if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF0000FF, "SYNTAX: /OSpray [ID]");
  82.     else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "The ID specified is invalid.");
  83.     else if(OSpray[id] == true) return SendClientMessage(playerid, 0xFF0000FF, "Someone already sent an offer to the ID specified.");
  84.     else if(SentSpray[playerid] == true) return SendClientMessage(playerid, 0xFF0000FF, "You already sent an offer to someone.");
  85.     else
  86.     {
  87.         new Float:x, Float:y, Float:z;
  88.         GetPlayerPos(playerid, x, y, z);
  89.         if(IsPlayerInRangeOfPoint(id, 10, x, y, z))
  90.         {
  91.             format(string, sizeof(string), "You have sent %s(%d) an offer to paint their vehicle, Please wait for them to accept it.", GetName(id), id);
  92.             SendClientMessage(playerid, 0xFF0000FF, string);
  93.  
  94.             format(string, sizeof(string), "You have received an offer to paint your vehicle from %s(%d)\nTo accept it write /ASpray [ID].", GetName(playerid), playerid);
  95.             SendClientMessage(id, 0xFF0000FF, string);
  96.  
  97.             OSpray[id] = true;
  98.             SentSpray[playerid] = true;
  99.             SenderID = playerid;
  100.         }
  101.         else return
  102.             SendClientMessage(playerid, 0xFF0000FF, "àéï àó àçã ìéãê");
  103.     }
  104.     return 1;
  105. }
  106.  
  107. CMD:aspray(playerid, params[])
  108. {
  109.     new string[128];
  110.     if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF0000FF, "SYNTAX: /ASpray [ID]");
  111.     if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "The ID specified is invalid.");
  112.     else if(id != SenderID) return SendClientMessage(playerid, 0xFF0000FF, "The ID you've entered didn't send you an offer to change your vehicle's color.");
  113.     else if(OSpray[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "No one has sent you an offer to change your vehicle's color.");
  114.     else
  115.     {
  116.         format(string, sizeof(string), "You have accepted %s(%d)'s offer to paint your vehicle!", GetName(id), id);
  117.         SendClientMessage(playerid, 0xFF0000FF, string);
  118.        
  119.         format(string, sizeof(string), "%s(%d) has accepted your offer to paint their vehicle!", GetName(playerid), playerid);
  120.         SendClientMessage(id, 0xFF0000FF, string);
  121.        
  122.         ASpray[playerid] = true;
  123.         SentSpray[id] = false;
  124.         OSpray[playerid] = false;
  125.     }
  126.     return 1;
  127. }
  128.  
  129. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  130. {
  131.     if(newkeys & KEY_FIRE && GetPlayerWeapon(playerid) == 41)
  132.     {
  133.         if(IsPlayerInAnyVehicle(playerid)) return SetPlayerArmedWeapon(playerid, 0);
  134.         else
  135.         {
  136.             if(ASpray[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "No one has accepted your offer to change their vehicle's color.");
  137.             else
  138.             {
  139.                 new Float:x, Float:y, Float:z;
  140.                 for(new i = 0; i < MAX_VEHICLES; i++)
  141.                 {
  142.                     if(!GetVehiclePos(i, x, y, z)) continue;
  143.                     if(IsPlayerInRangeOfPoint(playerid, 10, x, y, z))
  144.                     {
  145.                         if(g_Timer == false)
  146.                         {
  147.                             SetTimerEx("SprayTimer", 15000, false, "d", playerid);
  148.                             g_Timer = true;
  149.                             return SendClientMessage(playerid, 0xFF0000FF, "You have started to paint the vehicle. Please do this for 15 seconds.");
  150.                         }
  151.                         else
  152.                         {
  153.                             return SendClientMessage(playerid, 0xFF0000FF, "There is already a timer running, Please wait while the current timer ends.");
  154.                         }
  155.                     }
  156.                 }
  157.                 SendClientMessage(playerid, 0xFF0000FF, "You are not near any vehicle!");
  158.             }
  159.         }
  160.     }
  161.     return 1;
  162. }
  163.  
  164. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  165. {
  166.     new Float:x, Float:y, Float:z;
  167.     if(dialogid == DIALOG_CAR_SPRAY)
  168.     {
  169.         if(!response) return SendClientMessage(playerid, 0xFF0000FF, "You chose to decline the vehicle color changing dialog.");
  170.         if(response)
  171.         {
  172.             switch(listitem)
  173.             {
  174.                 case 0:
  175.                 {
  176.                     for(new i = 0; i < MAX_VEHICLES; i++)
  177.                     {
  178.                         GetVehiclePos(i, x, y, z);
  179.                         if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
  180.                         {
  181.                             ChangeVehicleColor(i, 1, 1);
  182.                             ASpray[id] = false;
  183.                             SentSpray[id] = false;
  184.                             OSpray[playerid] = false;
  185.                             GivePlayerMoney(playerid, -500);
  186.                             RepairVehicle(i);
  187.                         }
  188.                     }
  189.                 }
  190.                 case 1:
  191.                 {
  192.                     for(new i = 0; i < MAX_VEHICLES; i++)
  193.                     {
  194.                         GetVehiclePos(i, x, y, z);
  195.                         if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
  196.                         {
  197.                             ChangeVehicleColor(i, 0, 0);
  198.                             ASpray[id] = false;
  199.                             SentSpray[id] = false;
  200.                             OSpray[playerid] = false;
  201.                             GivePlayerMoney(playerid, -500);
  202.                             RepairVehicle(i);
  203.                         }
  204.                     }
  205.                 }
  206.                 case 2:
  207.                 {
  208.                     for(new i = 0; i < MAX_VEHICLES; i++)
  209.                     {
  210.                         GetVehiclePos(i, x, y, z);
  211.                         if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
  212.                         {
  213.                             ChangeVehicleColor(i, 3, 3);
  214.                             ASpray[id] = false;
  215.                             SentSpray[id] = false;
  216.                             OSpray[playerid] = false;
  217.                             GivePlayerMoney(playerid, -500);
  218.                             RepairVehicle(i);
  219.                         }
  220.                     }
  221.                 }
  222.                 case 3:
  223.                 {
  224.                     for(new i = 0; i < MAX_VEHICLES; i++)
  225.                     {
  226.                         GetVehiclePos(i, x, y, z);
  227.                         if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
  228.                         {
  229.                             ChangeVehicleColor(i, 16, 16);
  230.                             ASpray[id] = false;
  231.                             SentSpray[id] = false;
  232.                             OSpray[playerid] = false;
  233.                             GivePlayerMoney(playerid, -500);
  234.                             RepairVehicle(i);
  235.                         }
  236.                     }
  237.                 }
  238.                 case 4:
  239.                 {
  240.                     for(new i = 0; i < MAX_VEHICLES; i++)
  241.                     {
  242.                         GetVehiclePos(i, x, y, z);
  243.                         if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
  244.                         {
  245.                             ChangeVehicleColor(i, 7, 7);
  246.                             ASpray[id] = false;
  247.                             SentSpray[id] = false;
  248.                             OSpray[playerid] = false;
  249.                             GivePlayerMoney(playerid, -500);
  250.                             RepairVehicle(i);
  251.                         }
  252.                     }
  253.                 }
  254.                 case 5:
  255.                 {
  256.                     for(new i = 0; i < MAX_VEHICLES; i++)
  257.                     {
  258.                         GetVehiclePos(i, x, y, z);
  259.                         if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
  260.                         {
  261.                             ChangeVehicleColor(i, 6, 6);
  262.                             ASpray[id] = false;
  263.                             SentSpray[id] = false;
  264.                             OSpray[playerid] = false;
  265.                             GivePlayerMoney(playerid, -500);
  266.                             RepairVehicle(i);
  267.                         }
  268.                     }
  269.                 }
  270.                 case 6:
  271.                 {
  272.                     for(new i = 0; i < MAX_VEHICLES; i++)
  273.                     {
  274.                         GetVehiclePos(i, x, y, z);
  275.                         if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
  276.                         {
  277.                             ChangeVehicleColor(i, 158, 158);
  278.                             ASpray[id] = false;
  279.                             SentSpray[id] = false;
  280.                             OSpray[playerid] = false;
  281.                             GivePlayerMoney(playerid, -500);
  282.                             RepairVehicle(i);
  283.                         }
  284.                     }
  285.                 }
  286.             }
  287.         }
  288.         return 1;
  289.     }
  290.     return 0;
  291. }
  292.  
  293. stock GetName(playerid)
  294. {
  295.     new Name[MAX_PLAYER_NAME];
  296.  
  297.     GetPlayerName(playerid, Name, sizeof(Name));
  298.  
  299.     return Name;
  300. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement