Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #define COLOR_RED "950000"
- #define COLOR_GREEN "008500"
- #define COLOR_BLUE "407bef"
- #define COLOR_ORANGE "f28b41"
- #define DEFAULT_COLOR 0xF7F694FF
- #define DIALOG_RC_MODELS 1
- #define DIALOG_EXTRA_FEATURES 2
- #define DIALOG_BOMB_TYPE 3
- #define DIALOG_NAVIGATION_TYPE 4
- #define RC_SHOP_POS_X 2498.5
- #define RC_SHOP_POS_Y -1643.1
- #define RC_SHOP_POS_Z 13.8
- #define POS_HP_BAR_X 555.0 //upper left(?) but not sure
- #define POS_HP_BAR_Y 230.0//370.0
- #define MAX_SLOTS 3
- #define NO_SLOTS_AVAILABLE 255 //kind of "invalid code" for the function which checks which slot is free
- #define MAX_RC_MODELS 4
- new rc_names[MAX_RC_MODELS][16] = {"Bandit", "Baron", "Goblin", "Minitank"};
- new rc_model_ids[MAX_RC_MODELS] = {441,464,501,564};
- new rc_prices[MAX_RC_MODELS] = {0, 100, 200, 300};
- #define MAX_BOMB_TYPES 6
- new bomb_names[MAX_BOMB_TYPES][22] = {"", "Small bomb", "Bomb", "Large bomb", "Huge bomb", "Small nuclear bomb"};
- new Float:bomb_ranges[MAX_BOMB_TYPES] = {0.0, 3.0, 10.0, 20.0, 50.0, 200.0};
- new bomb_prices[MAX_BOMB_TYPES] = {0, 100, 200, 300, 400, 500}; //needs to be implemented (replace switch at OnDialog with loops)
- #define BOMB_NUCLEAR_THRESHOLD 5
- new Float:BOMB_VELOCITY_DIV = 15.0; // lower value -> higher velocity
- new bool: BOMB_AFFECT_CARS = true;
- new bool: BOMB_HP_AND_FLASH_EFFECTS = true; //flash only for nukes
- #define MAX_NAVIGATION_TYPES 3
- new navigation_names[MAX_NAVIGATION_TYPES][22] = {"Bluetooth", "2.4Ghz Remote control", "Satelite support"};
- new Float:navigation_ranges[MAX_NAVIGATION_TYPES] = {30.0, 300.0, 6000.0};
- new navigation_prices[MAX_NAVIGATION_TYPES] = {0, 100, 200};
- #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)
- enum PLAYER_DATA
- {
- //player related
- bool:IS_CONTROLLING, //is player currently driving any rc model
- SLOT_CONTROLLED, //which rc model is being driven
- bool:HAS_HP_MONITOR, //bool to know whether to use SetupTimerEx or it was already setup
- MONITOR, //timer for checking hp (to allow DestroyVehicle() and update hp bars)
- //rc model related
- bool:OWNED[MAX_SLOTS], //is the slot free or taken
- bool:DEPLOYED[MAX_SLOTS], // deployed, not deployed
- TYPE[MAX_SLOTS], // bandit/goblin etc (0-3)
- VEH_ID[MAX_SLOTS], // 0-2000
- HP[MAX_SLOTS],
- INTERIOR[MAX_SLOTS],
- VIRTUAL_WORLD[MAX_SLOTS],
- //extra_features
- //every new has to be added in ResetExtraFeatures(), PickExtraFeatures() where its name has to be set, in OnDialogResponse() and AppendExtraFeatures() - list function
- BOMB[MAX_SLOTS],
- //add Satelite communication (full map range)
- NAVIGATION[MAX_SLOTS]
- //could add the faction of the owner (so anti-rc devices won't detect own rcs)
- }
- new rc_data[MAX_PLAYERS][PLAYER_DATA];
- 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)
- new Float:controller_posX[MAX_PLAYERS], Float:controller_posY[MAX_PLAYERS], Float:controller_posZ[MAX_PLAYERS]; //position from which the player started controlling rc
- 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
- enum HP_BAR_RECTANGLES
- {
- PlayerText:LABEL[MAX_SLOTS],
- PlayerText:BACKGROUND[MAX_SLOTS],
- PlayerText:INDICATOR[MAX_SLOTS]
- }
- new hp_bar[MAX_PLAYERS][HP_BAR_RECTANGLES];
- new PlayerText:Flash[MAX_PLAYERS];
- new PlayerText:Display[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- //init hp of the rc models
- new i;
- for(i=0;i<MAX_SLOTS;i++)
- {
- new j;
- for(j=0; j<MAX_PLAYERS; j++)
- {
- rc_data[j][HP][i] = 5000;
- }
- }
- //init extra features (strings for dialogs and prices)
- print("\n--------------------------------------");
- print("RC Filterscript");
- print("--------------------------------------\n");
- //shop label/pickup
- 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);
- CreatePickup(364, 1, RC_SHOP_POS_X, RC_SHOP_POS_Y, RC_SHOP_POS_Z, 0);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnGameModeInit()
- {
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- InitHpBars(playerid);
- InitNukeFlash(playerid);
- InitDisplayer(playerid);
- return 1;
- }
- InitDisplayer(playerid)
- {
- Display[playerid] = CreatePlayerTextDraw(playerid, 608.0, 415.0,"test");
- //PlayerTextDrawUseBox(playerid, Display[playerid],1); //Toggle whether a textdraw should have a box or not
- //PlayerTextDrawBoxColor(playerid, Display[playerid],0x00000050); //Set the color of a textdraw's box
- //PlayerTextDrawTextSize(playerid, Display[playerid], 500.0,400.0);//950.0,0.0); //Set the size of a textdraw
- PlayerTextDrawAlignment(playerid, Display[playerid], 3);
- //PlayerTextDrawBackgroundColor(playerid, Displayer[playerid],0x000000ff);
- PlayerTextDrawFont(playerid, Display[playerid],2);
- PlayerTextDrawLetterSize(playerid, Display[playerid], 0.5 ,1.3);
- //PlayerTextDrawColor(playerid, Display[playerid],0x000000FF);
- //PlayerTextDrawSetOutline(playerid, Display[playerid],1);
- //PlayerTextDrawSetProportional(playerid, Display[playerid],1);
- //PlayerTextDrawSetShadow(playerid, Display[playerid],1);
- //PlayerTextDrawShow(playerid, Display[playerid]);
- }
- DisplayMessage(playerid, message[], time, color)
- {
- PlayerTextDrawColor(playerid, Display[playerid], color);
- PlayerTextDrawSetString(playerid, Display[playerid], message);
- PlayerTextDrawShow(playerid, Display[playerid]);
- SetTimerEx("HideMessage", time, false, "d", playerid); //have to create global variables with last used messages
- }
- forward HideMessage(playerid);
- public HideMessage(playerid)
- {
- PlayerTextDrawHide(playerid, Display[playerid]);
- }
- /*
- ~b~ Blue
- ~g~ Green
- ~l~ Black
- ~p~ Pink
- ~r~ Red
- ~w~ White
- ~y~ Yellow
- ~h~ Lighter color
- ~s~ Shadow
- ~d~ Down arrow
- ~u~ Up arrow
- ~<~ Left arrow
- ~>~ Right arrow
- ~t~ Rectangle
- ~n~ New line
- special symbols, not used inside ~~ will produce special graphics
- { question mark
- ] wanted level star (only some styles/fonts)
- @ inverted exclamation mark
- | circle icon
- */
- InitHpBars(playerid)
- {
- new Float:x = POS_HP_BAR_X, Float:init_y = POS_HP_BAR_Y, Float:sizeX = 0.569999, Float:sizeY = 4.0;//2.549999;
- new Float:y = init_y;
- new i;
- for(i=0; i<MAX_SLOTS;i++)
- {
- hp_bar[playerid][BACKGROUND][i] = CreatePlayerTextDraw(playerid, x, y,"..........");
- PlayerTextDrawAlignment(playerid, hp_bar[playerid][BACKGROUND][i],1);
- PlayerTextDrawBackgroundColor(playerid, hp_bar[playerid][BACKGROUND][i],0x000000ff);
- PlayerTextDrawFont(playerid, hp_bar[playerid][BACKGROUND][i],3);
- PlayerTextDrawLetterSize(playerid, hp_bar[playerid][BACKGROUND][i], sizeX, sizeY);
- PlayerTextDrawColor(playerid, hp_bar[playerid][BACKGROUND][i],0x00000033);
- PlayerTextDrawSetOutline(playerid, hp_bar[playerid][BACKGROUND][i],1);
- PlayerTextDrawSetProportional(playerid, hp_bar[playerid][BACKGROUND][i],1);
- PlayerTextDrawSetShadow(playerid, hp_bar[playerid][BACKGROUND][i],1);
- y += 20.0;
- }
- x += (sizeX/0.5);
- y = init_y + (sizeX/0.5) + (sizeY*2.5);
- sizeX -= (sizeX / 25);
- sizeY -= (sizeY / 2.5);
- for(i=0; i<MAX_SLOTS;i++)
- {
- hp_bar[playerid][INDICATOR][i] = CreatePlayerTextDraw(playerid, x, y,"..........");
- PlayerTextDrawAlignment(playerid, hp_bar[playerid][INDICATOR][i],1);
- PlayerTextDrawBackgroundColor(playerid, hp_bar[playerid][INDICATOR][i],0x6be1ffff);
- PlayerTextDrawFont(playerid, hp_bar[playerid][INDICATOR][i],3);
- PlayerTextDrawLetterSize(playerid, hp_bar[playerid][INDICATOR][i], sizeX, sizeY);
- PlayerTextDrawColor(playerid, hp_bar[playerid][INDICATOR][i],0x6be1ff33);
- PlayerTextDrawSetOutline(playerid, hp_bar[playerid][INDICATOR][i],1);
- PlayerTextDrawSetProportional(playerid, hp_bar[playerid][INDICATOR][i],1);
- PlayerTextDrawSetShadow(playerid, hp_bar[playerid][INDICATOR][i],1);
- y += 20.0;
- }
- y = (init_y - 1.0);
- for(i=0; i<MAX_SLOTS;i++)
- {
- y+= 20.0;
- hp_bar[playerid][LABEL][i] = CreatePlayerTextDraw(playerid, x, y,"Test");
- PlayerTextDrawAlignment(playerid, hp_bar[playerid][LABEL][i],1);
- PlayerTextDrawFont(playerid, hp_bar[playerid][LABEL][i],1);
- PlayerTextDrawLetterSize(playerid, hp_bar[playerid][LABEL][i], 0.3, 0.6);
- PlayerTextDrawColor(playerid, hp_bar[playerid][LABEL][i],0xFFFFFFFF);
- PlayerTextDrawSetOutline(playerid, hp_bar[playerid][LABEL][i],1);
- }
- return 1;
- }
- InitNukeFlash(playerid)
- {
- Flash[playerid] = CreatePlayerTextDraw(playerid, 0.0, 0.0,"FLASHBANG!");//Creates a textdraw.
- PlayerTextDrawUseBox(playerid, Flash[playerid],1); //Toggle whether a textdraw should have a box or not
- PlayerTextDrawBoxColor(playerid, Flash[playerid],0xffffff50); //Set the color of a textdraw's box
- PlayerTextDrawTextSize(playerid, Flash[playerid],950.0,0.0);//950.0,0.0); //Set the size of a textdraw
- PlayerTextDrawAlignment(playerid, Flash[playerid],0); //Set a textdraw's alignment
- PlayerTextDrawBackgroundColor(playerid, Flash[playerid],0xffffffff); //Adjusts the text draw area background color
- PlayerTextDrawFont(playerid, Flash[playerid],3); //Set a textdraw's font
- PlayerTextDrawLetterSize(playerid, Flash[playerid],0.0, 70.0); //Set the size of a textdraw's text
- PlayerTextDrawColor(playerid, Flash[playerid],0xffffff00); // Color white durp
- PlayerTextDrawSetOutline(playerid, Flash[playerid],1);//Set the outline thickness of a textdraw
- PlayerTextDrawSetProportional(playerid, Flash[playerid],1); //Set a textdraw's text proportion
- PlayerTextDrawSetShadow(playerid, Flash[playerid],1); //Toggle a shadow behind a textdraw's text
- /*
- Flash[playerid] = CreatePlayerTextDraw(playerid, 320.0, 240.0,"FLASHBANG!");//Creates a textdraw.
- PlayerTextDrawUseBox(playerid, Flash[playerid],1); //Toggle whether a textdraw should have a box or not
- PlayerTextDrawBoxColor(playerid, Flash[playerid],0xffffff50); //Set the color of a textdraw's box
- PlayerTextDrawTextSize(playerid, Flash[playerid],630.0,0.0);//950.0,0.0); //Set the size of a textdraw
- PlayerTextDrawAlignment(playerid, Flash[playerid],0); //Set a textdraw's alignment
- PlayerTextDrawBackgroundColor(playerid, Flash[playerid],0xffffffff); //Adjusts the text draw area background color
- PlayerTextDrawFont(playerid, Flash[playerid],3); //Set a textdraw's font
- PlayerTextDrawLetterSize(playerid, Flash[playerid],0.0,240.0 * 0.135); //Set the size of a textdraw's text
- PlayerTextDrawColor(playerid, Flash[playerid],0xffffff00); // Color white durp
- PlayerTextDrawSetOutline(playerid, Flash[playerid],1);//Set the outline thickness of a textdraw
- PlayerTextDrawSetProportional(playerid, Flash[playerid],1); //Set a textdraw's text proportion
- PlayerTextDrawSetShadow(playerid, Flash[playerid],1); //Toggle a shadow behind a textdraw's text
- */
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new i;
- for(i=0;i<MAX_SLOTS;i++)
- {
- PlayerTextDrawDestroy(playerid, hp_bar[playerid][BACKGROUND][i]);
- PlayerTextDrawDestroy(playerid, hp_bar[playerid][INDICATOR][i]);
- PlayerTextDrawDestroy(playerid, hp_bar[playerid][LABEL][i]);
- rc_data[playerid][BOMB][i] = 0;
- rc_data[playerid][NAVIGATION][i] = 0;
- rc_data[playerid][OWNED][i] = false;
- rc_data[playerid][DEPLOYED][i] = false;
- rc_data[playerid][HP][i] = 5000;
- rc_data[playerid][INTERIOR][i] = 0;
- rc_data[playerid][VIRTUAL_WORLD][i] = 0;
- }
- rc_data[playerid][IS_CONTROLLING] = false;
- rc_data[playerid][HAS_HP_MONITOR] = false;
- KillTimer(rc_data[playerid][MONITOR]);
- PlayerTextDrawDestroy(playerid, Flash[playerid]);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- GivePlayerMoney(playerid, 20000);
- return 1;
- }
- /*
- SetTimerEx("AngleTest", 500, true, "d", playerid);
- forward public AngleTest(playerid);
- public AngleTest(playerid)
- {
- //#define RC_SHOP_POS_X 2498.5
- //#define RC_SHOP_POS_Y -1643.1
- //#define RC_SHOP_POS_Z 13.8
- new Float:x,Float:y,Float:z, Float:facing_angle;
- GetPlayerPos(playerid,x,y,z);
- GetPlayerFacingAngle(playerid, facing_angle);
- new Float: angle = atan2 (x - RC_SHOP_POS_X, RC_SHOP_POS_Y - y) + 180.0;
- new str[64];format(str,sizeof(str),"angle=%.0f facing angle=%.0f", angle, facing_angle);
- SendClientMessage(playerid, -1, str);
- }
- */
- ShowHpBar(playerid, slot, label[])
- {
- PlayerTextDrawShow(playerid, hp_bar[playerid][BACKGROUND][slot]);
- PlayerTextDrawSetString(playerid, hp_bar[playerid][INDICATOR][slot],".........."); //background is always the same length
- PlayerTextDrawShow(playerid, hp_bar[playerid][INDICATOR][slot]);
- PlayerTextDrawSetString(playerid, hp_bar[playerid][LABEL][slot], label);
- PlayerTextDrawShow(playerid, hp_bar[playerid][LABEL][slot]);
- }
- HideHpBar(playerid, slot)
- {
- PlayerTextDrawHide(playerid, hp_bar[playerid][BACKGROUND][slot]);
- PlayerTextDrawHide(playerid, hp_bar[playerid][INDICATOR][slot]);
- PlayerTextDrawHide(playerid, hp_bar[playerid][LABEL][slot]);
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(rc_data[playerid][IS_CONTROLLING] == true)
- {
- rc_data[playerid][IS_CONTROLLING] = false;
- SetPlayerInterior(playerid, controller_interior[playerid]);
- SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
- SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
- }
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[30], params[30], slot, bool:slot_included;
- if(sscanf(cmdtext, "ssd", cmd, params, slot))
- {
- sscanf(cmdtext, "ss", cmd, params);
- }
- else
- {
- slot_included = true;
- slot -= 1; // to let the user have slot 1 as a starting one instead of slot 0
- }
- if (!strcmp("/rc", cmd, true)) //need to implement inventory here
- {
- if(!strcmp("deploy", params, true) && slot_included == true)
- {
- if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][DEPLOYED][slot] == true){DisplayMessage(playerid, "~r~-> ~y~The device is already deployed", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
- 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;}
- new Float:x, Float:y, Float:z;
- GetXYInFrontOfPlayer(playerid, x, y, z, 1.0);
- new vehid = CreateVehicle(rc_model_ids[rc_data[playerid][TYPE][slot]], x, y, z, 82.2873, 0x0, 0x0, -1, 0);
- 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
- LinkVehicleToInterior(vehid, GetPlayerInterior(playerid));
- rc_data[playerid][VEH_ID][slot] = vehid;
- rc_data[playerid][DEPLOYED][slot] = true;
- ShowHpBar(playerid, slot, rc_names[rc_data[playerid][TYPE][slot]]);
- if(rc_data[playerid][HAS_HP_MONITOR] != true)
- {
- rc_data[playerid][MONITOR] = SetTimerEx("HpMonitor", 200, true, "d", playerid);
- }
- rc_data[playerid][INTERIOR][slot] = GetPlayerInterior(playerid);
- rc_data[playerid][VIRTUAL_WORLD][slot] = GetPlayerVirtualWorld(playerid);
- return 1;
- }
- else if(!strcmp("conceal", params, true) && slot_included == true)
- {
- if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][DEPLOYED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~Device is currently not deployed", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
- 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;}
- new vehid = rc_data[playerid][VEH_ID][slot];
- //distance check (with ability to conceal the veh without need to disconnect from it)
- 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;}}}
- 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;}}
- new Float: fHp;
- GetVehicleHealth(vehid, fHp);
- rc_data[playerid][HP][slot] = floatround(fHp);
- DestroyVehicle(vehid);
- rc_data[playerid][DEPLOYED][slot] = false;
- HideHpBar(playerid, slot);
- if(PlayerDeployedAny(playerid) != 1){KillTimer(rc_data[playerid][MONITOR]);}
- return 1;
- }
- else if(!strcmp("connect", params, true) && slot_included == true)
- {
- if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][DEPLOYED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~Device is currently not deployed", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
- 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;}
- 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 )
- //range check
- new Float:x, Float:y, Float:z;
- GetVehiclePos(rc_data[playerid][VEH_ID][slot], x, y, z);
- 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;}
- //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)
- 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;}
- PutPlayerInVehicle(playerid, rc_data[playerid][VEH_ID][slot], 0);
- rc_data[playerid][IS_CONTROLLING] = true;
- rc_data[playerid][SLOT_CONTROLLED] = slot;
- DisplayMessage(playerid, "~g~-> ~y~Connection established", 700, DEFAULT_COLOR);
- controller_interior[playerid] = GetPlayerInterior(playerid);
- controller_virtual_world[playerid] = GetPlayerVirtualWorld(playerid);
- SetPlayerInterior(playerid, rc_data[playerid][INTERIOR][slot]);
- SetPlayerVirtualWorld(playerid, rc_data[playerid][VIRTUAL_WORLD][slot]);
- return 1;
- }
- else if(!strcmp("disconnect", params, true))
- {
- slot = rc_data[playerid][SLOT_CONTROLLED]; // so the slot id input is not necessary
- if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][IS_CONTROLLING] != true){DisplayMessage(playerid, "~r~-> ~y~There are no connections at the moment", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][DEPLOYED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~Device is currently not deployed", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
- rc_data[playerid][IS_CONTROLLING] = false;
- SetPlayerInterior(playerid, controller_interior[playerid]);
- SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
- SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
- DisplayMessage(playerid, "~g~-> ~y~Disconnected successfully", 700, DEFAULT_COLOR);
- return 1;
- }
- else if(!strcmp("list", params, true) && strlen(params) > 0)
- {
- SendClientMessage(playerid, DEFAULT_COLOR, "________________________");
- SendClientMessage(playerid, DEFAULT_COLOR, "List of owned RC devices:");
- new i;
- for(i=0; i<MAX_SLOTS; i++)
- {
- new str[100];
- //ternary example c = ( a == b ) ? d : e;
- //owned, deployed, type, veh_id
- if(rc_data[playerid][OWNED][i] == true)
- {
- //rc_names[0-3]
- 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));
- //format(str,sizeof(str), ;
- }
- else
- {
- format(str, sizeof(str), "Slot %d: -", i+1);
- }
- SendClientMessage(playerid, -1, str);
- }
- return 1;
- }
- else if(!strcmp("buy", params, true) && strlen(params) > 0)
- {
- if(IsPlayerInRangeOfPoint(playerid, 5.0, RC_SHOP_POS_X, RC_SHOP_POS_Y, RC_SHOP_POS_Z))
- {
- new str[100];
- //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);
- for(new i=0; i < MAX_RC_MODELS;i++)
- {
- new add[50];format(add, sizeof(add), "%s ($%d)\n", rc_names[i], rc_prices[i]);
- strcat(str,add);
- }
- ShowPlayerDialog(playerid, DIALOG_RC_MODELS, DIALOG_STYLE_LIST, "Available devices", str, "Buy", "Cancel");
- return 1;
- }
- else
- {
- DisplayMessage(playerid, "~r~-> ~y~You're not in the RC shop", 2000, DEFAULT_COLOR);
- return 1;
- }
- }
- else if(!strcmp("explode", params, true) && slot_included == true)
- {
- //may adjust this one if more bomb types will be added
- 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;}
- if(slot < 0 || slot >= MAX_SLOTS){DisplayMessage(playerid, "~r~-> ~y~Invalid slot number", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][OWNED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~The specified slot is empty", 2000, DEFAULT_COLOR); return 1;}
- if(rc_data[playerid][DEPLOYED][slot] != true){DisplayMessage(playerid, "~r~-> ~y~Device is currently not deployed", 2000, DEFAULT_COLOR); return 1;}
- new Float:x, Float:y, Float:z;
- if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == slot)
- {
- SetPlayerInterior(playerid, controller_interior[playerid]);
- SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
- SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
- }
- GetVehiclePos(rc_data[playerid][VEH_ID][slot], x, y, z);
- //new Float:radius, type;
- //may adjust this one if more bomb types will be added
- 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
- if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == slot){rc_data[playerid][IS_CONTROLLING] = false;}
- DestroyVehicle(rc_data[playerid][VEH_ID][slot]);
- rc_data[playerid][DEPLOYED][slot] = false;
- rc_data[playerid][OWNED][slot] = false;
- rc_data[playerid][BOMB][slot] = 0;
- rc_data[playerid][NAVIGATION][slot] = 0;
- new str[64];
- format(str, sizeof(str), "~g~-> ~y~The %s exploded successfully", rc_names[rc_data[playerid][TYPE][slot]]);
- DisplayMessage(playerid, str, 700, DEFAULT_COLOR);
- HideHpBar(playerid, slot);
- if(PlayerDeployedAny(playerid) != 1){KillTimer(rc_data[playerid][MONITOR]);}
- rc_data[playerid][HP][slot] = 5000; //reset to initial value
- ResetExtraFeatures(playerid, slot);
- return 1;
- }
- else if(!strcmp("help", params, true) && strlen(params) > 0)
- {
- SendClientMessage(playerid, DEFAULT_COLOR, "RC Commands:");
- SendClientMessage(playerid, -1, "/rc list {F7F694}(Show list of owned devices)");
- SendClientMessage(playerid, -1, "/rc deploy <slot> {F7F694}(Deploys device)");
- SendClientMessage(playerid, -1, "/rc conceal <slot> {F7F694}(Hides device)");
- SendClientMessage(playerid, -1, "/rc connect <slot> {F7F694}(Gains control)");
- SendClientMessage(playerid, -1, "/rc disconnect{F7F694}(Cancels the controlling mode - the device stays where it was)");
- SendClientMessage(playerid, -1, "/rc explode <slot> {F7F694}(bomb detonation)");
- //
- return 1;
- }
- }
- return 0;
- }
- forward ExplodeBomb(playerid, slot, Float:x,Float:y,Float:z, bomb_strength, bomb_strength_progress, z_angle);
- 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
- {
- new Float:distance=8.0, Float:tempX, Float:tempY;
- new i;
- new ten_at_once=0;
- if(bomb_strength_progress == 1 && z_angle == 0)
- {
- CreateExplosion(x,y, z, 7, 50.0);
- if(bomb_strength >= 4)
- {
- //initial center blast
- for(i = bomb_strength_progress; i <= bomb_strength; i++)
- {
- new j;
- for(j=0; j<360; j += ((360/4)/i))
- {
- tempX = x + (distance * float(i) * floatsin(float(-j), degrees)); // angles in GTA go counter-clockwise, so we need to reverse the retrieved angle
- tempY = y + (distance * float(i) * floatcos(float(-j), degrees));//float(-j), degrees));
- CreateExplosion(tempX, tempY, z, 7, 50.0);
- }
- z_angle = 0;
- }
- }
- if(BOMB_HP_AND_FLASH_EFFECTS){HpAndVelocityEffects(playerid, slot, (bomb_strength >= BOMB_NUCLEAR_THRESHOLD-1)? true:false);}
- }
- for(i = bomb_strength_progress; i <= bomb_strength; i++)
- {
- new j;
- for(j=z_angle; j<360; j += ((360/4)/i))
- {
- ten_at_once++;
- if(ten_at_once == 9)
- {
- SetTimerEx("ExplodeBomb", 1500, false, "ddfffddd", playerid, slot, x,y,z, bomb_strength, i, j);
- return 1;
- }
- tempX = x + (distance * float(i) * floatsin(float(-random(359)), degrees)); // angles in GTA go counter-clockwise, so we need to reverse the retrieved angle
- tempY = y + (distance * float(i) * floatcos(float(-random(359)), degrees));//float(-j), degrees));
- CreateExplosion(tempX, tempY, z + ((i-1) * 7.0), 7, 50.0);
- }
- z_angle = 0;
- }
- return 1;
- }
- HpAndVelocityEffects(playerid, slot, bool:isNuke)//need take account of: -is player controlling the rc now
- {
- //playerid = attacker, i = all potential victims
- new Float:eX, Float:eY, Float:eZ;
- GetVehiclePos(rc_data[playerid][VEH_ID][slot], eX, eY, eZ);
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i)){continue;}
- new Float: fDistance;
- if(rc_data[i][IS_CONTROLLING] == true)
- {
- if(controller_virtual_world[i] != rc_data[playerid][VIRTUAL_WORLD][slot]){continue;}
- if(controller_interior[i] != rc_data[playerid][INTERIOR][slot]){continue;}
- fDistance = GetVehicleDistanceFromPoint(rc_data[playerid][VEH_ID][slot], controller_posX[i], controller_posY[i], controller_posZ[i]);
- }
- else
- {
- if(GetPlayerVirtualWorld(i) != rc_data[playerid][VIRTUAL_WORLD][slot]){continue;}
- if(GetPlayerInterior(i) != rc_data[playerid][INTERIOR][slot]){continue;}
- fDistance = GetPlayerDistanceFromPoint(i, eX, eY, eZ);
- }
- if(fDistance < bomb_ranges[rc_data[playerid][BOMB][slot]])
- {
- //bomb_ranges[rc_data[playerid][BOMB][slot]] // range
- //GetPlayerDistanceFromPoint(i, eX, eY, eZ) //actual distance
- //100 - ((actual_dist / range) * 100)
- new dmg = floatround(100.0 - (( fDistance / bomb_ranges[rc_data[playerid][BOMB][slot]]) * 100.0));
- //new str[50];format(str,sizeof(str),"dmg:%d, distance:%f", dmg, fDistance);
- //SendClientMessage(i, -1, str);
- //get angle between explosion and the victim
- new Float:angle;
- if(rc_data[i][IS_CONTROLLING] == true)
- {
- angle = atan2 (controller_posX[i] - eX, eY - controller_posY[i]) + 180.0;
- //new Float: angle = atan2 (x - RC_SHOP_POS_X, RC_SHOP_POS_Y - y) + 180.0;
- }
- else
- {
- new Float:x,Float:y,Float:z;
- GetPlayerPos(i,x,y,z);
- angle = atan2 (x - eX, eY - y) + 180.0;
- }
- if(isNuke == true) // if nuclear
- {
- SetTimerEx("NukeFlash", 1, false, "dd", i, 255); //divide 255 somehow + add how much hp to decrease
- }
- 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
- new Float:yThrust = floatcos(-angle, degrees) * (float(dmg)/BOMB_VELOCITY_DIV);//float(-j), degrees));
- SetPlayerVelocity(i, xThrust, yThrust, 0.2); // Forces the player to jump (Z velocity + 0.2)
- new Float:x,Float:y,Float:z;
- GetPlayerPos(i,x,y,z);
- PlayerPlaySound(i,1159,x,y,z);
- new Float:hp;
- GetPlayerHealth(i, hp);
- SetPlayerHealth(i, hp - dmg);
- }
- }
- //for vehicles
- if(BOMB_AFFECT_CARS)
- {
- for(new i=0;i<MAX_VEHICLES;i++)
- {
- //could add "if spawned" or something like that
- new Float: fDistance = GetVehicleDistanceFromPoint(i, eX, eY, eZ);
- if(fDistance < bomb_ranges[rc_data[playerid][BOMB][slot]] && fDistance > 0.0)
- {
- //new str[64];format(str,sizeof(str),"distance=%f x=%.0f y=%.0f z=%.0f", fDistance, eX, eY, eZ);
- //SendClientMessage(i,-1,str);
- new Float: hp;
- new dmg = floatround(1000.0 - (( fDistance / bomb_ranges[rc_data[playerid][BOMB][slot]]) * 1000.0));
- new Float:x,Float:y,Float:z;
- GetVehiclePos(i,x,y,z);
- new Float:angle = atan2 (x - eX, eY - y) + 180.0;
- 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
- new Float:yThrust = floatcos(-angle, degrees) * ((float(dmg)/BOMB_VELOCITY_DIV))/10.0;//float(-j), degrees));
- SetVehicleVelocity(i, xThrust, yThrust, 0.2); // Forces the player to jump (Z velocity + 0.2)
- GetVehicleHealth(i, hp);
- SetVehicleHealth(i, hp - dmg);
- //str= "";format(str,sizeof(str),"distance=%.0f dmg=%d angle=%.0f", fDistance, dmg, angle);
- //SendClientMessage(i,-1,str);
- }
- }
- }
- }
- //SetTimerEx("NukeFlash",1000,0,"d",playerid);
- forward NukeFlash(playerid, alpha);
- public NukeFlash(playerid, alpha)
- {
- if(alpha <= 0) //wave arrived
- {
- PlayerTextDrawHide(playerid, Flash[playerid]);
- return 1;
- }
- new color = (4294809088 + alpha);//0xfffd9600
- PlayerTextDrawBoxColor(playerid, Flash[playerid], color);
- PlayerTextDrawShow(playerid,Flash[playerid]);
- SetTimerEx("NukeFlash", 10, false, "dd", playerid, (alpha - 3));
- return 1;
- }
- AppendExtraFeatures(playerid, slot)
- {
- new str[100];
- new str2[10];
- format(str2, sizeof(str2), "{%s}(", COLOR_BLUE);
- strcat(str, str2);
- format(str2, sizeof(str2), "%.0fm", navigation_ranges[rc_data[playerid][NAVIGATION][slot]]);
- strcat(str, str2);
- if(rc_data[playerid][BOMB][slot] > 0){strcat(str,", ");strcat(str, bomb_names[rc_data[playerid][BOMB][slot]]);}
- strcat(str,")");
- if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == slot)
- {
- new str_connect[30];
- format(str_connect, sizeof(str_connect), "{%s} - CONNECTED", COLOR_ORANGE);
- strcat(str, str_connect);
- }
- return str;
- }
- PlayerDeployedAny(playerid)
- {
- new i;
- for(i=0;i<MAX_SLOTS;i++)
- {
- if(rc_data[playerid][DEPLOYED][i])
- {
- return true;
- }
- }
- return false;
- }
- forward HpMonitor(playerid); //now also range monitor
- public HpMonitor(playerid) //monitor hp of all 3 slots, need to use SetTimerEx and pass playerid as a parameter
- {
- //PlayerTextDrawSetString(playerid, hp_bar[playerid][slot][INDICATOR],"..........");
- new i;
- for(i=0;i<MAX_SLOTS;i++)
- {
- if(rc_data[playerid][DEPLOYED][i] == true)
- {
- new Float:hp, vehid = rc_data[playerid][VEH_ID][i];
- GetVehicleHealth(vehid, hp);
- new hp_int = floatround(hp);
- UpdateHpBar(playerid, i, hp_int);
- if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == i)
- {
- //yellow text colour if currently controlled
- PlayerTextDrawLetterSize(playerid, hp_bar[playerid][LABEL][i], 0.4, 0.8);
- PlayerTextDrawColor(playerid, hp_bar[playerid][LABEL][i], DEFAULT_COLOR);
- }
- else
- {
- //white text otherwise
- PlayerTextDrawLetterSize(playerid, hp_bar[playerid][LABEL][i], 0.3, 0.6);
- PlayerTextDrawColor(playerid, hp_bar[playerid][LABEL][i], 0xffffffcc);
- }
- PlayerTextDrawShow(playerid, hp_bar[playerid][LABEL][i]); //re-show
- if(hp_int <= 4250)
- {
- if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == i)
- {
- rc_data[playerid][IS_CONTROLLING] = false;
- SetPlayerInterior(playerid, controller_interior[playerid]);
- SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
- SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
- }
- DestroyVehicle(vehid);
- rc_data[playerid][DEPLOYED][i] = false;
- rc_data[playerid][OWNED][i] = false;
- rc_data[playerid][BOMB][i] = 0;
- rc_data[playerid][NAVIGATION][i] = 0;
- new str[64];
- format(str, sizeof(str), "The %s has been {%s}destroyed{F7F694}.", rc_names[rc_data[playerid][TYPE][i]], COLOR_RED);
- SendClientMessage(playerid, DEFAULT_COLOR, str);
- //format(str, sizeof(str), "~r~-> ~y~The %s has been ~r~destroyed", rc_names[rc_data[playerid][TYPE][i]], COLOR_RED);
- //DisplayMessage(playerid, str, 2000, DEFAULT_COLOR);
- HideHpBar(playerid, i);
- if(PlayerDeployedAny(playerid) != 1){KillTimer(rc_data[playerid][MONITOR]);}
- rc_data[playerid][HP][i] = 5000; //reset to initial value
- ResetExtraFeatures(playerid, i);
- }
- //RANGE MONITOR
- if(rc_data[playerid][IS_CONTROLLING] == true && rc_data[playerid][SLOT_CONTROLLED] == i && rc_data[playerid][NAVIGATION][i] < SATELITE_THRESHOLD)
- {
- new Float: fDistance = GetVehicleDistanceFromPoint(rc_data[playerid][VEH_ID][i], controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
- if(fDistance >= navigation_ranges[rc_data[playerid][NAVIGATION][i]])
- {
- rc_data[playerid][IS_CONTROLLING] = false;
- SetPlayerInterior(playerid, controller_interior[playerid]);
- SetPlayerVirtualWorld(playerid, controller_virtual_world[playerid]);
- SetPlayerPos(playerid, controller_posX[playerid], controller_posY[playerid], controller_posZ[playerid]);
- //DisplayMessage(playerid, "~r~-> ~y~Connection lost, the range is too high", 2000, DEFAULT_COLOR);
- SendClientMessage(playerid, DEFAULT_COLOR, "Connection {950000}lost{F7F694}, the range is too high");
- }
- else if((fDistance * 1.2) >= navigation_ranges[rc_data[playerid][NAVIGATION][i]])
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x,y,z);
- //add sign or something saying the signal is weak
- PlayerPlaySound(playerid,45400,x,y,z);
- DisplayMessage(playerid, "~r~-> ~y~Weak signal", 190, DEFAULT_COLOR);
- }
- }
- }
- }
- }
- ResetExtraFeatures(playerid, slot)
- {
- rc_data[playerid][BOMB][slot] = 0;
- }
- UpdateHpBar(playerid, slot, hp)
- {
- new str_label[11];
- str_label = GetHpBarStringIndicator(playerid, slot, hp);
- PlayerTextDrawSetString(playerid, hp_bar[playerid][INDICATOR][slot],str_label);
- }
- GetHpBarStringIndicator(playerid, slot, hp_int)
- {
- new str[11];
- new color;
- switch(hp_int)
- {
- case 0 .. 4249:
- {
- str = "";
- color = 0x950000FF;
- }
- case 4250 .. 4324:
- {
- str = ".";
- color = 0x950000FF;
- }
- case 4325 .. 4399:
- {
- str = "..";
- color = 0x950000FF;
- }
- case 4400 .. 4474:
- {
- str = "...";
- color = 0x950000FF;
- }
- case 4475 .. 4549:
- {
- str = "....";
- color = DEFAULT_COLOR;
- }
- case 4550 .. 4624:
- {
- str = ".....";
- color = DEFAULT_COLOR;
- }
- case 4625 .. 4699:
- {
- str = "......";
- color = DEFAULT_COLOR;
- }
- case 4700 .. 4774:
- {
- str = ".......";
- color = DEFAULT_COLOR;
- }
- case 4775 .. 4849:
- {
- str = "........";
- color = 0x008500FF;
- }
- case 4850 .. 4924:
- {
- str = ".........";
- color = 0x008500FF;
- }
- case 4925 .. 5499:
- {
- str = "..........";
- color = 0x008500FF;
- }
- default:
- {
- str = "..........";
- color = 0x008500FF;
- }
- }
- PlayerTextDrawColor(playerid, hp_bar[playerid][INDICATOR][slot], color);
- PlayerTextDrawBackgroundColor(playerid, hp_bar[playerid][INDICATOR][slot], color);
- PlayerTextDrawShow(playerid, hp_bar[playerid][INDICATOR][slot]);
- return str;
- }
- public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
- {
- if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted + if heliblades
- {
- new
- infoString[128],
- weaponName[24],
- victimName[MAX_PLAYER_NAME],
- attackerName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, victimName, sizeof (victimName));
- GetPlayerName(issuerid, attackerName, sizeof (attackerName));
- GetWeaponName(weaponid, weaponName, sizeof (weaponName));
- format(infoString, sizeof(infoString), "%s has made %.0f damage to %s, weapon: %s", attackerName, amount, victimName, weaponName);
- SendClientMessageToAll(-1, infoString);
- //new Float:health;
- //GetPlayerHealth(playerid,health);
- //SetPlayerHealth(playerid, health+amount);
- }
- return 1;
- }
- public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
- {
- if(rc_data[playerid][IS_CONTROLLING] == true)
- {
- return 0;
- }
- return 1;
- }
- /*
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- TextDrawDestroy(hp_bar[playerid][i][BACKGROUND]);
- return 1;
- }
- public OnPlayerDeath(playerid)
- {
- TextDrawHideForPlayer(playerid,hp_bar[playerid][i][BACKGROUND]);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- TextDrawSetString(hp_bar[playerid][i][BACKGROUND],"..........");
- TextDrawShowForPlayer(playerid,hp_bar[playerid][i][BACKGROUND]);
- return 1;
- }
- */
- /*
- IsVehicleRc( vehicleid ){//defines the RC vehicles.
- new model = GetVehicleModel(vehicleid);
- switch(model)
- {
- case RC_GOBLIN, RC_BARON, RC_BANDIT, RC_MINITANK: return 1;
- default: return 0;
- }
- return 0;
- }
- */
- stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:z, Float:distance)
- {
- // Created by Y_Less
- new Float:a;
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, a);
- if (GetPlayerVehicleID(playerid)) {
- GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
- }
- x += (distance * floatsin(-a, degrees));
- y += (distance * floatcos(-a, degrees));
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(response)// They pressed the first button.
- {
- switch(dialogid)// If you only have one dialog, then this isn't required, but it's neater for when you implement more dialogs.
- {
- case DIALOG_RC_MODELS:// Picking device "Bandit ($)\nBaron ($)\nGoblin ($)\nMinitank ($)"
- {
- if(GetPlayerMoney(playerid) < rc_prices[listitem]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- new slot = AvailableSlot(playerid);
- if(slot != NO_SLOTS_AVAILABLE)
- {
- last_bought_slot[playerid] = slot;
- GivePlayerMoney(playerid, - rc_prices[listitem]);
- rc_data[playerid][OWNED][slot] = true;
- rc_data[playerid][TYPE][slot] = listitem;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- /*
- switch(listitem)// Checking which listitem was selected
- {
- case 0:// Bandit
- {
- if(GetPlayerMoney(playerid) < RC_BANDIT_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- new slot = AvailableSlot(playerid);
- if(slot != NO_SLOTS_AVAILABLE)
- {
- GivePlayerMoney(playerid, - RC_BANDIT_PRICE);
- rc_data[playerid][OWNED][slot] = true;
- rc_data[playerid][TYPE][slot] = 0;
- last_bought_slot[playerid] = slot;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- }
- case 1: // Baron
- {
- if(GetPlayerMoney(playerid) < RC_BARON_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- new slot = AvailableSlot(playerid);
- if(slot != NO_SLOTS_AVAILABLE)
- {
- GivePlayerMoney(playerid, - RC_BARON_PRICE);
- rc_data[playerid][OWNED][slot] = true;
- rc_data[playerid][TYPE][slot] = 1;
- last_bought_slot[playerid] = slot;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- }
- case 2: // Goblin
- {
- if(GetPlayerMoney(playerid) < RC_GOBLIN_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- new slot = AvailableSlot(playerid);
- if(slot != NO_SLOTS_AVAILABLE)
- {
- GivePlayerMoney(playerid, - RC_GOBLIN_PRICE);
- rc_data[playerid][OWNED][slot] = true;
- rc_data[playerid][TYPE][slot] = 2;
- last_bought_slot[playerid] = slot;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- }
- case 3: // Minitank
- {
- if(GetPlayerMoney(playerid) < RC_MINITANK_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- new slot = AvailableSlot(playerid);
- if(slot != NO_SLOTS_AVAILABLE)
- {
- GivePlayerMoney(playerid, - RC_MINITANK_PRICE);
- rc_data[playerid][OWNED][slot] = true;
- rc_data[playerid][TYPE][slot] = 3;
- last_bought_slot[playerid] = slot;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- }
- }
- */
- }
- case DIALOG_EXTRA_FEATURES:// extra_features selection
- {
- //new slot = last_bought_slot[playerid];
- switch(listitem)// Checking which listitem was selected
- {
- case 0: //Bombs
- {
- new str[150];
- //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);
- for(new i=1; i < MAX_BOMB_TYPES;i++)
- {
- new add[50];format(add, sizeof(add), "%s ($%d)\n", bomb_names[i], bomb_prices[i]);
- strcat(str,add);
- }
- ShowPlayerDialog(playerid, DIALOG_BOMB_TYPE, DIALOG_STYLE_LIST, "Bomb type", str, "Buy", "Cancel");
- }
- case 1: //Navigation
- {
- new str[150];
- //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]);
- for(new i=1; i < MAX_NAVIGATION_TYPES;i++)
- {
- new add[50];format(add, sizeof(add), "%s - %.0fm ($%d)\n", navigation_names[i], navigation_ranges[i], navigation_prices[i]);
- strcat(str,add);
- }
- ShowPlayerDialog(playerid, DIALOG_NAVIGATION_TYPE, DIALOG_STYLE_LIST, "Navigation type", str, "Buy", "Cancel");
- //new navigation_names[3] = {"", "2.4Ghz Remote controller", "Satelite support"};
- //new navigation_ranges[3] = {0.0, 300.0, 6000.0};
- }
- case 2: //
- {
- }
- case 3: //
- {
- }
- }
- }
- case DIALOG_BOMB_TYPE:// bomb size selection
- {
- new slot = last_bought_slot[playerid];
- if(GetPlayerMoney(playerid) < bomb_prices[listitem + 1]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- GivePlayerMoney(playerid, - bomb_prices[listitem + 1]);
- rc_data[playerid][BOMB][slot] = listitem + 1;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- /*
- switch(listitem)// SMALL_BOMB_PRICE, BOMB_PRICE, LARGE_BOMB_PRICE, HUGE_BOMB_PRICE, SMALL_NUCLEAR_BOMB_PRICE
- {
- case 0: //small bomb
- {
- if(GetPlayerMoney(playerid) < SMALL_BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- GivePlayerMoney(playerid, - SMALL_BOMB_PRICE);
- rc_data[playerid][BOMB][slot] = 1;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- case 1: //bomb
- {
- if(GetPlayerMoney(playerid) < BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- GivePlayerMoney(playerid, - BOMB_PRICE);
- rc_data[playerid][BOMB][slot] = 2;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- case 2: //large bomb
- {
- if(GetPlayerMoney(playerid) < LARGE_BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- GivePlayerMoney(playerid, - LARGE_BOMB_PRICE);
- rc_data[playerid][BOMB][slot] = 3;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- case 3: //huge bomb
- {
- if(GetPlayerMoney(playerid) < HUGE_BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- GivePlayerMoney(playerid, - HUGE_BOMB_PRICE);
- rc_data[playerid][BOMB][slot] = 4;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- case 4: //small nuclear weapon
- {
- if(GetPlayerMoney(playerid) < SMALL_NUCLEAR_BOMB_PRICE) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- GivePlayerMoney(playerid, - SMALL_NUCLEAR_BOMB_PRICE);
- rc_data[playerid][BOMB][slot] = 5;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- case 5: //
- {
- }
- }
- */
- }
- case DIALOG_NAVIGATION_TYPE:
- {
- new slot = last_bought_slot[playerid];
- if(GetPlayerMoney(playerid) < navigation_prices[listitem + 1]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- GivePlayerMoney(playerid, - navigation_prices[listitem + 1]);
- rc_data[playerid][NAVIGATION][slot] = listitem + 1;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- /*
- switch(listitem)//
- {
- case 0: //RC24GHZ_PRICE
- {
- if(GetPlayerMoney(playerid) < navigation_prices[1]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- GivePlayerMoney(playerid, - navigation_prices[1]);
- rc_data[playerid][NAVIGATION][slot] = 1;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- case 1: //
- {
- if(GetPlayerMoney(playerid) < navigation_prices[2]) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
- GivePlayerMoney(playerid, - navigation_prices[2]);
- rc_data[playerid][NAVIGATION][slot] = 2;
- PickExtraFeatures(playerid, slot);
- DisplayMessage(playerid, "~g~-> ~y~Purchased", 700, DEFAULT_COLOR);
- }
- case 2: //
- {
- PickExtraFeatures(playerid, slot);
- }
- case 3: //
- {
- PickExtraFeatures(playerid, slot);
- }
- case 4: //
- {
- PickExtraFeatures(playerid, slot);
- }
- }
- */
- }
- }
- }
- return 1;
- }
- PickExtraFeatures(playerid, slot)
- {
- new str[255];
- new bool:showAny; //to check if not everyone was bought
- //new str_price[15];
- if(rc_data[playerid][BOMB][slot] == 0)
- {
- showAny = true;
- strcat(str, "Bomb");
- strcat(str, "\n");
- }
- else {strcat(str, "-\n");}
- if(rc_data[playerid][NAVIGATION][slot] == 0)
- {
- showAny = true;
- strcat(str, "Navigation");
- strcat(str, "\n");
- }
- else {strcat(str, "-\n");}
- if(showAny == true){ShowPlayerDialog(playerid, DIALOG_EXTRA_FEATURES, DIALOG_STYLE_LIST, "Extra features", str, "Buy", "Cancel");}
- }
- //forward byte AvailableSlot(playerid)
- AvailableSlot(playerid)
- {
- new i;
- for (i=0; i < MAX_SLOTS; i++)
- {
- if(rc_data[playerid][OWNED][i] != true)return i;
- }
- return NO_SLOTS_AVAILABLE;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- stock sscanf(string[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(string))
- #else
- if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- stringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (string[stringPos] && string[stringPos] <= ' ')
- {
- stringPos++;
- }
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = string[stringPos];
- do
- {
- stringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new changestr[16], changepos = 0, strpos = stringPos;
- while(changepos < 16 && string[strpos] && string[strpos] != delim)
- {
- changestr[changepos++] = string[strpos++];
- }
- changestr[changepos] = '\0';
- setarg(paramPos,0,_:floatstr(changestr));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- stringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = stringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = string[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- string[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - stringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, string[stringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- string[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- stringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
- {
- stringPos++;
- }
- while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
- {
- stringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement