Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shooting Training - Idea By Avi Raj
- // Mapping and Scripting By Avi Raj
- // Thanks for using it.
- #include <a_samp>
- #include <zcmd>
- new InGame[MAX_PLAYERS];
- new PlayerObjectHP[MAX_PLAYERS][MAX_OBJECTS];
- new bool:PlayerObjectDamage[MAX_PLAYERS][MAX_OBJECTS];
- new p_OBJECTS[MAX_PLAYERS][16];
- new p_DestroyedCounts[MAX_PLAYERS],
- p_GameTicks[MAX_PLAYERS];
- #define DIALOG_SKILLS 1
- public OnPlayerConnect(playerid)
- {
- InGame[playerid] = 0;
- p_GameTicks[playerid] = 0;
- p_DestroyedCounts[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- p_DestroyedCounts[playerid] = 0;
- p_GameTicks[playerid] = 0;
- InGame[playerid] = 0;
- CreatePlayerObject(playerid,12918, 39.37264, 1952.38953, 15.43090, 0.00000, 0.00000, 0.00000);
- CreatePlayerObject(playerid,983, 44.16277, 1936.70996, 17.32400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 36.22247, 1936.71204, 17.32400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 42.60558, 1936.70715, 17.32400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 36.21048, 1933.56628, 17.32400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 42.62512, 1933.58105, 17.32400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 44.19323, 1933.59900, 17.32400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 44.19320, 1933.59900, 18.52400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 36.21050, 1933.56628, 18.52400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 42.62510, 1933.58105, 18.52400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 36.19595, 1934.16809, 19.06000, 0.00000, 90.00000, 90.00000);
- CreatePlayerObject(playerid,983, 36.16003, 1935.38806, 19.06000, 0.00000, 90.00000, 90.00000);
- CreatePlayerObject(playerid,983, 36.18409, 1936.60950, 19.06000, 0.00000, 90.00000, 90.00000);
- CreatePlayerObject(playerid,983, 42.53846, 1934.18225, 19.06000, 0.00000, 90.00000, 90.00000);
- CreatePlayerObject(playerid,983, 44.17745, 1934.19397, 19.06000, 0.00000, 90.00000, 90.00000);
- CreatePlayerObject(playerid,983, 42.58401, 1935.42004, 19.06000, 0.00000, 90.00000, 90.00000);
- CreatePlayerObject(playerid,983, 44.17020, 1935.41870, 19.06000, 0.00000, 90.00000, 90.00000);
- CreatePlayerObject(playerid,983, 42.55861, 1936.62244, 19.06000, 0.00000, 90.00000, 90.00000);
- CreatePlayerObject(playerid,983, 44.14478, 1936.62158, 19.06000, 0.00000, 90.00000, 90.00000);
- CreatePlayerObject(playerid,983, 36.17381, 1952.75635, 17.32400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 42.55510, 1952.73096, 17.32400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 44.14042, 1952.72888, 17.32400, 0.00000, 0.00000, 90.00000);
- CreatePlayerObject(playerid,983, 32.98570, 1949.59143, 17.32400, 0.00000, 0.00000, 0.00000);
- CreatePlayerObject(playerid,983, 32.99252, 1943.18262, 17.32400, 0.00000, 0.00000, 0.00000);
- CreatePlayerObject(playerid,983, 33.00263, 1936.79358, 17.32400, 0.00000, 0.00000, 0.00000);
- CreatePlayerObject(playerid,983, 47.35019, 1936.75378, 17.32400, 0.00000, 0.00000, 0.00000);
- CreatePlayerObject(playerid,983, 47.38920, 1943.13135, 17.32400, 0.00000, 0.00000, 0.00000);
- CreatePlayerObject(playerid,983, 47.36412, 1949.49487, 17.32400, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][0] = CreatePlayerObject(playerid,1786, 34.59750, 1948.22119, 17.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][1] = CreatePlayerObject(playerid,1786, 36.76123, 1949.06116, 17.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][2] = CreatePlayerObject(playerid,1786, 40.29044, 1950.06531, 17.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][3] = CreatePlayerObject(playerid,1786, 42.33493, 1949.07739, 17.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][4] = CreatePlayerObject(playerid,1786, 44.31467, 1950.03711, 17.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][5] = CreatePlayerObject(playerid,1786, 46.28563, 1948.97021, 17.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][6] = CreatePlayerObject(playerid,1786, 46.43850, 1947.93774, 16.93660, 0.00000, 0.00000, -40.00000);
- p_OBJECTS[playerid][7] = CreatePlayerObject(playerid,1786, 34.22170, 1946.69580, 16.93660, 0.00000, 0.00000, 47.00000);
- p_OBJECTS[playerid][8] = CreatePlayerObject(playerid,1786, 40.28210, 1950.14075, 16.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][9] = CreatePlayerObject(playerid,1786, 38.77774, 1949.08057, 16.86600, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][10] = CreatePlayerObject(playerid,1786, 40.74410, 1951.16272, 18.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][11] = CreatePlayerObject(playerid,1786, 38.72364, 1950.07544, 18.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][12] = CreatePlayerObject(playerid,1786, 34.42710, 1951.10791, 18.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][13] = CreatePlayerObject(playerid,1786, 36.43932, 1950.42993, 18.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][14] = CreatePlayerObject(playerid,1786, 44.41322, 1951.03076, 18.73660, 0.00000, 0.00000, 0.00000);
- p_OBJECTS[playerid][15] = CreatePlayerObject(playerid,1786, 42.22642, 1949.95215, 18.73660, 0.00000, 0.00000, 0.00000);
- for(new i; i< 16; i++) {
- PlayerObjectDamage[playerid][p_OBJECTS[playerid][i]] = true;
- }
- for(new i; i< MAX_OBJECTS; i++) {
- if(!IsValidPlayerObject(playerid, i)) continue;
- PlayerObjectHP[playerid][i] = 30;
- }
- return 1;
- }
- public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
- {
- if(hittype == BULLET_HIT_TYPE_PLAYER_OBJECT) {
- if(IsValidPlayerObject(playerid, hitid)) {
- if(PlayerObjectDamage[playerid][hitid] == true) {
- PlayerObjectHP[playerid][hitid] -= random(10) + 1;
- if(PlayerObjectHP[playerid][hitid] <= 0) { //If the HP goes to 0 or goes lesser than 0;
- DestroyPlayerObject(playerid, hitid); //We're destroying the PLAYER's OBJECT then, not a global one.
- PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
- p_DestroyedCounts[playerid]++;
- new str[60];
- format(str, sizeof(str), "~Y~OBJECT~R~ DESTROYED!~N~~G~REMAINING ONES ~W~:~R~ %d", 16-p_DestroyedCounts[playerid]);
- GameTextForPlayer(playerid, str, 1800, 3);
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- InGame[playerid] = 0;
- //We'll loop through every objects at first.
- for(new i; i< MAX_OBJECTS; i++) {
- //Then, we'll see if it's a player object or not.
- if(!IsValidPlayerObject(playerid, i)) continue; //If it's not a valid player object, it will skip that loop value.
- DestroyPlayerObject(playerid, i); //In case if there's any player objects, it will be destroying them.
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 1)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0:
- {
- GivePlayerWeapon(playerid, WEAPON_MP5, 1000);
- SendClientMessage(playerid, 0xFFFFAA00,"Easy Level Selected - Game Started! NOTE : There may be objects which are kept hidden.");
- InGame[playerid] = 1;
- p_GameTicks[playerid] = GetTickCount();
- }
- case 1:
- {
- SendClientMessage(playerid, 0xFFFFAA00,"Easy Level Selected - Game Started! NOTE : There may be objects which are kept hidden.");
- GivePlayerWeapon(playerid, WEAPON_DEAGLE, 1000);
- InGame[playerid] = 1;
- p_GameTicks[playerid] = GetTickCount();
- }
- case 2:
- {
- SendClientMessage(playerid, 0xFFFFAA00,"Easy Level Selected - Game Started! NOTE : There may be objects which are kept hidden.");
- GivePlayerWeapon(playerid, WEAPON_RIFLE, 1000);
- InGame[playerid] = 1;
- p_GameTicks[playerid] = GetTickCount();
- }
- }
- }
- return 1;
- }
- return 0;
- }
- CMD:game(playerid, params[])
- {
- SendClientMessage(playerid, 0xFFFFAA00,"Welcome to Shooting Minigame - By Avi Raj");
- ResetPlayerWeapons(playerid);
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST,"Select Level","Easy\nMedium\nDifficult","SELECT","");
- SetPlayerPos(playerid, 40.1007,1935.5529,17.6406);
- SetPlayerFacingAngle(playerid,1.5626);
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(p_DestroyedCounts[playerid] >= 16)
- {
- new str[128];
- format(str, sizeof(str), "You've successfully completed the shooting minigame in %d seconds!", (GetTickCount() - p_GameTicks[playerid]) / 1000);
- SendClientMessage(playerid, 0xFF0000, str);
- InGame[playerid] = 0;
- SpawnPlayer(playerid);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement