Advertisement
Guest User

Fappin N' Slappin'

a guest
May 19th, 2012
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.83 KB | None | 0 0
  1. //  Fappin' N' Slappin' - It's (kinda) exactly how it sounds!
  2. //
  3. //  Description:
  4. //      Basically a game of tig. (If you're British you'll know what that is.)
  5. //      The aim of 'tig' is to touch someone. Once they've been touched, they can't move until someone frees them.
  6. //      The last one to be touched is the next 'tigger'.
  7. //      Fappin' N' Slappin' is basically the same without the ability to be freed.
  8. //      Once 'tagged' with the dildo (or whatever you set as SLAP_GUN), you die, and spectate The Slapper (tigger).
  9. //      When The Slapper has killed everyone with his instagib dildo, the game restarts.
  10. //      When two people have spawned it will begin deciding a new player to take over the role of The Slapper.
  11. //
  12. //  Basic information:
  13. //      An RCON-enabled admin can start the game prematurely with /start. It will randomly pick a player to be The Slapper.
  14. //      The arena is the KACC military fuels. There are three spawns; feel free to add more on line 37. (new Float:SlapSpawn[][3])
  15. //      Or, if you'd prefer, you can change the arena completely. For interiors, remember to add SetPlayerInterior to the spawns.
  16. //      Currently 6 classes, you can add as many as you like.
  17. //
  18. //  Basic script, add whatever the hell you want to it.
  19. //  Don't care about credits, either.
  20.  
  21. #include a_samp
  22.  
  23. #define SLAP_GUN 10 // Purple Dildo - Change to whatever you want (can be any weapon, not just melee!).
  24. #define FREEZE_ON_SPAWN // Comment to disable freezing before round begins. Will still freeze "Slapper" for 5-second head start.
  25.  
  26. main(){}
  27.  
  28. new
  29.     bool:DildoChosen = false,
  30.     DildoSlapper = INVALID_PLAYER_ID,
  31.     bool:RoundStarted = false,
  32.     bool:Dead[MAX_PLAYERS] = false,
  33.     currPlayers = 0,
  34.     currDead = 0,
  35.     bool:Restarting = false,
  36.     Slapping,
  37.     Starting,
  38.     Unfreezing;
  39.    
  40. new Float:SlapSpawn[][3] =
  41.     {
  42.         {2502.0,2777.0,11.0},
  43.         {2586.0,2823.0,11.0},
  44.         {2619.0,2719.0,37.0}
  45.     };
  46.  
  47. public OnGameModeInit()
  48. {
  49.     SetGameModeText("Fappin' N' Slappin'"); //Set the gamemode text.
  50.     UsePlayerPedAnims(); //Stop people have a speed advantage due to skin animations.
  51.     EnableStuntBonusForAll(false); //Make sure people don't get moneys for stunting in any vehicles somehow.
  52.     DisableInteriorEnterExits(); //Make sure people can't hide inside interiors.
  53.     SetWorldTime(12); //Make sure it's nice and bright for the players to get slapped.
  54.     ShowPlayerMarkers(1); //Players are visible (0xFFFFFFFF), The Slapper
  55.     ShowNameTags(false); //Make sure players don't 'metagame' The Slapper.
  56.     AllowInteriorWeapons(true); //In case of interior arenas.
  57.     SetWeather(0); //Make sure it's nice and bright for the players to get slapped.
  58.     ManualVehicleEngineAndLights(); //Prevent any way of driving cars client-side without using an engine starter (eg CLEO)
  59.     if(currPlayers < 0) currPlayers = FixPlayers(); //Used to make sure enough players are online to start the game.
  60.     AddPlayerClass(296, SlapSpawn[0][0], SlapSpawn[0][1], SlapSpawn[0][2], 0.0, 0, 0, 0, 0, 0, 0);
  61.     AddPlayerClass(28, SlapSpawn[1][0], SlapSpawn[1][1], SlapSpawn[1][2], 0.0, 0, 0, 0, 0, 0, 0);
  62.     AddPlayerClass(29, SlapSpawn[2][0], SlapSpawn[2][1], SlapSpawn[2][2], 0.0, 0, 0, 0, 0, 0, 0);
  63.     AddPlayerClass(178, SlapSpawn[0][0], SlapSpawn[0][1], SlapSpawn[0][2], 0.0, 0, 0, 0, 0, 0, 0);
  64.     AddPlayerClass(120, SlapSpawn[1][0], SlapSpawn[1][1], SlapSpawn[1][2], 0.0, 0, 0, 0, 0, 0, 0);
  65.     AddPlayerClass(299, SlapSpawn[2][0], SlapSpawn[2][1], SlapSpawn[2][2], 0.0, 0, 0, 0, 0, 0, 0);
  66.     Restarting = false; //Is the server restarting? Stops the "The Slapper has left the game, restarting!" bug when GMXing.
  67. }
  68.  
  69. stock FixPlayers()
  70. {
  71.     new O;
  72.     for(new i; i < GetMaxPlayers(); i++)
  73.     {
  74.         if(IsPlayerConnected(i))
  75.         {
  76.             O += 1;
  77.         }
  78.     }
  79.     return O;
  80. }
  81.  
  82. public OnPlayerConnect(playerid)
  83. {
  84.     new s[128];
  85.     format(s, 128, "[SERVER]{FFFFFF}: {FFAA00}%s{FFFFFF} has {00AA00}joined{FFFFFF} the game!", N(playerid));
  86.     SendClientMessageToAll(0x33CCFF00, s);
  87.     Dead[playerid] = false;
  88.     currPlayers = FixPlayers();
  89.     if(currPlayers > 1)
  90.     {
  91.         if(RoundStarted == true) return;
  92.         if(DildoChosen == false && !Slapping)
  93.         {
  94.             Slapping = SetTimer("ChooseSlapper", 5000, 0);
  95.             SendClientMessageToAll(0x33CCFF00, "[SERVER]{FFFFFF}: Now choosing The Slapper!");
  96.         }
  97.     }
  98.     return;
  99. }
  100.  
  101. public OnPlayerCommandText(playerid, cmdtext[])
  102. {
  103.     if(!strcmp(cmdtext, "/start", true))
  104.     {
  105.         if(IsPlayerAdmin(playerid))
  106.         {
  107.             DildoSlapper = (random(FixPlayers()) - 1);
  108.             for(new i; i < GetMaxPlayers(); i++)
  109.             {
  110.                 TogglePlayerControllable(i, true);
  111.             }
  112.             GameTextForAll("~g~GO~w~!", 5000, 5);
  113.             currDead = 0;
  114.             UnfreezeSlapper();
  115.             if(Slapping) KillTimer(Slapping);
  116.             if(Starting) KillTimer(Starting);
  117.             if(Unfreezing) KillTimer(Unfreezing);
  118.         }
  119.         return 1;
  120.     }
  121.     if(!strcmp(cmdtext, "/credits", true))
  122.     {
  123.         return SendClientMessage(playerid, 0xC2A2DA00, "[INFO]{FFFFFF}: Original Fap N' Slap - [FMJ]PowerSurge/Skelebob9/Joey_Tucker");
  124.     }
  125.     return 1;
  126. }
  127.  
  128. public OnPlayerRequestClass(playerid, classid)
  129. {
  130.     switch(classid)
  131.     {
  132.         case 0,3:
  133.         {
  134.             SetPlayerPos(playerid, SlapSpawn[0][0], SlapSpawn[0][1], SlapSpawn[0][2]);
  135.             SetPlayerFacingAngle(playerid, 0.0);
  136.             SetPlayerCameraPos(playerid, SlapSpawn[0][0], SlapSpawn[0][1]+3, SlapSpawn[0][2]);
  137.             SetPlayerCameraLookAt(playerid, SlapSpawn[0][0], SlapSpawn[0][1], SlapSpawn[0][2]);
  138.         }
  139.         case 1,4:
  140.         {
  141.             SetPlayerPos(playerid, SlapSpawn[1][0], SlapSpawn[0][1], SlapSpawn[0][2]);
  142.             SetPlayerFacingAngle(playerid, 0.0);
  143.             SetPlayerCameraPos(playerid, SlapSpawn[1][0], SlapSpawn[0][1]+3, SlapSpawn[0][2]);
  144.             SetPlayerCameraLookAt(playerid, SlapSpawn[1][0], SlapSpawn[0][1], SlapSpawn[0][2]);
  145.         }
  146.         case 2,5:
  147.         {
  148.             SetPlayerPos(playerid, SlapSpawn[2][0], SlapSpawn[0][1], SlapSpawn[0][2]);
  149.             SetPlayerFacingAngle(playerid, 0.0);
  150.             SetPlayerCameraPos(playerid, SlapSpawn[2][0], SlapSpawn[0][1]+3, SlapSpawn[0][2]);
  151.             SetPlayerCameraLookAt(playerid, SlapSpawn[2][0], SlapSpawn[0][1], SlapSpawn[0][2]);
  152.         }
  153.     }
  154.     return 1;
  155. }
  156.  
  157. public OnPlayerDeath(playerid, killerid, reason)
  158. {
  159.     if(reason != SLAP_GUN || killerid != DildoSlapper)
  160.     {
  161.         SpawnPlayer(playerid);
  162.     }
  163.     if(playerid == DildoSlapper)
  164.     {
  165.         EndGame();
  166.     }
  167. }
  168.  
  169. public OnPlayerDisconnect(playerid)
  170. {
  171.     if(Restarting == false)
  172.     {
  173.         new s[128];
  174.         format(s, 128, "[SERVER]{FFFFFF}: {FFAA00}%s{FFFFFF} has {FF0000}left{FFFFFF} the game!", N(playerid));
  175.         SendClientMessageToAll(0x33CCFF00, s);
  176.         Dead[playerid] = false;
  177.         currPlayers -= FixPlayers();
  178.         if(playerid == DildoSlapper)
  179.         {
  180.             GameTextForAll("~r~THE SLAPPER HAS LEFT~w~ ~n~RESTARTING", 7500, 5);
  181.             SendRconCommand("gmx");
  182.         }
  183.     }
  184.     return;
  185. }
  186.  
  187. stock EndGame()
  188. {
  189.     for(new u; u < GetMaxPlayers(); u++)
  190.     {
  191.         if(u != DildoSlapper && Dead[u] == true)
  192.         {
  193.             new s[128];
  194.             format(s, 128, "~b~%s ~w~wins~w~!~n~~r~RESTARTING", N(DildoSlapper));
  195.             GameTextForAll(s, 5000, 5);
  196.         }
  197.     }
  198.     currDead = 0;
  199.     currPlayers = 0;
  200.     DildoChosen = false;
  201.     DildoSlapper = INVALID_PLAYER_ID;
  202.     Restarting = true;
  203.     if(Slapping) KillTimer(Slapping);
  204.     if(Starting) KillTimer(Starting);
  205.     if(Unfreezing) KillTimer(Unfreezing);
  206.     SendRconCommand("gmx");
  207.     return;
  208. }
  209.  
  210. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
  211. {
  212.     if(weaponid == SLAP_GUN && issuerid == DildoSlapper)
  213.     {
  214.         GameTextForPlayer(playerid, "~r~DEAD~w~!", 3000, 5);
  215.         GameTextForPlayer(playerid, "~g~KILLED~w~!", 3000, 5);
  216.         SendDeathMessage(issuerid, playerid, SLAP_GUN);
  217.         Dead[playerid] = true;
  218.         currDead++;
  219.         TogglePlayerSpectating(playerid, true);
  220.         PlayerSpectatePlayer(playerid, issuerid, SPECTATE_MODE_NORMAL);
  221.         if(currDead == (FixPlayers() - 1))
  222.         {
  223.             EndGame();
  224.         }
  225.     }
  226.     return;
  227. }
  228.  
  229. public OnPlayerSpawn(playerid)
  230. {
  231.     new r;
  232.     r = random(sizeof(SlapSpawn));
  233.     if(DildoChosen == true)
  234.     {
  235.         if(RoundStarted == true)
  236.         {
  237.             TogglePlayerSpectating(playerid, true);
  238.             PlayerSpectatePlayer(playerid, DildoSlapper, SPECTATE_MODE_NORMAL);
  239.             new
  240.                 s[128];
  241.             format(s, 128, "[SERVER]{FFFFFF}: The round has already started with {00AA00}%s{FFFFFF} as The Slapper. Please wait until next round.", N(DildoSlapper));
  242.             SendClientMessage(playerid, 0x33CCFF00, s);
  243.             Dead[playerid] = true;
  244.             SetPlayerColor(playerid, 0xAAAAAA00); //Grey colour (spectating), not visible on map
  245.         }
  246.         else
  247.         {
  248.             SetPlayerPos(playerid, SlapSpawn[r][0], SlapSpawn[r][1], SlapSpawn[r][2]);
  249.             #if defined FREEZE_ON_SPAWN
  250.                 TogglePlayerControllable(playerid, false);
  251.             #endif
  252.             new
  253.                 s[128];
  254.             format(s, 128, "[SERVER]{FFFFFF}: The round is about to start with {00AA00}%s{FFFFFF} as The Slapper.", N(DildoSlapper));
  255.             SendClientMessage(playerid, 0x33CCFF00, s);
  256.             Dead[playerid] = false;
  257.             SetPlayerColor(playerid, 0xFFFFFFFF); //White colour, visible on map
  258.         }
  259.     }
  260.     else
  261.     {
  262.         SetPlayerPos(playerid, SlapSpawn[r][0], SlapSpawn[r][1], SlapSpawn[r][2]);
  263.         #if defined FREEZE_ON_SPAWN
  264.             TogglePlayerControllable(playerid, false);
  265.         #endif
  266.         new
  267.             s[128];
  268.         format(s, 128, "[SERVER]{FFFFFF}: Deciding The Slapper. Currently, {00AA00}no one{FFFFFF} is The Slapper.");
  269.         SendClientMessage(playerid, 0x33CCFF00, s);
  270.         Dead[playerid] = false;
  271.         SetPlayerColor(playerid, 0xFFFFFFFF);
  272.     }
  273.     SetPlayerHealth(playerid, 10000);
  274.     return;
  275. }
  276.  
  277. forward ChooseSlapper();
  278. public ChooseSlapper()
  279. {
  280.     if(FixPlayers() > 1)
  281.     {
  282.         new r = random(FixPlayers());
  283.         if(IsPlayerConnected(r))
  284.         {
  285.             KillTimer(Slapping);
  286.             if(Starting) KillTimer(Starting);
  287.             DildoSlapper = (r);
  288.             DildoChosen = true;
  289.             Starting = SetTimer("StartRound", 5000, 0);
  290.             TogglePlayerControllable(DildoSlapper, false);
  291.         }
  292.         else
  293.         {
  294.             ChooseSlapper();
  295.         }
  296.         return;
  297.     }
  298. }
  299.  
  300. /*stock formatBool(bool:Bool) //For pre-release debugging
  301. {
  302.     new s[5];
  303.     if(Bool == true) s = "Yes";
  304.     else s = "No";
  305.     return s;
  306. }*/
  307.  
  308. forward StartRound();
  309. public StartRound()
  310. {
  311.     if(FixPlayers() > 1)
  312.     {
  313.         if(DildoChosen == true)
  314.         {
  315.             if(IsPlayerConnected(DildoSlapper))
  316.             {
  317.                 if(GetPlayerState(DildoSlapper) != PLAYER_STATE_WASTED)
  318.                 {
  319.                     RoundStarted = true;
  320.                     SendClientMessageToAll(0xC2A2DAFF, "[INFO]{FFFFFF}: The round has begun!");
  321.                     for(new i; i < GetMaxPlayers(); i++)
  322.                     {
  323.                         if(i != DildoSlapper)
  324.                         {
  325.                             TogglePlayerControllable(i, true);
  326.                             GameTextForPlayer(i, "~g~GO~w~!", 5000, 5);
  327.                             currDead = 0;
  328.                         }
  329.                         else
  330.                         {
  331.                             GameTextForPlayer(DildoSlapper, "WAIT ~r~5~w~ seconds!", 5000, 5);
  332.                             Unfreezing = SetTimer("UnfreezeSlapper", 5000, 0);
  333.                         }
  334.                     }
  335.                 }
  336.                 else
  337.                 {
  338.                     SendClientMessageToAll(0x33CCFF00, "[SERVER]{FFFFFF}: Choosing The Slapper again, current is not spawned!");
  339.                     Slapping = SetTimer("ChooseSlapper", 5000, 0);
  340.                 }
  341.             }
  342.             else
  343.             {
  344.                 SendClientMessageToAll(0x33CCFF00, "[SERVER]{FFFFFF}: Choosing The Slapper again, current is not online!");
  345.                 Slapping = SetTimer("ChooseSlapper", 5000, 0);
  346.             }
  347.         }
  348.         else
  349.         {
  350.             SendClientMessageToAll(0x33CCFF00, "[SERVER]{FFFFFF}: Choosing The Slapper again, current is not online!");
  351.             Slapping = SetTimer("ChooseSlapper", 5000, 0);
  352.         }
  353.     }
  354.     else
  355.     {
  356.         SendClientMessageToAll(0xFF634700, "[ERROR]{FFFFFF}: Not enough players to start round - aborted!");
  357.         return;
  358.     }
  359.     return;
  360. }
  361.  
  362. forward UnfreezeSlapper();
  363. public UnfreezeSlapper()
  364. {
  365.     GameTextForAll("~p~The Slapper ~w~has been unfrozen! ~r~Run~w~!", 5000, 5);
  366.     TogglePlayerControllable(DildoSlapper, true);
  367.     GivePlayerWeapon(DildoSlapper, SLAP_GUN, 65535);
  368.     SetPlayerColor(DildoSlapper, 0xFF000000); //Red colour, not visible on minimap
  369. }
  370.  
  371. stock N(u)
  372. {
  373.     new
  374.         n[32];
  375.     GetPlayerName(u, n, 32);
  376.     for(new m; m < 32; m++)
  377.     {
  378.         if(n[m] == '_')
  379.             n[m] = ' ';
  380.     }
  381.     return n;
  382. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement