Advertisement
michalmonday

RC models filterscript (pre-alpha version)

Jan 15th, 2017
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 57.06 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3.  
  4. #define COLOR_RED "950000"
  5. #define COLOR_GREEN "008500"
  6. #define COLOR_BLUE "407bef"
  7. #define COLOR_ORANGE "f28b41"
  8.  
  9. #define DEFAULT_COLOR 0xF7F694FF
  10.  
  11. #define DIALOG_RC_MODELS 1
  12. #define DIALOG_EXTRA_FEATURES 2
  13. #define DIALOG_BOMB_TYPE 3
  14. #define DIALOG_NAVIGATION_TYPE 4
  15.  
  16. #define RC_SHOP_POS_X 2498.5
  17. #define RC_SHOP_POS_Y -1643.1
  18. #define RC_SHOP_POS_Z 13.8
  19.  
  20. #define POS_HP_BAR_X 555.0 //upper left(?) but not sure
  21. #define POS_HP_BAR_Y 230.0//370.0
  22.  
  23. #define MAX_SLOTS 3
  24. #define NO_SLOTS_AVAILABLE 255 //kind of "invalid code" for the function which checks which slot is free
  25.  
  26. #define MAX_RC_MODELS 4
  27. new rc_names[MAX_RC_MODELS][16] = {"Bandit", "Baron", "Goblin", "Minitank"};
  28. new rc_model_ids[MAX_RC_MODELS] = {441,464,501,564};
  29. new rc_prices[MAX_RC_MODELS] = {0, 100, 200, 300};
  30.  
  31. #define MAX_BOMB_TYPES 6
  32. new bomb_names[MAX_BOMB_TYPES][22] = {"", "Small bomb", "Bomb", "Large bomb", "Huge bomb", "Small nuclear bomb"};
  33. new Float:bomb_ranges[MAX_BOMB_TYPES] = {0.0, 3.0, 10.0, 20.0, 50.0, 200.0};
  34. new bomb_prices[MAX_BOMB_TYPES] = {0, 100, 200, 300, 400, 500}; //needs to be implemented (replace switch at OnDialog with loops)
  35.  
  36. #define BOMB_NUCLEAR_THRESHOLD 5
  37. new Float:BOMB_VELOCITY_DIV = 15.0; // lower value -> higher velocity
  38. new bool: BOMB_AFFECT_CARS = true;
  39. new bool: BOMB_HP_AND_FLASH_EFFECTS = true; //flash only for nukes
  40.  
  41. #define MAX_NAVIGATION_TYPES 3
  42. new navigation_names[MAX_NAVIGATION_TYPES][22] = {"Bluetooth", "2.4Ghz Remote control", "Satelite support"};
  43. new Float:navigation_ranges[MAX_NAVIGATION_TYPES] = {30.0, 300.0, 6000.0};
  44. new navigation_prices[MAX_NAVIGATION_TYPES] = {0, 100, 200};
  45. #define SATELITE_THRESHOLD 2 //only satelite will allow full map control + ability to control from different interior/virtual world (because of the range measurements in interiors)
  46.  
  47. enum PLAYER_DATA
  48. {
  49.     //player related
  50.     bool:IS_CONTROLLING, //is player currently driving any rc model
  51.     SLOT_CONTROLLED, //which rc model is being driven
  52.     bool:HAS_HP_MONITOR, //bool to know whether to use SetupTimerEx or it was already setup
  53.     MONITOR, //timer for checking hp (to allow DestroyVehicle() and update hp bars)
  54.  
  55.     //rc model related
  56.     bool:OWNED[MAX_SLOTS], //is the slot free or taken
  57.     bool:DEPLOYED[MAX_SLOTS], // deployed, not deployed
  58.     TYPE[MAX_SLOTS], // bandit/goblin etc (0-3)
  59.     VEH_ID[MAX_SLOTS], // 0-2000
  60.     HP[MAX_SLOTS],
  61.     INTERIOR[MAX_SLOTS],
  62.     VIRTUAL_WORLD[MAX_SLOTS],
  63.  
  64.     //extra_features
  65.     //every new has to be added in ResetExtraFeatures(), PickExtraFeatures() where its name has to be set, in OnDialogResponse() and AppendExtraFeatures() - list function
  66.     BOMB[MAX_SLOTS],
  67.     //add Satelite communication (full map range)
  68.     NAVIGATION[MAX_SLOTS]
  69.  
  70.     //could add the faction of the owner (so anti-rc devices won't detect own rcs)
  71.  
  72. }
  73.  
  74.  
  75.  
  76. new rc_data[MAX_PLAYERS][PLAYER_DATA];
  77. new last_bought_slot[MAX_PLAYERS]; //needed to determine to which slot assign the purchased extra features (ShowDialog function doesn't pass a custom param so it seems to be necessary)
  78.  
  79. new Float:controller_posX[MAX_PLAYERS], Float:controller_posY[MAX_PLAYERS], Float:controller_posZ[MAX_PLAYERS]; //position from which the player started controlling rc
  80. new controller_interior[MAX_PLAYERS], controller_virtual_world[MAX_PLAYERS]; //vars to allow the controller to get back where he was after disconnecting from vehicle or when it gets destroyed
  81.  
  82. enum HP_BAR_RECTANGLES
  83. {
  84.     PlayerText:LABEL[MAX_SLOTS],
  85.     PlayerText:BACKGROUND[MAX_SLOTS],
  86.     PlayerText:INDICATOR[MAX_SLOTS]
  87. }
  88.  
  89. new hp_bar[MAX_PLAYERS][HP_BAR_RECTANGLES];
  90. new PlayerText:Flash[MAX_PLAYERS];
  91. new PlayerText:Display[MAX_PLAYERS];
  92.  
  93.  
  94. public OnFilterScriptInit()
  95. {
  96.     //init hp of the rc models
  97.     new i;
  98.     for(i=0;i<MAX_SLOTS;i++)
  99.     {
  100.         new j;
  101.         for(j=0; j<MAX_PLAYERS; j++)
  102.         {
  103.             rc_data[j][HP][i] = 5000;
  104.         }
  105.     }
  106.  
  107.     //init extra features (strings for dialogs and prices)
  108.  
  109.     print("\n--------------------------------------");
  110.     print("RC Filterscript");
  111.     print("--------------------------------------\n");
  112.  
  113.     //shop label/pickup
  114.     Create3DTextLabel("RC shop\n(/rc buy)\n(/rc help)", 0x008080FF, RC_SHOP_POS_X, RC_SHOP_POS_Y, RC_SHOP_POS_Z + 1.0, 40.0, 0, 0);
  115.     CreatePickup(364, 1, RC_SHOP_POS_X, RC_SHOP_POS_Y, RC_SHOP_POS_Z, 0);
  116.  
  117.     return 1;
  118. }
  119.  
  120. public OnFilterScriptExit()
  121. {
  122.     return 1;
  123. }
  124.  
  125.  
  126. public OnGameModeInit()
  127. {
  128.     return 1;
  129. }
  130.  
  131.  
  132. public OnGameModeExit()
  133. {
  134.  
  135.     return 1;
  136. }
  137.  
  138. public OnPlayerRequestClass(playerid, classid)
  139. {
  140.     return 1;
  141. }
  142.  
  143. public OnPlayerConnect(playerid)
  144. {
  145.     InitHpBars(playerid);
  146.     InitNukeFlash(playerid);
  147.     InitDisplayer(playerid);
  148.     return 1;
  149. }
  150.  
  151. InitDisplayer(playerid)
  152. {
  153.     Display[playerid] = CreatePlayerTextDraw(playerid, 608.0, 415.0,"test");
  154.  
  155.     //PlayerTextDrawUseBox(playerid, Display[playerid],1);      //Toggle whether a textdraw should have a box or not
  156.     //PlayerTextDrawBoxColor(playerid, Display[playerid],0x00000050);       //Set the color of a textdraw's box
  157.     //PlayerTextDrawTextSize(playerid, Display[playerid], 500.0,400.0);//950.0,0.0); //Set the size of a textdraw
  158.  
  159.  
  160.     PlayerTextDrawAlignment(playerid, Display[playerid], 3);
  161.     //PlayerTextDrawBackgroundColor(playerid, Displayer[playerid],0x000000ff);
  162.     PlayerTextDrawFont(playerid, Display[playerid],2);
  163.     PlayerTextDrawLetterSize(playerid, Display[playerid], 0.5 ,1.3);
  164.     //PlayerTextDrawColor(playerid, Display[playerid],0x000000FF);
  165.     //PlayerTextDrawSetOutline(playerid, Display[playerid],1);
  166.     //PlayerTextDrawSetProportional(playerid, Display[playerid],1);
  167.     //PlayerTextDrawSetShadow(playerid, Display[playerid],1);
  168.    
  169. //PlayerTextDrawShow(playerid, Display[playerid]);
  170. }
  171.  
  172. DisplayMessage(playerid, message[], time, color)
  173. {
  174.     PlayerTextDrawColor(playerid, Display[playerid], color);
  175.     PlayerTextDrawSetString(playerid, Display[playerid], message);
  176.     PlayerTextDrawShow(playerid, Display[playerid]);
  177.     SetTimerEx("HideMessage", time, false, "d", playerid); //have to create global variables with last used messages
  178. }
  179.  
  180. forward HideMessage(playerid);
  181. public HideMessage(playerid)
  182. {
  183.     PlayerTextDrawHide(playerid, Display[playerid]);
  184. }
  185.  
  186. /*
  187. ~b~ Blue
  188. ~g~ Green
  189. ~l~ Black
  190. ~p~ Pink
  191. ~r~ Red
  192. ~w~ White
  193. ~y~ Yellow
  194. ~h~ Lighter color
  195. ~s~ Shadow
  196.  
  197. ~d~ Down arrow
  198. ~u~ Up arrow
  199. ~<~ Left arrow
  200. ~>~ Right arrow
  201. ~t~ Rectangle
  202. ~n~ New line
  203.  
  204. special symbols, not used inside ~~ will produce special graphics
  205.  
  206. { question mark
  207. ] wanted level star (only some styles/fonts)
  208. @ inverted exclamation mark
  209. | circle icon
  210. */
  211.  
  212. InitHpBars(playerid)
  213. {
  214.     new Float:x = POS_HP_BAR_X, Float:init_y = POS_HP_BAR_Y, Float:sizeX = 0.569999, Float:sizeY = 4.0;//2.549999;
  215.     new Float:y = init_y;
  216.     new i;
  217.  
  218.  
  219.     for(i=0; i<MAX_SLOTS;i++)
  220.     {
  221.         hp_bar[playerid][BACKGROUND][i] = CreatePlayerTextDraw(playerid, x, y,"..........");
  222.         PlayerTextDrawAlignment(playerid, hp_bar[playerid][BACKGROUND][i],1);
  223.         PlayerTextDrawBackgroundColor(playerid, hp_bar[playerid][BACKGROUND][i],0x000000ff);
  224.         PlayerTextDrawFont(playerid, hp_bar[playerid][BACKGROUND][i],3);
  225.         PlayerTextDrawLetterSize(playerid, hp_bar[playerid][BACKGROUND][i], sizeX, sizeY);
  226.         PlayerTextDrawColor(playerid, hp_bar[playerid][BACKGROUND][i],0x00000033);
  227.         PlayerTextDrawSetOutline(playerid, hp_bar[playerid][BACKGROUND][i],1);
  228.         PlayerTextDrawSetProportional(playerid, hp_bar[playerid][BACKGROUND][i],1);
  229.         PlayerTextDrawSetShadow(playerid, hp_bar[playerid][BACKGROUND][i],1);
  230.  
  231.         y += 20.0;
  232.     }
  233.  
  234.     x += (sizeX/0.5);
  235.     y = init_y + (sizeX/0.5) + (sizeY*2.5);
  236.     sizeX -= (sizeX / 25);
  237.     sizeY -= (sizeY / 2.5);
  238.  
  239.  
  240.     for(i=0; i<MAX_SLOTS;i++)
  241.     {
  242.         hp_bar[playerid][INDICATOR][i] = CreatePlayerTextDraw(playerid, x, y,"..........");
  243.         PlayerTextDrawAlignment(playerid, hp_bar[playerid][INDICATOR][i],1);
  244.         PlayerTextDrawBackgroundColor(playerid, hp_bar[playerid][INDICATOR][i],0x6be1ffff);
  245.         PlayerTextDrawFont(playerid, hp_bar[playerid][INDICATOR][i],3);
  246.         PlayerTextDrawLetterSize(playerid, hp_bar[playerid][INDICATOR][i], sizeX, sizeY);
  247.         PlayerTextDrawColor(playerid, hp_bar[playerid][INDICATOR][i],0x6be1ff33);
  248.         PlayerTextDrawSetOutline(playerid, hp_bar[playerid][INDICATOR][i],1);
  249.         PlayerTextDrawSetProportional(playerid, hp_bar[playerid][INDICATOR][i],1);
  250.         PlayerTextDrawSetShadow(playerid, hp_bar[playerid][INDICATOR][i],1);
  251.  
  252.         y += 20.0;
  253.     }
  254.  
  255.     y = (init_y - 1.0);
  256.     for(i=0; i<MAX_SLOTS;i++)
  257.     {
  258.         y+= 20.0;
  259.         hp_bar[playerid][LABEL][i] = CreatePlayerTextDraw(playerid, x, y,"Test");
  260.         PlayerTextDrawAlignment(playerid, hp_bar[playerid][LABEL][i],1);
  261.         PlayerTextDrawFont(playerid, hp_bar[playerid][LABEL][i],1);
  262.         PlayerTextDrawLetterSize(playerid, hp_bar[playerid][LABEL][i], 0.3, 0.6);
  263.         PlayerTextDrawColor(playerid, hp_bar[playerid][LABEL][i],0xFFFFFFFF);
  264.         PlayerTextDrawSetOutline(playerid, hp_bar[playerid][LABEL][i],1);
  265.     }
  266.  
  267.     return 1;
  268. }
  269.  
  270. InitNukeFlash(playerid)
  271. {
  272.     Flash[playerid] = CreatePlayerTextDraw(playerid, 0.0, 0.0,"FLASHBANG!");//Creates a textdraw.
  273.     PlayerTextDrawUseBox(playerid, Flash[playerid],1);      //Toggle whether a textdraw should have a box or not
  274.     PlayerTextDrawBoxColor(playerid, Flash[playerid],0xffffff50);       //Set the color of a textdraw's box
  275.     PlayerTextDrawTextSize(playerid, Flash[playerid],950.0,0.0);//950.0,0.0); //Set the size of a textdraw
  276.     PlayerTextDrawAlignment(playerid, Flash[playerid],0);       //Set a textdraw's alignment
  277.     PlayerTextDrawBackgroundColor(playerid, Flash[playerid],0xffffffff);        //Adjusts the text draw area background color
  278.     PlayerTextDrawFont(playerid, Flash[playerid],3);            //Set a textdraw's font
  279.     PlayerTextDrawLetterSize(playerid, Flash[playerid],0.0, 70.0);      //Set the size of a textdraw's text
  280.     PlayerTextDrawColor(playerid, Flash[playerid],0xffffff00);      // Color white durp
  281.     PlayerTextDrawSetOutline(playerid, Flash[playerid],1);//Set the outline thickness of a textdraw
  282.     PlayerTextDrawSetProportional(playerid, Flash[playerid],1);     //Set a textdraw's text proportion
  283.     PlayerTextDrawSetShadow(playerid, Flash[playerid],1);       //Toggle a shadow behind a textdraw's text
  284.    
  285.    
  286.     /*
  287.     Flash[playerid] = CreatePlayerTextDraw(playerid, 320.0, 240.0,"FLASHBANG!");//Creates a textdraw.
  288.     PlayerTextDrawUseBox(playerid, Flash[playerid],1);      //Toggle whether a textdraw should have a box or not
  289.     PlayerTextDrawBoxColor(playerid, Flash[playerid],0xffffff50);       //Set the color of a textdraw's box
  290.     PlayerTextDrawTextSize(playerid, Flash[playerid],630.0,0.0);//950.0,0.0); //Set the size of a textdraw
  291.     PlayerTextDrawAlignment(playerid, Flash[playerid],0);       //Set a textdraw's alignment
  292.     PlayerTextDrawBackgroundColor(playerid, Flash[playerid],0xffffffff);        //Adjusts the text draw area background color
  293.     PlayerTextDrawFont(playerid, Flash[playerid],3);            //Set a textdraw's font
  294.     PlayerTextDrawLetterSize(playerid, Flash[playerid],0.0,240.0 * 0.135);      //Set the size of a textdraw's text
  295.     PlayerTextDrawColor(playerid, Flash[playerid],0xffffff00);      // Color white durp
  296.     PlayerTextDrawSetOutline(playerid, Flash[playerid],1);//Set the outline thickness of a textdraw
  297.     PlayerTextDrawSetProportional(playerid, Flash[playerid],1);     //Set a textdraw's text proportion
  298.     PlayerTextDrawSetShadow(playerid, Flash[playerid],1);       //Toggle a shadow behind a textdraw's text
  299.     */
  300.  
  301. }
  302.  
  303. public OnPlayerDisconnect(playerid, reason)
  304. {
  305.     new i;
  306.     for(i=0;i<MAX_SLOTS;i++)
  307.     {
  308.         PlayerTextDrawDestroy(playerid, hp_bar[playerid][BACKGROUND][i]);
  309.         PlayerTextDrawDestroy(playerid, hp_bar[playerid][INDICATOR][i]);
  310.         PlayerTextDrawDestroy(playerid, hp_bar[playerid][LABEL][i]);
  311.         rc_data[playerid][BOMB][i] = 0;
  312.         rc_data[playerid][NAVIGATION][i] = 0;
  313.         rc_data[playerid][OWNED][i] = false;
  314.         rc_data[playerid][DEPLOYED][i] = false;
  315.         rc_data[playerid][HP][i] = 5000;
  316.         rc_data[playerid][INTERIOR][i] = 0;
  317.         rc_data[playerid][VIRTUAL_WORLD][i] = 0;
  318.     }
  319.    
  320.     rc_data[playerid][IS_CONTROLLING] = false;
  321.     rc_data[playerid][HAS_HP_MONITOR] = false;
  322.     KillTimer(rc_data[playerid][MONITOR]);
  323.    
  324.  
  325.     PlayerTextDrawDestroy(playerid, Flash[playerid]);
  326.     return 1;
  327. }
  328.  
  329. public OnPlayerSpawn(playerid)
  330. {
  331.     GivePlayerMoney(playerid, 20000);
  332.  
  333.     return 1;
  334. }
  335.  
  336. /*
  337. SetTimerEx("AngleTest", 500, true, "d", playerid);
  338.  
  339. forward public AngleTest(playerid);
  340. public AngleTest(playerid)
  341. {
  342.  
  343. //#define RC_SHOP_POS_X 2498.5
  344. //#define RC_SHOP_POS_Y -1643.1
  345. //#define RC_SHOP_POS_Z 13.8
  346.  
  347.     new Float:x,Float:y,Float:z, Float:facing_angle;
  348.     GetPlayerPos(playerid,x,y,z);
  349.  
  350.     GetPlayerFacingAngle(playerid, facing_angle);
  351.     new Float: angle = atan2 (x - RC_SHOP_POS_X, RC_SHOP_POS_Y - y) + 180.0;
  352.     new str[64];format(str,sizeof(str),"angle=%.0f facing angle=%.0f", angle, facing_angle);
  353.     SendClientMessage(playerid, -1, str);
  354. }
  355. */
  356.  
  357.  
  358.  
  359. ShowHpBar(playerid, slot, label[])
  360. {
  361.     PlayerTextDrawShow(playerid, hp_bar[playerid][BACKGROUND][slot]);
  362.     PlayerTextDrawSetString(playerid, hp_bar[playerid][INDICATOR][slot],".........."); //background is always the same length
  363.     PlayerTextDrawShow(playerid, hp_bar[playerid][INDICATOR][slot]);
  364.     PlayerTextDrawSetString(playerid, hp_bar[playerid][LABEL][slot], label);
  365.     PlayerTextDrawShow(playerid, hp_bar[playerid][LABEL][slot]);
  366. }
  367.  
  368. HideHpBar(playerid, slot)
  369. {
  370.     PlayerTextDrawHide(playerid, hp_bar[playerid][BACKGROUND][slot]);
  371.     PlayerTextDrawHide(playerid, hp_bar[playerid][INDICATOR][slot]);
  372.     PlayerTextDrawHide(playerid, hp_bar[playerid][LABEL][slot]);
  373. }
  374.  
  375. public OnPlayerDeath(playerid, killerid, reason)
  376. {
  377.     if(rc_data[playerid][IS_CONTROLLING] == true)
  378.     {
  379.         rc_data[playerid][IS_CONTROLLING] = false;
  380.         SetPlayerInterior(playerid, controller_interior[playerid]);
  381.         SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
  382.         SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
  383.     }
  384.     return 1;
  385. }
  386.  
  387. public OnVehicleSpawn(vehicleid)
  388. {
  389.     return 1;
  390. }
  391.  
  392. public OnVehicleDeath(vehicleid, killerid)
  393. {
  394.     return 1;
  395. }
  396.  
  397. public OnPlayerText(playerid, text[])
  398. {
  399.     return 1;
  400. }
  401.  
  402. public OnPlayerCommandText(playerid, cmdtext[])
  403. {
  404.     new cmd[30], params[30], slot, bool:slot_included;
  405.     if(sscanf(cmdtext, "ssd", cmd, params, slot))
  406.     {
  407.         sscanf(cmdtext, "ss", cmd, params);
  408.     }
  409.     else
  410.     {
  411.         slot_included = true;
  412.         slot -= 1; // to let the user have slot 1 as a starting one instead of slot 0
  413.     }
  414.  
  415.  
  416.     if (!strcmp("/rc", cmd, true)) //need to implement inventory here
  417.     {
  418.         if(!strcmp("deploy", params, true) && slot_included == true)
  419.         {
  420.             if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
  421.  
  422.             if(rc_data[playerid][DEPLOYED][slot] == true){DisplayMessage(playerid, "~r~-> ~y~The device is already deployed", 2000, DEFAULT_COLOR); return 1;}
  423.             if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
  424.             if(rc_data[playerid][IS_CONTROLLING] == true){DisplayMessage(playerid, "~r~-> ~y~Disconnect from the device in order to deploy another one", 2000, DEFAULT_COLOR); return 1;}
  425.             new Float:x, Float:y, Float:z;
  426.             GetXYInFrontOfPlayer(playerid, x, y, z, 1.0);
  427.             new vehid = CreateVehicle(rc_model_ids[rc_data[playerid][TYPE][slot]], x, y, z, 82.2873, 0x0, 0x0, -1, 0);
  428.             SetVehicleHealth(vehid, rc_data[playerid][HP][slot]); // hp bar adjusting and DestroyVehicle() functions are relying on 5000 (rcs get destroyed after losing 75hp) so they'd have to be changed
  429.             LinkVehicleToInterior(vehid, GetPlayerInterior(playerid));
  430.             rc_data[playerid][VEH_ID][slot] = vehid;
  431.             rc_data[playerid][DEPLOYED][slot] = true;
  432.  
  433.             ShowHpBar(playerid, slot, rc_names[rc_data[playerid][TYPE][slot]]);
  434.  
  435.             if(rc_data[playerid][HAS_HP_MONITOR] != true)
  436.             {
  437.                 rc_data[playerid][MONITOR] = SetTimerEx("HpMonitor", 200, true, "d", playerid);
  438.             }
  439.             rc_data[playerid][INTERIOR][slot] = GetPlayerInterior(playerid);
  440.             rc_data[playerid][VIRTUAL_WORLD][slot] = GetPlayerVirtualWorld(playerid);
  441.             return 1;
  442.         }
  443.         else if(!strcmp("conceal", params, true) && slot_included == true)
  444.         {
  445.  
  446.             if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
  447.             if(rc_data[playerid][DEPLOYED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~Device is currently not deployed", 2000, DEFAULT_COLOR); return 1;}
  448.             if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
  449.             if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] != slot){DisplayMessage(playerid, "~r~-> ~y~Can't conceal device while controlling another one", 2000, DEFAULT_COLOR); return 1;}
  450.  
  451.             new vehid = rc_data[playerid][VEH_ID][slot];
  452.  
  453.             //distance check (with ability to conceal the veh without need to disconnect from it)
  454.             if(rc_data[playerid][IS_CONTROLLING] == true){if(!IsPlayerInRangeOfPoint(playerid, 5.0, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid])){DisplayMessage(playerid, "~r~-> ~y~The device is too far away", 2000, DEFAULT_COLOR); return 1;}else{if(rc_data[playerid][SLOT_CONTROLLED] == slot){rc_data[playerid][IS_CONTROLLING] = false;}}}
  455.             else {new Float:x, Float:y, Float:z; GetVehiclePos(vehid, x, y, z); if(!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)){DisplayMessage(playerid, "~r~-> ~y~The device is too far away", 2000, DEFAULT_COLOR); return 1;}}
  456.  
  457.             new Float: fHp;
  458.             GetVehicleHealth(vehid, fHp);
  459.             rc_data[playerid][HP][slot] = floatround(fHp);
  460.             DestroyVehicle(vehid);
  461.             rc_data[playerid][DEPLOYED][slot] = false;
  462.  
  463.             HideHpBar(playerid, slot);
  464.             if(PlayerDeployedAny(playerid) != 1){KillTimer(rc_data[playerid][MONITOR]);}
  465.             return 1;
  466.         }
  467.         else if(!strcmp("connect", params, true) && slot_included == true)
  468.         {
  469.             if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
  470.  
  471.             if(rc_data[playerid][DEPLOYED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~Device is currently not deployed", 2000, DEFAULT_COLOR); return 1;}
  472.             if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
  473.             if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == slot){DisplayMessage(playerid, "~r~-> ~y~Connection with the specified device is already established", 2000, DEFAULT_COLOR); return 1;}
  474.             if(rc_data[playerid][IS_CONTROLLING] != true){GetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);} // save the position to global var to get back there at disconnect (but only if player is not controlling rc already - to avoid going back to the position of previous rc model )
  475.             //range check
  476.             new Float:x, Float:y, Float:z;
  477.             GetVehiclePos(rc_data[playerid][VEH_ID][slot], x, y, z);
  478.             if(!IsPlayerInRangeOfPoint(playerid,navigation_ranges[rc_data[playerid][NAVIGATION][slot]],x,y,z)){DisplayMessage(playerid, "~r~-> ~y~Unable to connect. The device is out of range", 2000, DEFAULT_COLOR); return 1;}
  479.             //interior check (not possible to monitor range wihin interior if the range is limited, so here's the check for "satelite threshold" which has infinite - 6000m range)
  480.             if(rc_data[playerid][NAVIGATION][slot] < SATELITE_THRESHOLD && (GetPlayerVirtualWorld(playerid) != rc_data[playerid][VIRTUAL_WORLD][slot] || GetPlayerInterior(playerid) != rc_data[playerid][INTERIOR][slot])){DisplayMessage(playerid, "~r~-> ~y~Unable to connect. The device is out of range", 2000, DEFAULT_COLOR); return 1;}
  481.  
  482.             PutPlayerInVehicle(playerid, rc_data[playerid][VEH_ID][slot], 0);
  483.             rc_data[playerid][IS_CONTROLLING] = true;
  484.             rc_data[playerid][SLOT_CONTROLLED] = slot;
  485.             DisplayMessage(playerid, "~g~-> ~y~Connection established", 700, DEFAULT_COLOR);
  486.  
  487.             controller_interior[playerid] = GetPlayerInterior(playerid);
  488.             controller_virtual_world[playerid] = GetPlayerVirtualWorld(playerid);
  489.             SetPlayerInterior(playerid, rc_data[playerid][INTERIOR][slot]);
  490.             SetPlayerVirtualWorld(playerid, rc_data[playerid][VIRTUAL_WORLD][slot]);
  491.             return 1;
  492.         }
  493.         else if(!strcmp("disconnect", params, true))
  494.         {
  495.             slot = rc_data[playerid][SLOT_CONTROLLED]; // so the slot id input is not necessary
  496.             if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
  497.             if(rc_data[playerid][IS_CONTROLLING] != true){DisplayMessage(playerid, "~r~-> ~y~There are no connections at the moment", 2000, DEFAULT_COLOR); return 1;}
  498.             if(rc_data[playerid][DEPLOYED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~Device is currently not deployed", 2000, DEFAULT_COLOR); return 1;}
  499.             if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
  500.  
  501.  
  502.             rc_data[playerid][IS_CONTROLLING] = false;
  503.             SetPlayerInterior(playerid, controller_interior[playerid]);
  504.             SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
  505.             SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
  506.             DisplayMessage(playerid, "~g~-> ~y~Disconnected successfully", 700, DEFAULT_COLOR);
  507.             return 1;
  508.         }
  509.         else if(!strcmp("list", params, true) && strlen(params) > 0)
  510.         {
  511.             SendClientMessage(playerid, DEFAULT_COLOR, "________________________");
  512.             SendClientMessage(playerid, DEFAULT_COLOR, "List of owned RC devices:");
  513.             new i;
  514.             for(i=0; i<MAX_SLOTS; i++)
  515.             {
  516.                 new str[100];
  517.                 //ternary example    c = ( a == b ) ? d : e;
  518.                 //owned, deployed, type, veh_id
  519.                 if(rc_data[playerid][OWNED][i] == true)
  520.                 {
  521.                      //rc_names[0-3]
  522.                     format(str, sizeof(str), "Slot %d: {F7F694}%s %s %s", i+1, rc_names[rc_data[playerid][TYPE][i]], (rc_data[playerid][DEPLOYED][i] == true) ? ("{008500}Deployed") : (""), AppendExtraFeatures(playerid, i));
  523.  
  524.                     //format(str,sizeof(str), ;
  525.                 }
  526.                 else
  527.                 {
  528.                     format(str, sizeof(str), "Slot %d: -", i+1);
  529.                 }
  530.                 SendClientMessage(playerid, -1, str);
  531.             }
  532.             return 1;
  533.         }
  534.         else if(!strcmp("buy", params, true) && strlen(params) > 0)
  535.         {
  536.             if(IsPlayerInRangeOfPoint(playerid, 5.0, RC_SHOP_POS_X, RC_SHOP_POS_Y, RC_SHOP_POS_Z))
  537.             {
  538.                 new str[100];
  539.                 //format(str_available_rc,sizeof(str_available_rc),"Bandit ($%d)\nBaron ($%d)\nGoblin ($%d)\nMinitank ($%d)", RC_BANDIT_PRICE, RC_BARON_PRICE, RC_GOBLIN_PRICE, RC_MINITANK_PRICE);
  540.                 for(new i=0; i < MAX_RC_MODELS;i++)
  541.                 {
  542.                     new add[50];format(add, sizeof(add), "%s ($%d)\n", rc_names[i], rc_prices[i]);
  543.                     strcat(str,add);
  544.                 }
  545.                 ShowPlayerDialog(playerid, DIALOG_RC_MODELS, DIALOG_STYLE_LIST, "Available devices", str, "Buy", "Cancel");
  546.                 return 1;
  547.             }
  548.             else
  549.             {
  550.                 DisplayMessage(playerid, "~r~-> ~y~You're not in the RC shop", 2000, DEFAULT_COLOR);
  551.                 return 1;
  552.             }
  553.         }
  554.         else if(!strcmp("explode", params, true) && slot_included == true)
  555.         {
  556.             //may adjust this one if more bomb types will be added
  557.             if(rc_data[playerid][BOMB][slot] == 0){DisplayMessage(playerid, "~r~-> ~y~The specified device doesn't have any bomb installed", 2000, DEFAULT_COLOR); return 1;}
  558.  
  559.             if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
  560.             if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
  561.             if(rc_data[playerid][DEPLOYED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~Device is currently not deployed", 2000, DEFAULT_COLOR); return 1;}
  562.  
  563.             new Float:x, Float:y, Float:z;
  564.             if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == slot)
  565.             {
  566.                 SetPlayerInterior(playerid, controller_interior[playerid]);
  567.                 SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
  568.                 SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
  569.             }
  570.             GetVehiclePos(rc_data[playerid][VEH_ID][slot], x, y, z);
  571.  
  572.             //new Float:radius, type;
  573.  
  574.             //may adjust this one if more bomb types will be added
  575.  
  576.  
  577.             ExplodeBomb(playerid, slot, x,y,z, rc_data[playerid][BOMB][slot]-1, 1, 0); //x,y,z, strength, strength progress(must be 1), z_angle progress(must be 0)  - the last 2 are there due to 10 max explosions limit
  578.             if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == slot){rc_data[playerid][IS_CONTROLLING] = false;}
  579.  
  580.  
  581.             DestroyVehicle(rc_data[playerid][VEH_ID][slot]);
  582.             rc_data[playerid][DEPLOYED][slot] = false;
  583.             rc_data[playerid][OWNED][slot] = false;
  584.             rc_data[playerid][BOMB][slot] = 0;
  585.             rc_data[playerid][NAVIGATION][slot] = 0;
  586.             new str[64];
  587.             format(str, sizeof(str), "~g~-> ~y~The %s exploded successfully", rc_names[rc_data[playerid][TYPE][slot]]);
  588.             DisplayMessage(playerid, str, 700, DEFAULT_COLOR);
  589.  
  590.             HideHpBar(playerid, slot);
  591.             if(PlayerDeployedAny(playerid) != 1){KillTimer(rc_data[playerid][MONITOR]);}
  592.             rc_data[playerid][HP][slot] = 5000; //reset to initial value
  593.  
  594.             ResetExtraFeatures(playerid, slot);
  595.             return 1;
  596.         }
  597.         else if(!strcmp("help", params, true) && strlen(params) > 0)
  598.         {
  599.             SendClientMessage(playerid, DEFAULT_COLOR, "RC Commands:");
  600.             SendClientMessage(playerid, -1, "/rc list {F7F694}(Show list of owned devices)");
  601.             SendClientMessage(playerid, -1, "/rc deploy <slot> {F7F694}(Deploys device)");
  602.             SendClientMessage(playerid, -1, "/rc conceal <slot> {F7F694}(Hides device)");
  603.             SendClientMessage(playerid, -1, "/rc connect <slot> {F7F694}(Gains control)");
  604.             SendClientMessage(playerid, -1, "/rc disconnect{F7F694}(Cancels the controlling mode - the device stays where it was)");
  605.             SendClientMessage(playerid, -1, "/rc explode <slot> {F7F694}(bomb detonation)");
  606.             //
  607.             return 1;
  608.         }
  609.     }
  610.     return 0;
  611. }
  612.  
  613. forward ExplodeBomb(playerid, slot, Float:x,Float:y,Float:z, bomb_strength, bomb_strength_progress, z_angle);
  614. public ExplodeBomb(playerid, slot, Float:x,Float:y,Float:z, bomb_strength, bomb_strength_progress, z_angle) //only 10 explosions can be seen at once
  615. {
  616.     new Float:distance=8.0, Float:tempX, Float:tempY;
  617.     new i;
  618.     new ten_at_once=0;
  619.  
  620.     if(bomb_strength_progress == 1 && z_angle == 0)
  621.     {
  622.         CreateExplosion(x,y, z, 7, 50.0);
  623.         if(bomb_strength >= 4)
  624.         {
  625.             //initial center blast
  626.             for(i = bomb_strength_progress; i <= bomb_strength; i++)
  627.             {
  628.                 new j;
  629.                 for(j=0; j<360; j += ((360/4)/i))
  630.                 {
  631.                     tempX = x + (distance * float(i) * floatsin(float(-j), degrees)); // angles in GTA go counter-clockwise, so we need to reverse the retrieved angle
  632.                     tempY = y + (distance * float(i) * floatcos(float(-j), degrees));//float(-j), degrees));
  633.                     CreateExplosion(tempX, tempY, z, 7, 50.0);
  634.                 }
  635.                 z_angle = 0;
  636.             }
  637.         }
  638.  
  639.         if(BOMB_HP_AND_FLASH_EFFECTS){HpAndVelocityEffects(playerid, slot, (bomb_strength >= BOMB_NUCLEAR_THRESHOLD-1)? true:false);}
  640.     }
  641.  
  642.     for(i = bomb_strength_progress; i <= bomb_strength; i++)
  643.     {
  644.         new j;
  645.         for(j=z_angle; j<360; j += ((360/4)/i))
  646.         {
  647.             ten_at_once++;
  648.             if(ten_at_once == 9)
  649.             {
  650.                 SetTimerEx("ExplodeBomb", 1500, false, "ddfffddd", playerid, slot, x,y,z, bomb_strength, i, j);
  651.                 return 1;
  652.             }
  653.             tempX = x + (distance * float(i) * floatsin(float(-random(359)), degrees)); // angles in GTA go counter-clockwise, so we need to reverse the retrieved angle
  654.             tempY = y + (distance * float(i) * floatcos(float(-random(359)), degrees));//float(-j), degrees));
  655.             CreateExplosion(tempX, tempY, z + ((i-1) * 7.0), 7, 50.0);
  656.         }
  657.         z_angle = 0;
  658.     }
  659.     return 1;
  660. }
  661.  
  662. HpAndVelocityEffects(playerid, slot, bool:isNuke)//need take account of: -is player controlling the rc now
  663. {
  664.     //playerid = attacker, i = all potential victims
  665.  
  666.     new Float:eX, Float:eY, Float:eZ;
  667.     GetVehiclePos(rc_data[playerid][VEH_ID][slot], eX, eY, eZ);
  668.  
  669.     for(new i=0;i<MAX_PLAYERS;i++)
  670.     {
  671.         if(!IsPlayerConnected(i)){continue;}
  672.  
  673.         new Float: fDistance;
  674.         if(rc_data[i][IS_CONTROLLING] == true)
  675.         {
  676.             if(controller_virtual_world[i] != rc_data[playerid][VIRTUAL_WORLD][slot]){continue;}
  677.             if(controller_interior[i] != rc_data[playerid][INTERIOR][slot]){continue;}
  678.            
  679.             fDistance = GetVehicleDistanceFromPoint(rc_data[playerid][VEH_ID][slot], controller_posX[i], controller_posY[i], controller_posZ[i]);
  680.         }
  681.         else
  682.         {
  683.             if(GetPlayerVirtualWorld(i) != rc_data[playerid][VIRTUAL_WORLD][slot]){continue;}
  684.             if(GetPlayerInterior(i) != rc_data[playerid][INTERIOR][slot]){continue;}
  685.  
  686.             fDistance = GetPlayerDistanceFromPoint(i, eX, eY, eZ);
  687.         }
  688.  
  689.         if(fDistance < bomb_ranges[rc_data[playerid][BOMB][slot]])
  690.         {
  691.             //bomb_ranges[rc_data[playerid][BOMB][slot]] // range
  692.             //GetPlayerDistanceFromPoint(i, eX, eY, eZ) //actual distance
  693.             //100 - ((actual_dist / range) * 100)
  694.  
  695.             new dmg = floatround(100.0 - (( fDistance / bomb_ranges[rc_data[playerid][BOMB][slot]]) * 100.0));
  696.  
  697.             //new str[50];format(str,sizeof(str),"dmg:%d, distance:%f", dmg, fDistance);
  698.             //SendClientMessage(i, -1, str);
  699.  
  700.             //get angle between explosion and the victim
  701.             new Float:angle;
  702.             if(rc_data[i][IS_CONTROLLING] == true)
  703.             {
  704.                 angle = atan2 (controller_posX[i] - eX, eY - controller_posY[i]) + 180.0;
  705.                 //new Float: angle = atan2 (x - RC_SHOP_POS_X, RC_SHOP_POS_Y - y) + 180.0;
  706.             }
  707.             else
  708.             {
  709.                 new Float:x,Float:y,Float:z;
  710.                 GetPlayerPos(i,x,y,z);
  711.                 angle = atan2 (x - eX, eY - y) + 180.0;
  712.             }
  713.  
  714.             if(isNuke == true) // if nuclear
  715.             {
  716.                 SetTimerEx("NukeFlash", 1, false, "dd", i, 255); //divide 255 somehow + add how much hp to decrease
  717.             }
  718.  
  719.             new Float:xThrust = floatsin(-angle, degrees) * (float(dmg)/BOMB_VELOCITY_DIV); // angles in GTA go counter-clockwise, so we need to reverse the retrieved angle
  720.             new Float:yThrust = floatcos(-angle, degrees) * (float(dmg)/BOMB_VELOCITY_DIV);//float(-j), degrees));
  721.             SetPlayerVelocity(i, xThrust, yThrust, 0.2); // Forces the player to jump (Z velocity + 0.2)
  722.  
  723.             new Float:x,Float:y,Float:z;
  724.             GetPlayerPos(i,x,y,z);
  725.             PlayerPlaySound(i,1159,x,y,z);
  726.             new Float:hp;
  727.             GetPlayerHealth(i, hp);
  728.             SetPlayerHealth(i, hp - dmg);
  729.         }
  730.     }
  731.  
  732.     //for vehicles
  733.  
  734.     if(BOMB_AFFECT_CARS)
  735.     {
  736.         for(new i=0;i<MAX_VEHICLES;i++)
  737.         {
  738.             //could add "if spawned" or something like that
  739.  
  740.             new Float: fDistance = GetVehicleDistanceFromPoint(i, eX, eY, eZ);
  741.  
  742.             if(fDistance < bomb_ranges[rc_data[playerid][BOMB][slot]] && fDistance > 0.0)
  743.             {
  744.                 //new str[64];format(str,sizeof(str),"distance=%f x=%.0f y=%.0f z=%.0f", fDistance, eX, eY, eZ);
  745.                 //SendClientMessage(i,-1,str);
  746.  
  747.                 new Float: hp;
  748.                 new dmg = floatround(1000.0 - (( fDistance / bomb_ranges[rc_data[playerid][BOMB][slot]]) * 1000.0));
  749.  
  750.                 new Float:x,Float:y,Float:z;
  751.                 GetVehiclePos(i,x,y,z);
  752.                 new Float:angle = atan2 (x - eX, eY - y) + 180.0;
  753.                 new Float:xThrust = floatsin(-angle, degrees) * ((float(dmg)/BOMB_VELOCITY_DIV)/10.0); // angles in GTA go counter-clockwise, so we need to reverse the retrieved angle
  754.                 new Float:yThrust = floatcos(-angle, degrees) * ((float(dmg)/BOMB_VELOCITY_DIV))/10.0;//float(-j), degrees));
  755.                 SetVehicleVelocity(i, xThrust, yThrust, 0.2); // Forces the player to jump (Z velocity + 0.2)
  756.  
  757.                 GetVehicleHealth(i, hp);
  758.                 SetVehicleHealth(i, hp - dmg);
  759.  
  760.                 //str= "";format(str,sizeof(str),"distance=%.0f dmg=%d angle=%.0f", fDistance, dmg, angle);
  761.                 //SendClientMessage(i,-1,str);
  762.             }
  763.         }
  764.     }
  765. }
  766.  
  767. //SetTimerEx("NukeFlash",1000,0,"d",playerid);
  768. forward NukeFlash(playerid, alpha);
  769. public NukeFlash(playerid, alpha)
  770. {
  771.     if(alpha <= 0) //wave arrived
  772.     {
  773.         PlayerTextDrawHide(playerid, Flash[playerid]);
  774.         return 1;
  775.     }
  776.  
  777.     new color = (4294809088 + alpha);//0xfffd9600
  778.     PlayerTextDrawBoxColor(playerid, Flash[playerid], color);
  779.     PlayerTextDrawShow(playerid,Flash[playerid]);
  780.  
  781.     SetTimerEx("NukeFlash", 10, false, "dd", playerid, (alpha - 3));
  782.     return 1;
  783. }
  784.  
  785.  
  786.  
  787. AppendExtraFeatures(playerid, slot)
  788. {
  789.     new str[100];
  790.     new str2[10];
  791.  
  792.     format(str2, sizeof(str2), "{%s}(", COLOR_BLUE);
  793.     strcat(str, str2);
  794.     format(str2, sizeof(str2), "%.0fm", navigation_ranges[rc_data[playerid][NAVIGATION][slot]]);
  795.     strcat(str, str2);
  796.     if(rc_data[playerid][BOMB][slot] > 0){strcat(str,", ");strcat(str, bomb_names[rc_data[playerid][BOMB][slot]]);}
  797.     strcat(str,")");
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.     if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == slot)
  806.     {
  807.         new str_connect[30];
  808.         format(str_connect, sizeof(str_connect), "{%s} - CONNECTED", COLOR_ORANGE);
  809.         strcat(str, str_connect);
  810.     }
  811.  
  812.     return str;
  813. }
  814.  
  815. PlayerDeployedAny(playerid)
  816. {
  817.     new i;
  818.     for(i=0;i<MAX_SLOTS;i++)
  819.     {
  820.         if(rc_data[playerid][DEPLOYED][i])
  821.         {
  822.             return true;
  823.         }
  824.     }
  825.     return false;
  826. }
  827.  
  828.  
  829. forward HpMonitor(playerid); //now also range monitor
  830. public HpMonitor(playerid) //monitor hp of all 3 slots, need to use SetTimerEx and pass playerid as a parameter
  831. {
  832.     //PlayerTextDrawSetString(playerid, hp_bar[playerid][slot][INDICATOR],"..........");
  833.     new i;
  834.     for(i=0;i<MAX_SLOTS;i++)
  835.     {
  836.         if(rc_data[playerid][DEPLOYED][i] == true)
  837.         {
  838.             new Float:hp, vehid = rc_data[playerid][VEH_ID][i];
  839.             GetVehicleHealth(vehid, hp);
  840.             new hp_int = floatround(hp);
  841.             UpdateHpBar(playerid, i, hp_int);
  842.  
  843.             if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == i)
  844.             {
  845.                 //yellow text colour if currently controlled
  846.                 PlayerTextDrawLetterSize(playerid, hp_bar[playerid][LABEL][i], 0.4, 0.8);
  847.                 PlayerTextDrawColor(playerid, hp_bar[playerid][LABEL][i], DEFAULT_COLOR);
  848.             }
  849.             else
  850.             {
  851.                 //white text otherwise
  852.                 PlayerTextDrawLetterSize(playerid, hp_bar[playerid][LABEL][i], 0.3, 0.6);
  853.                 PlayerTextDrawColor(playerid, hp_bar[playerid][LABEL][i], 0xffffffcc);
  854.             }
  855.             PlayerTextDrawShow(playerid, hp_bar[playerid][LABEL][i]); //re-show
  856.  
  857.             if(hp_int <= 4250)
  858.             {
  859.                 if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == i)
  860.                 {
  861.                     rc_data[playerid][IS_CONTROLLING] = false;
  862.                     SetPlayerInterior(playerid, controller_interior[playerid]);
  863.                     SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
  864.                     SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
  865.                 }
  866.                 DestroyVehicle(vehid);
  867.                 rc_data[playerid][DEPLOYED][i] = false;
  868.                 rc_data[playerid][OWNED][i] = false;
  869.                 rc_data[playerid][BOMB][i] = 0;
  870.                 rc_data[playerid][NAVIGATION][i] = 0;
  871.                 new str[64];
  872.                 format(str, sizeof(str), "The %s has been {%s}destroyed{F7F694}.", rc_names[rc_data[playerid][TYPE][i]], COLOR_RED);
  873.                 SendClientMessage(playerid, DEFAULT_COLOR, str);
  874.  
  875.                 //format(str, sizeof(str), "~r~-> ~y~The %s has been ~r~destroyed", rc_names[rc_data[playerid][TYPE][i]], COLOR_RED);
  876.                 //DisplayMessage(playerid, str, 2000, DEFAULT_COLOR);
  877.  
  878.  
  879.                 HideHpBar(playerid, i);
  880.                 if(PlayerDeployedAny(playerid) != 1){KillTimer(rc_data[playerid][MONITOR]);}
  881.                 rc_data[playerid][HP][i] = 5000; //reset to initial value
  882.                 ResetExtraFeatures(playerid, i);
  883.             }
  884.  
  885.  
  886.             //RANGE MONITOR
  887.             if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == i && rc_data[playerid][NAVIGATION][i] < SATELITE_THRESHOLD)
  888.             {
  889.                 new Float: fDistance = GetVehicleDistanceFromPoint(rc_data[playerid][VEH_ID][i], controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
  890.                 if(fDistance >= navigation_ranges[rc_data[playerid][NAVIGATION][i]])
  891.                 {
  892.                     rc_data[playerid][IS_CONTROLLING] = false;
  893.                     SetPlayerInterior(playerid, controller_interior[playerid]);
  894.                     SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
  895.                     SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
  896.                     //DisplayMessage(playerid, "~r~-> ~y~Connection lost, the range is too high", 2000, DEFAULT_COLOR);
  897.                     SendClientMessage(playerid, DEFAULT_COLOR, "Connection {950000}lost{F7F694}, the range is too high");
  898.                 }
  899.                 else if((fDistance * 1.2) >= navigation_ranges[rc_data[playerid][NAVIGATION][i]])
  900.                 {
  901.                     new Float:x, Float:y, Float:z;
  902.                     GetPlayerPos(playerid, x,y,z);
  903.                     //add sign or something saying the signal is weak
  904.                     PlayerPlaySound(playerid,45400,x,y,z);
  905.                     DisplayMessage(playerid, "~r~-> ~y~Weak signal", 190, DEFAULT_COLOR);
  906.                 }
  907.             }
  908.         }
  909.     }
  910. }
  911.  
  912. ResetExtraFeatures(playerid, slot)
  913. {
  914.     rc_data[playerid][BOMB][slot] = 0;
  915. }
  916.  
  917. UpdateHpBar(playerid, slot, hp)
  918. {
  919.     new str_label[11];
  920.     str_label = GetHpBarStringIndicator(playerid, slot, hp);
  921.     PlayerTextDrawSetString(playerid, hp_bar[playerid][INDICATOR][slot],str_label);
  922. }
  923.  
  924.  
  925. GetHpBarStringIndicator(playerid, slot, hp_int)
  926. {
  927.     new str[11];
  928.     new color;
  929.     switch(hp_int)
  930.     {
  931.         case 0 .. 4249:
  932.         {
  933.             str = "";
  934.             color = 0x950000FF;
  935.         }
  936.         case 4250 .. 4324:
  937.         {
  938.             str = ".";
  939.             color = 0x950000FF;
  940.         }
  941.         case 4325 .. 4399:
  942.         {
  943.             str = "..";
  944.             color = 0x950000FF;
  945.         }
  946.         case 4400 .. 4474:
  947.         {
  948.             str = "...";
  949.             color = 0x950000FF;
  950.         }
  951.         case 4475 .. 4549:
  952.         {
  953.             str = "....";
  954.             color = DEFAULT_COLOR;
  955.         }
  956.         case 4550 .. 4624:
  957.         {
  958.             str = ".....";
  959.             color = DEFAULT_COLOR;
  960.         }
  961.         case 4625 .. 4699:
  962.         {
  963.             str = "......";
  964.             color = DEFAULT_COLOR;
  965.         }
  966.         case 4700 .. 4774:
  967.         {
  968.             str = ".......";
  969.             color = DEFAULT_COLOR;
  970.         }
  971.         case 4775 .. 4849:
  972.         {
  973.             str = "........";
  974.             color = 0x008500FF;
  975.         }
  976.         case 4850 .. 4924:
  977.         {
  978.             str = ".........";
  979.             color = 0x008500FF;
  980.         }
  981.         case 4925 .. 5499:
  982.         {
  983.             str = "..........";
  984.             color = 0x008500FF;
  985.         }
  986.         default:
  987.         {
  988.             str = "..........";
  989.             color = 0x008500FF;
  990.         }
  991.     }
  992.  
  993.     PlayerTextDrawColor(playerid, hp_bar[playerid][INDICATOR][slot], color);
  994.     PlayerTextDrawBackgroundColor(playerid, hp_bar[playerid][INDICATOR][slot], color);
  995.     PlayerTextDrawShow(playerid, hp_bar[playerid][INDICATOR][slot]);
  996.  
  997.     return str;
  998. }
  999.  
  1000. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  1001. {
  1002.     if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted + if heliblades
  1003.     {
  1004.         new
  1005.             infoString[128],
  1006.             weaponName[24],
  1007.             victimName[MAX_PLAYER_NAME],
  1008.             attackerName[MAX_PLAYER_NAME];
  1009.  
  1010.         GetPlayerName(playerid, victimName, sizeof (victimName));
  1011.         GetPlayerName(issuerid, attackerName, sizeof (attackerName));
  1012.  
  1013.         GetWeaponName(weaponid, weaponName, sizeof (weaponName));
  1014.  
  1015.         format(infoString, sizeof(infoString), "%s has made %.0f damage to %s, weapon: %s", attackerName, amount, victimName, weaponName);
  1016.         SendClientMessageToAll(-1, infoString);
  1017.  
  1018.         //new Float:health;
  1019.         //GetPlayerHealth(playerid,health);
  1020.         //SetPlayerHealth(playerid, health+amount);
  1021.     }
  1022.     return 1;
  1023. }
  1024.  
  1025. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  1026. {
  1027.     if(rc_data[playerid][IS_CONTROLLING] == true)
  1028.     {
  1029.         return 0;
  1030.     }
  1031.  
  1032.     return 1;
  1033. }
  1034.  
  1035. /*
  1036. public OnPlayerConnect(playerid)
  1037. {
  1038.  
  1039.         return 1;
  1040. }
  1041.  
  1042. public OnPlayerDisconnect(playerid)
  1043. {
  1044.         TextDrawDestroy(hp_bar[playerid][i][BACKGROUND]);
  1045.         return 1;
  1046. }
  1047.  
  1048. public OnPlayerDeath(playerid)
  1049. {
  1050.         TextDrawHideForPlayer(playerid,hp_bar[playerid][i][BACKGROUND]);
  1051.         return 1;
  1052. }
  1053.  
  1054. public OnPlayerSpawn(playerid)
  1055. {
  1056.         TextDrawSetString(hp_bar[playerid][i][BACKGROUND],"..........");
  1057.         TextDrawShowForPlayer(playerid,hp_bar[playerid][i][BACKGROUND]);
  1058.         return 1;
  1059. }
  1060. */
  1061.  
  1062.  
  1063. /*
  1064. IsVehicleRc( vehicleid ){//defines the RC vehicles.
  1065.     new model = GetVehicleModel(vehicleid);
  1066.     switch(model)
  1067.     {
  1068.         case RC_GOBLIN, RC_BARON, RC_BANDIT, RC_MINITANK: return 1;
  1069.         default: return 0;
  1070.     }
  1071.  
  1072.     return 0;
  1073. }
  1074. */
  1075.  
  1076. stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:z, Float:distance)
  1077. {
  1078.     // Created by Y_Less
  1079.  
  1080.     new Float:a;
  1081.  
  1082.     GetPlayerPos(playerid, x, y, z);
  1083.     GetPlayerFacingAngle(playerid, a);
  1084.  
  1085.     if (GetPlayerVehicleID(playerid)) {
  1086.         GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  1087.     }
  1088.  
  1089.     x += (distance * floatsin(-a, degrees));
  1090.     y += (distance * floatcos(-a, degrees));
  1091. }
  1092.  
  1093.  
  1094. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  1095. {
  1096.     return 1;
  1097. }
  1098.  
  1099. public OnPlayerExitVehicle(playerid, vehicleid)
  1100. {
  1101.     return 1;
  1102. }
  1103.  
  1104. public OnPlayerStateChange(playerid, newstate, oldstate)
  1105. {
  1106.     return 1;
  1107. }
  1108.  
  1109. public OnPlayerEnterCheckpoint(playerid)
  1110. {
  1111.     return 1;
  1112. }
  1113.  
  1114. public OnPlayerLeaveCheckpoint(playerid)
  1115. {
  1116.     return 1;
  1117. }
  1118.  
  1119. public OnPlayerEnterRaceCheckpoint(playerid)
  1120. {
  1121.     return 1;
  1122. }
  1123.  
  1124. public OnPlayerLeaveRaceCheckpoint(playerid)
  1125. {
  1126.     return 1;
  1127. }
  1128.  
  1129. public OnRconCommand(cmd[])
  1130. {
  1131.     return 1;
  1132. }
  1133.  
  1134. public OnPlayerRequestSpawn(playerid)
  1135. {
  1136.     return 1;
  1137. }
  1138.  
  1139. public OnObjectMoved(objectid)
  1140. {
  1141.     return 1;
  1142. }
  1143.  
  1144. public OnPlayerObjectMoved(playerid, objectid)
  1145. {
  1146.     return 1;
  1147. }
  1148.  
  1149. public OnPlayerPickUpPickup(playerid, pickupid)
  1150. {
  1151.     return 1;
  1152. }
  1153.  
  1154. public OnVehicleMod(playerid, vehicleid, componentid)
  1155. {
  1156.     return 1;
  1157. }
  1158.  
  1159. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  1160. {
  1161.     return 1;
  1162. }
  1163.  
  1164. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  1165. {
  1166.     return 1;
  1167. }
  1168.  
  1169. public OnPlayerSelectedMenuRow(playerid, row)
  1170. {
  1171.     return 1;
  1172. }
  1173.  
  1174. public OnPlayerExitedMenu(playerid)
  1175. {
  1176.     return 1;
  1177. }
  1178.  
  1179. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  1180. {
  1181.     return 1;
  1182. }
  1183.  
  1184. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  1185. {
  1186.     return 1;
  1187. }
  1188.  
  1189. public OnRconLoginAttempt(ip[], password[], success)
  1190. {
  1191.     return 1;
  1192. }
  1193.  
  1194. public OnPlayerUpdate(playerid)
  1195. {
  1196.     return 1;
  1197. }
  1198.  
  1199. public OnPlayerStreamIn(playerid, forplayerid)
  1200. {
  1201.     return 1;
  1202. }
  1203.  
  1204. public OnPlayerStreamOut(playerid, forplayerid)
  1205. {
  1206.     return 1;
  1207. }
  1208.  
  1209. public OnVehicleStreamIn(vehicleid, forplayerid)
  1210. {
  1211.     return 1;
  1212. }
  1213.  
  1214. public OnVehicleStreamOut(vehicleid, forplayerid)
  1215. {
  1216.     return 1;
  1217. }
  1218.  
  1219. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  1220. {
  1221.     if(response)// They pressed the first button.
  1222.     {
  1223.         switch(dialogid)// If you only have one dialog, then this isn't required, but it's neater for when you implement more dialogs.
  1224.         {
  1225.             case DIALOG_RC_MODELS:// Picking device "Bandit ($)\nBaron ($)\nGoblin ($)\nMinitank ($)"
  1226.             {
  1227.                 if(GetPlayerMoney(playerid) < rc_prices[listitem]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1228.                 new slot = AvailableSlot(playerid);
  1229.                 if(slot != NO_SLOTS_AVAILABLE)
  1230.                 {
  1231.                     last_bought_slot[playerid] = slot;
  1232.                     GivePlayerMoney(playerid, - rc_prices[listitem]);
  1233.                     rc_data[playerid][OWNED][slot] = true;
  1234.                     rc_data[playerid][TYPE][slot] = listitem;
  1235.                     PickExtraFeatures(playerid, slot);
  1236.                     DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1237.                 }
  1238.  
  1239.                 /*
  1240.                 switch(listitem)// Checking which listitem was selected
  1241.                 {
  1242.                     case 0:// Bandit
  1243.                     {
  1244.                         if(GetPlayerMoney(playerid) < RC_BANDIT_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1245.                         new slot = AvailableSlot(playerid);
  1246.                         if(slot != NO_SLOTS_AVAILABLE)
  1247.                         {
  1248.                             GivePlayerMoney(playerid, - RC_BANDIT_PRICE);
  1249.                             rc_data[playerid][OWNED][slot] = true;
  1250.                             rc_data[playerid][TYPE][slot] = 0;
  1251.  
  1252.                             last_bought_slot[playerid] = slot;
  1253.                             PickExtraFeatures(playerid, slot);
  1254.  
  1255.                             DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1256.                         }
  1257.                     }
  1258.                     case 1: // Baron
  1259.                     {
  1260.                         if(GetPlayerMoney(playerid) < RC_BARON_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1261.                         new slot = AvailableSlot(playerid);
  1262.                         if(slot != NO_SLOTS_AVAILABLE)
  1263.                         {
  1264.                             GivePlayerMoney(playerid, - RC_BARON_PRICE);
  1265.                             rc_data[playerid][OWNED][slot] = true;
  1266.                             rc_data[playerid][TYPE][slot] = 1;
  1267.  
  1268.                             last_bought_slot[playerid] = slot;
  1269.                             PickExtraFeatures(playerid, slot);
  1270.                             DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1271.                         }
  1272.  
  1273.                     }
  1274.                     case 2: // Goblin
  1275.                     {
  1276.                         if(GetPlayerMoney(playerid) < RC_GOBLIN_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1277.                         new slot = AvailableSlot(playerid);
  1278.                         if(slot != NO_SLOTS_AVAILABLE)
  1279.                         {
  1280.                             GivePlayerMoney(playerid, - RC_GOBLIN_PRICE);
  1281.                             rc_data[playerid][OWNED][slot] = true;
  1282.                             rc_data[playerid][TYPE][slot] = 2;
  1283.  
  1284.                             last_bought_slot[playerid] = slot;
  1285.                             PickExtraFeatures(playerid, slot);
  1286.                             DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1287.                         }
  1288.                     }
  1289.                     case 3: // Minitank
  1290.                     {
  1291.                         if(GetPlayerMoney(playerid) < RC_MINITANK_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1292.                         new slot = AvailableSlot(playerid);
  1293.                         if(slot != NO_SLOTS_AVAILABLE)
  1294.                         {
  1295.                             GivePlayerMoney(playerid, - RC_MINITANK_PRICE);
  1296.                             rc_data[playerid][OWNED][slot] = true;
  1297.                             rc_data[playerid][TYPE][slot] = 3;
  1298.  
  1299.                             last_bought_slot[playerid] = slot;
  1300.                             PickExtraFeatures(playerid, slot);
  1301.                             DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1302.                         }
  1303.                     }
  1304.                 }
  1305.                 */
  1306.             }
  1307.             case DIALOG_EXTRA_FEATURES:// extra_features selection
  1308.             {
  1309.                 //new slot = last_bought_slot[playerid];
  1310.  
  1311.                 switch(listitem)// Checking which listitem was selected
  1312.                 {
  1313.                     case 0: //Bombs
  1314.                     {
  1315.                         new str[150];
  1316.                         //format(str,sizeof(str),"Small bomb ($%d)\nBomb ($%d)\nLarge bomb ($%d)\nHuge bomb ($%d)\nSmall nuclear bomb ($%d)", SMALL_BOMB_PRICE, BOMB_PRICE, LARGE_BOMB_PRICE, HUGE_BOMB_PRICE, SMALL_NUCLEAR_BOMB_PRICE);
  1317.                         for(new i=1; i < MAX_BOMB_TYPES;i++)
  1318.                         {
  1319.                             new add[50];format(add, sizeof(add), "%s ($%d)\n", bomb_names[i], bomb_prices[i]);
  1320.                             strcat(str,add);
  1321.                         }
  1322.                         ShowPlayerDialog(playerid, DIALOG_BOMB_TYPE, DIALOG_STYLE_LIST, "Bomb type", str, "Buy", "Cancel");
  1323.                     }
  1324.                     case 1: //Navigation
  1325.                     {
  1326.                         new str[150];
  1327.                         //format(str,sizeof(str),"%s - %.0fm ($%d)\n%s - %.0fm ($%d)", navigation_names[1], navigation_ranges[1], navigation_prices[1], navigation_names[2], navigation_ranges[2], navigation_prices[2]);
  1328.                         for(new i=1; i < MAX_NAVIGATION_TYPES;i++)
  1329.                         {
  1330.                             new add[50];format(add, sizeof(add), "%s - %.0fm ($%d)\n", navigation_names[i], navigation_ranges[i], navigation_prices[i]);
  1331.                             strcat(str,add);
  1332.                         }
  1333.                         ShowPlayerDialog(playerid, DIALOG_NAVIGATION_TYPE, DIALOG_STYLE_LIST, "Navigation type", str, "Buy", "Cancel");
  1334.                         //new navigation_names[3] = {"", "2.4Ghz Remote controller", "Satelite support"};
  1335.                         //new navigation_ranges[3] = {0.0, 300.0, 6000.0};
  1336.                     }
  1337.                     case 2: //
  1338.                     {
  1339.  
  1340.                     }
  1341.                     case 3: //
  1342.                     {
  1343.  
  1344.                     }
  1345.                 }
  1346.             }
  1347.             case DIALOG_BOMB_TYPE:// bomb size selection
  1348.             {
  1349.                 new slot = last_bought_slot[playerid];
  1350.                 if(GetPlayerMoney(playerid) < bomb_prices[listitem + 1]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1351.                 GivePlayerMoney(playerid, - bomb_prices[listitem + 1]);
  1352.                 rc_data[playerid][BOMB][slot] = listitem + 1;
  1353.                 PickExtraFeatures(playerid, slot);
  1354.                 DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1355.                 /*
  1356.                 switch(listitem)// SMALL_BOMB_PRICE, BOMB_PRICE, LARGE_BOMB_PRICE, HUGE_BOMB_PRICE, SMALL_NUCLEAR_BOMB_PRICE
  1357.                 {
  1358.                     case 0: //small bomb
  1359.                     {
  1360.                         if(GetPlayerMoney(playerid) < SMALL_BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1361.                         GivePlayerMoney(playerid, - SMALL_BOMB_PRICE);
  1362.                         rc_data[playerid][BOMB][slot] = 1;
  1363.                         PickExtraFeatures(playerid, slot);
  1364.                         DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1365.                     }
  1366.                     case 1: //bomb
  1367.                     {
  1368.                         if(GetPlayerMoney(playerid) < BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1369.                         GivePlayerMoney(playerid, - BOMB_PRICE);
  1370.                         rc_data[playerid][BOMB][slot] = 2;
  1371.                         PickExtraFeatures(playerid, slot);
  1372.                         DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1373.                     }
  1374.                     case 2: //large bomb
  1375.                     {
  1376.                         if(GetPlayerMoney(playerid) < LARGE_BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1377.                         GivePlayerMoney(playerid, - LARGE_BOMB_PRICE);
  1378.                         rc_data[playerid][BOMB][slot] = 3;
  1379.                         PickExtraFeatures(playerid, slot);
  1380.                         DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1381.  
  1382.                     }
  1383.                     case 3: //huge bomb
  1384.                     {
  1385.                         if(GetPlayerMoney(playerid) < HUGE_BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1386.                         GivePlayerMoney(playerid, - HUGE_BOMB_PRICE);
  1387.                         rc_data[playerid][BOMB][slot] = 4;
  1388.                         PickExtraFeatures(playerid, slot);
  1389.                         DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1390.  
  1391.                     }
  1392.                     case 4: //small nuclear weapon
  1393.                     {
  1394.                         if(GetPlayerMoney(playerid) < SMALL_NUCLEAR_BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1395.                         GivePlayerMoney(playerid, - SMALL_NUCLEAR_BOMB_PRICE);
  1396.                         rc_data[playerid][BOMB][slot] = 5;
  1397.                         PickExtraFeatures(playerid, slot);
  1398.                         DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1399.  
  1400.                     }
  1401.                     case 5: //
  1402.                     {
  1403.  
  1404.  
  1405.                     }
  1406.                 }
  1407.                 */
  1408.             }
  1409.             case DIALOG_NAVIGATION_TYPE:
  1410.             {
  1411.                 new slot = last_bought_slot[playerid];
  1412.                 if(GetPlayerMoney(playerid) < navigation_prices[listitem + 1]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1413.                 GivePlayerMoney(playerid, - navigation_prices[listitem + 1]);
  1414.                 rc_data[playerid][NAVIGATION][slot] = listitem + 1;
  1415.                 PickExtraFeatures(playerid, slot);
  1416.                 DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1417.                  
  1418.                
  1419.                 /*
  1420.                 switch(listitem)//
  1421.                 {
  1422.                     case 0: //RC24GHZ_PRICE
  1423.                     {
  1424.                         if(GetPlayerMoney(playerid) < navigation_prices[1]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1425.                         GivePlayerMoney(playerid, - navigation_prices[1]);
  1426.                         rc_data[playerid][NAVIGATION][slot] = 1;
  1427.                         PickExtraFeatures(playerid, slot);
  1428.                         DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1429.                     }
  1430.                     case 1: //
  1431.                     {
  1432.                         if(GetPlayerMoney(playerid) < navigation_prices[2]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
  1433.                         GivePlayerMoney(playerid, - navigation_prices[2]);
  1434.                         rc_data[playerid][NAVIGATION][slot] = 2;
  1435.                         PickExtraFeatures(playerid, slot);
  1436.                         DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
  1437.                     }
  1438.                     case 2: //
  1439.                     {
  1440.                         PickExtraFeatures(playerid, slot);
  1441.                     }
  1442.                     case 3: //
  1443.                     {
  1444.                         PickExtraFeatures(playerid, slot);
  1445.                     }
  1446.                     case 4: //
  1447.                     {
  1448.                         PickExtraFeatures(playerid, slot);
  1449.                     }
  1450.                 }
  1451.                 */
  1452.             }
  1453.         }
  1454.     }
  1455.     return 1;
  1456. }
  1457.  
  1458. PickExtraFeatures(playerid, slot)
  1459. {
  1460.     new str[255];
  1461.     new bool:showAny; //to check if not everyone was bought
  1462.     //new str_price[15];
  1463.  
  1464.     if(rc_data[playerid][BOMB][slot] == 0)
  1465.     {
  1466.         showAny = true;
  1467.  
  1468.         strcat(str, "Bomb");
  1469.         strcat(str, "\n");
  1470.     }
  1471.     else {strcat(str, "-\n");}
  1472.  
  1473.     if(rc_data[playerid][NAVIGATION][slot] == 0)
  1474.     {
  1475.         showAny = true;
  1476.  
  1477.         strcat(str, "Navigation");
  1478.         strcat(str, "\n");
  1479.     }
  1480.     else {strcat(str, "-\n");}
  1481.  
  1482.  
  1483.  
  1484.     if(showAny == true){ShowPlayerDialog(playerid, DIALOG_EXTRA_FEATURES, DIALOG_STYLE_LIST, "Extra features", str, "Buy", "Cancel");}
  1485. }
  1486.  
  1487. //forward byte AvailableSlot(playerid)
  1488. AvailableSlot(playerid)
  1489. {
  1490.     new i;
  1491.     for (i=0; i < MAX_SLOTS; i++)
  1492.     {
  1493.         if(rc_data[playerid][OWNED][i] != true)return i;
  1494.     }
  1495.     return NO_SLOTS_AVAILABLE;
  1496. }
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  1503. {
  1504.     return 1;
  1505. }
  1506.  
  1507. stock sscanf(string[], format[], {Float,_}:...)
  1508. {
  1509.     #if defined isnull
  1510.         if (isnull(string))
  1511.     #else
  1512.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  1513.     #endif
  1514.         {
  1515.             return format[0];
  1516.         }
  1517.     #pragma tabsize 4
  1518.     new
  1519.         formatPos = 0,
  1520.         stringPos = 0,
  1521.         paramPos = 2,
  1522.         paramCount = numargs(),
  1523.         delim = ' ';
  1524.     while (string[stringPos] && string[stringPos] <= ' ')
  1525.     {
  1526.         stringPos++;
  1527.     }
  1528.     while (paramPos < paramCount && string[stringPos])
  1529.     {
  1530.         switch (format[formatPos++])
  1531.         {
  1532.             case '\0':
  1533.             {
  1534.                 return 0;
  1535.             }
  1536.             case 'i', 'd':
  1537.             {
  1538.                 new
  1539.                     neg = 1,
  1540.                     num = 0,
  1541.                     ch = string[stringPos];
  1542.                 if (ch == '-')
  1543.                 {
  1544.                     neg = -1;
  1545.                     ch = string[++stringPos];
  1546.                 }
  1547.                 do
  1548.                 {
  1549.                     stringPos++;
  1550.                     if ('0' <= ch <= '9')
  1551.                     {
  1552.                         num = (num * 10) + (ch - '0');
  1553.                     }
  1554.                     else
  1555.                     {
  1556.                         return -1;
  1557.                     }
  1558.                 }
  1559.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  1560.                 setarg(paramPos, 0, num * neg);
  1561.             }
  1562.             case 'h', 'x':
  1563.             {
  1564.                 new
  1565.                     num = 0,
  1566.                     ch = string[stringPos];
  1567.                 do
  1568.                 {
  1569.                     stringPos++;
  1570.                     switch (ch)
  1571.                     {
  1572.                         case 'x', 'X':
  1573.                         {
  1574.                             num = 0;
  1575.                             continue;
  1576.                         }
  1577.                         case '0' .. '9':
  1578.                         {
  1579.                             num = (num << 4) | (ch - '0');
  1580.                         }
  1581.                         case 'a' .. 'f':
  1582.                         {
  1583.                             num = (num << 4) | (ch - ('a' - 10));
  1584.                         }
  1585.                         case 'A' .. 'F':
  1586.                         {
  1587.                             num = (num << 4) | (ch - ('A' - 10));
  1588.                         }
  1589.                         default:
  1590.                         {
  1591.                             return -1;
  1592.                         }
  1593.                     }
  1594.                 }
  1595.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  1596.                 setarg(paramPos, 0, num);
  1597.             }
  1598.             case 'c':
  1599.             {
  1600.                 setarg(paramPos, 0, string[stringPos++]);
  1601.             }
  1602.             case 'f':
  1603.             {
  1604.  
  1605.                 new changestr[16], changepos = 0, strpos = stringPos;
  1606.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  1607.                 {
  1608.                     changestr[changepos++] = string[strpos++];
  1609.                     }
  1610.                 changestr[changepos] = '\0';
  1611.                 setarg(paramPos,0,_:floatstr(changestr));
  1612.             }
  1613.             case 'p':
  1614.             {
  1615.                 delim = format[formatPos++];
  1616.                 continue;
  1617.             }
  1618.             case '\'':
  1619.             {
  1620.                 new
  1621.                     end = formatPos - 1,
  1622.                     ch;
  1623.                 while ((ch = format[++end]) && ch != '\'') {}
  1624.                 if (!ch)
  1625.                 {
  1626.                     return -1;
  1627.                 }
  1628.                 format[end] = '\0';
  1629.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  1630.                 {
  1631.                     if (format[end + 1])
  1632.                     {
  1633.                         return -1;
  1634.                     }
  1635.                     return 0;
  1636.                 }
  1637.                 format[end] = '\'';
  1638.                 stringPos = ch + (end - formatPos);
  1639.                 formatPos = end + 1;
  1640.             }
  1641.             case 'u':
  1642.             {
  1643.                 new
  1644.                     end = stringPos - 1,
  1645.                     id = 0,
  1646.                     bool:num = true,
  1647.                     ch;
  1648.                 while ((ch = string[++end]) && ch != delim)
  1649.                 {
  1650.                     if (num)
  1651.                     {
  1652.                         if ('0' <= ch <= '9')
  1653.                         {
  1654.                             id = (id * 10) + (ch - '0');
  1655.                         }
  1656.                         else
  1657.                         {
  1658.                             num = false;
  1659.                         }
  1660.                     }
  1661.                 }
  1662.                 if (num && IsPlayerConnected(id))
  1663.                 {
  1664.                     setarg(paramPos, 0, id);
  1665.                 }
  1666.                 else
  1667.                 {
  1668.                     #if !defined foreach
  1669.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  1670.                         #define __SSCANF_FOREACH__
  1671.                     #endif
  1672.                     string[end] = '\0';
  1673.                     num = false;
  1674.                     new
  1675.                         name[MAX_PLAYER_NAME];
  1676.                     id = end - stringPos;
  1677.                     foreach (Player, playerid)
  1678.                     {
  1679.                         GetPlayerName(playerid, name, sizeof (name));
  1680.                         if (!strcmp(name, string[stringPos], true, id))
  1681.                         {
  1682.                             setarg(paramPos, 0, playerid);
  1683.                             num = true;
  1684.                             break;
  1685.                         }
  1686.                     }
  1687.                     if (!num)
  1688.                     {
  1689.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  1690.                     }
  1691.                     string[end] = ch;
  1692.                     #if defined __SSCANF_FOREACH__
  1693.                         #undef foreach
  1694.                         #undef __SSCANF_FOREACH__
  1695.                     #endif
  1696.                 }
  1697.                 stringPos = end;
  1698.             }
  1699.             case 's', 'z':
  1700.             {
  1701.                 new
  1702.                     i = 0,
  1703.                     ch;
  1704.                 if (format[formatPos])
  1705.                 {
  1706.                     while ((ch = string[stringPos++]) && ch != delim)
  1707.                     {
  1708.                         setarg(paramPos, i++, ch);
  1709.                     }
  1710.                     if (!i)
  1711.                     {
  1712.                         return -1;
  1713.                     }
  1714.                 }
  1715.                 else
  1716.                 {
  1717.                     while ((ch = string[stringPos++]))
  1718.                     {
  1719.                         setarg(paramPos, i++, ch);
  1720.                     }
  1721.                 }
  1722.                 stringPos--;
  1723.                 setarg(paramPos, i, '\0');
  1724.             }
  1725.             default:
  1726.             {
  1727.                 continue;
  1728.             }
  1729.         }
  1730.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  1731.         {
  1732.             stringPos++;
  1733.         }
  1734.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  1735.         {
  1736.             stringPos++;
  1737.         }
  1738.         paramPos++;
  1739.     }
  1740.     do
  1741.     {
  1742.         if ((delim = format[formatPos++]) > ' ')
  1743.         {
  1744.             if (delim == '\'')
  1745.             {
  1746.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  1747.             }
  1748.             else if (delim != 'z')
  1749.             {
  1750.                 return delim;
  1751.             }
  1752.         }
  1753.     }
  1754.     while (delim > ' ');
  1755.     return 0;
  1756. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement