Advertisement
Guest User

Sneaky

a guest
Jan 7th, 2009
6,597
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.95 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. /*
  4.  
  5.     Duel Filterscript (Ripped from LW_LVDM)
  6.     Brought to you by [NB]Sneaky
  7.  
  8.     www.99BlaZed.com
  9.     www.sneakyhost.net
  10.  
  11.     You will need to edit line 184,185,201,202
  12.  
  13. */
  14.  
  15. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  16. #define SendError(%1,%2) SendClientMessage(%1,COLOR_RED,"ERROR: " %2)
  17. #define SendUsage(%1,%2) SendClientMessage(%1,COLOR_WHITE,"USAGE: " %2)
  18.  
  19. #define COLOR_ORANGE    0xFF8040FF
  20. #define COLOR_YELLOW    0xFFFF00AA
  21. #define COLOR_RED       0xFF0000AA
  22. #define COLOR_WHITE     0xFFFFFFAA
  23.  
  24.  
  25. stock
  26.     g_GotInvitedToDuel[MAX_PLAYERS],
  27.     g_HasInvitedToDuel[MAX_PLAYERS],
  28.     g_IsPlayerDueling[MAX_PLAYERS],
  29.     g_DuelCountDown[MAX_PLAYERS],
  30.     g_DuelTimer[MAX_PLAYERS],
  31.     g_DuelInProgress,
  32.     g_DuelingID1,
  33.     g_DuelingID2;
  34.  
  35. public OnFilterScriptInit()
  36. {
  37.     print("\t============================================");
  38.     print("\tDuel Filterscript (Ripped from LW_LVDM)");
  39.     print("\tBy: Sneaky");
  40.     print("\t-");
  41.     print("\tLoaded");
  42.     print("\t============================================");
  43.     return 1;
  44. }
  45.  
  46. public OnFilterScriptExit()
  47. {
  48.     print("\t============================================");
  49.     print("\tDuel Filterscript (Ripped from LW_LVDM)");
  50.     print("\tBy: Sneaky");
  51.     print("\t-");
  52.     print("\tLoaded");
  53.     print("\t============================================");
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerConnect(playerid)
  58. {
  59.     g_GotInvitedToDuel[playerid] = 0;
  60.     g_HasInvitedToDuel[playerid] = 0;
  61.     g_IsPlayerDueling[playerid]  = 0;
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerDisconnect(playerid, reason)
  66. {
  67.     if(playerid == g_DuelingID1 || playerid == g_DuelingID2)
  68.     {
  69.         g_DuelInProgress = 0;
  70.     }
  71.     return 1;
  72. }
  73.  
  74. public OnPlayerCommandText(playerid, cmdtext[])
  75. {
  76.     dcmd(duel,4,cmdtext);
  77.     dcmd(cduel,5,cmdtext);
  78.     dcmd(duelaccept,10,cmdtext);
  79.     return 1;
  80. }
  81.  
  82. dcmd_cduel(playerid, params[])
  83. {
  84.     #pragma unused params
  85.  
  86.     if(g_HasInvitedToDuel[playerid] == 0)
  87.         return SendError(playerid, "You did not invite anyone to a duel!");
  88.  
  89.     SendClientMessage(playerid, COLOR_YELLOW, "You have reset your duel invite, you can now use /duel [playerid] again.");
  90.     g_HasInvitedToDuel[playerid] = 0;
  91.  
  92.     return 1;
  93. }
  94.  
  95. dcmd_duelaccept(playerid, params[])
  96. {
  97.     if(params[0] == '\0' || !IsNumeric(params))
  98.         return SendUsage(playerid, "/duelaccept [playerid]");
  99.  
  100.     if(g_DuelInProgress == 1)
  101.         return SendError(playerid, "Another duel is in progress at the moment, wait till that duel is finished!");
  102.  
  103.     new
  104.         DuelID = strvalEx(params),
  105.         pName[MAX_PLAYER_NAME],
  106.         zName[MAX_PLAYER_NAME],
  107.         tString[128];
  108.  
  109.     if(DuelID != g_GotInvitedToDuel[playerid])
  110.         return SendError(playerid, "That player did not invite you to a duel!");
  111.  
  112.     GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  113.     GetPlayerName(DuelID, zName, MAX_PLAYER_NAME);
  114.  
  115.     format(tString, sizeof(tString), "You accepted the duel with %s (ID:%d), duel will start in 10 seconds..",zName,DuelID);
  116.     SendClientMessage(playerid, COLOR_YELLOW, tString);
  117.  
  118.     format(tString, sizeof(tString), "%s (ID:%d), accepted the duel with you, duel will start in 10 seconds..",pName,playerid);
  119.     SendClientMessage(DuelID, COLOR_YELLOW, tString);
  120.  
  121.     format(tString, sizeof(tString), "(News) Duel between %s and %s will start in 10 seconds",pName,zName);
  122.     SendClientMessageToAll(COLOR_ORANGE, tString);
  123.  
  124.     InitializeDuel(playerid);
  125.     InitializeDuelEx( DuelID);
  126.  
  127.     g_IsPlayerDueling[playerid] = 1;
  128.     g_IsPlayerDueling[DuelID] = 1;
  129.  
  130.     g_DuelingID1 = playerid;
  131.     g_DuelingID2 = DuelID;
  132.  
  133.     g_DuelInProgress = 1;
  134.  
  135.     return 1;
  136. }
  137.  
  138. dcmd_duel(playerid, params[])
  139. {
  140.     if(params[0] == '\0' || !IsNumeric(params))
  141.         return SendUsage(playerid, "/duel [playerid]");
  142.  
  143.     if(g_HasInvitedToDuel[playerid] == 1)
  144.         return SendError(playerid, "You already invited someone to a duel! (Type, /cduel to reset your invite)");
  145.  
  146.     new
  147.         DuelID = strvalEx(params),
  148.         pName[MAX_PLAYER_NAME],
  149.         zName[MAX_PLAYER_NAME],
  150.         tString[128];
  151.  
  152.     GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  153.     GetPlayerName(DuelID, zName, MAX_PLAYER_NAME);
  154.  
  155.     if (!IsPlayerConnected(DuelID))
  156.         return SendError(playerid, "Player is not connected.");
  157.  
  158.     if( g_HasInvitedToDuel[DuelID] == 1)
  159.         return SendError(playerid, "That player is already invited to a duel!");
  160.  
  161.     if( DuelID  == playerid)
  162.         return SendError(playerid, "You can not duel yourself!");
  163.  
  164.     format(tString, sizeof(tString), "You invited %s (ID:%d) to a 1 on 1 duel, wait till %s accepts your invite.",zName, DuelID, zName);
  165.     SendClientMessage(playerid, COLOR_YELLOW, tString);
  166.  
  167.     format(tString, sizeof(tString), "You got invited by %s (ID:%d) to a 1 on 1 duel, type /duelaccept [playerid] to accept and start the duel. ",pName, playerid);
  168.     SendClientMessage(DuelID, COLOR_YELLOW, tString);
  169.  
  170.     g_GotInvitedToDuel[DuelID] = playerid;
  171.     g_HasInvitedToDuel[playerid] = 1;
  172.  
  173.     return 1;
  174. }
  175.  
  176. forward InitializeDuel(playerid);
  177. public InitializeDuel(playerid)
  178. {
  179.     g_DuelTimer[playerid]  = SetTimerEx("DuelCountDown", 1000, 1, "i", playerid);
  180.  
  181.     SetPlayerHealth(playerid, 100);
  182.     SetPlayerArmour(playerid, 100);
  183.  
  184.     //SetPlayerPos(playerid, X, Y, Z); // da1
  185.     //SetPlayerFacingAngle(playerid, A);
  186.     SetCameraBehindPlayer(playerid);
  187.     TogglePlayerControllable(playerid, 0);
  188.     g_DuelCountDown[playerid] = 11;
  189.  
  190.     return 1;
  191. }
  192.  
  193. forward InitializeDuelEx(playerid);
  194. public InitializeDuelEx(playerid)
  195. {
  196.     g_DuelTimer[playerid]  = SetTimerEx("DuelCountDown", 1000, 1, "i", playerid);
  197.  
  198.     SetPlayerHealth(playerid, 100);
  199.     SetPlayerArmour(playerid, 100);
  200.  
  201.     //SetPlayerPos(playerid, X, Y, Z);
  202.     //SetPlayerFacingAngle(playerid, A);
  203.     SetCameraBehindPlayer(playerid);
  204.     TogglePlayerControllable(playerid, 0);
  205.     g_DuelCountDown[playerid] = 11;
  206.  
  207.     return 1;
  208. }
  209.  
  210. forward DuelCountDown(playerid);
  211. public DuelCountDown(playerid)
  212. {
  213.     new
  214.         tString[128] ;
  215.  
  216.     g_DuelCountDown[playerid] --;
  217.  
  218.     PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
  219.  
  220.     format(tString, sizeof(tString), "~w~%d", g_DuelCountDown[playerid]);
  221.     GameTextForPlayer(playerid, tString, 900, 3);
  222.  
  223.     if(g_DuelCountDown[playerid] == 0)
  224.     {
  225.         KillTimer(g_DuelTimer[playerid]);
  226.         TogglePlayerControllable(playerid, 1);
  227.         GameTextForPlayer(playerid,"~g~GO GO GO", 900, 3);
  228.         return 1;
  229.     }
  230.  
  231.     return 1;
  232. }
  233.  
  234. strvalEx(xxx[])
  235. {
  236.     if(strlen(xxx) > 9)
  237.     return 0;
  238.     return strval(xxx);
  239. }
  240.  
  241. IsNumeric(const string[])
  242. {
  243.     for (new i = 0, j = strlen(string); i < j; i++)
  244.     {
  245.         if (string[i] > '9' || string[i] < '0') return false;
  246.     }
  247.     return true;
  248. }
  249.  
  250. public OnPlayerDeath(playerid, killerid, reason)
  251. {
  252.     new
  253.         sString[128],
  254.         pName[MAX_PLAYER_NAME],
  255.         zName[MAX_PLAYER_NAME],
  256.         Float:Health,
  257.         Float:Armor;
  258.  
  259.     if(g_IsPlayerDueling[playerid] == 1 && g_IsPlayerDueling[killerid] == 1)
  260.     {
  261.         GetPlayerHealth(killerid, Health);
  262.         GetPlayerArmour(killerid, Armor);
  263.  
  264.         GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  265.         GetPlayerName(killerid, zName, MAX_PLAYER_NAME);
  266.  
  267.         if(Health > 90.0 && Armor > 90.0)
  268.         {
  269.             format(sString, sizeof(sString),"(News) %s has \"OWNED\" %s in the duel and has %.2f health and %.2f armor left!", zName,pName,Health,Armor);
  270.             SendClientMessageToAll(COLOR_ORANGE, sString);
  271.  
  272.             g_GotInvitedToDuel[playerid] = 0;g_HasInvitedToDuel[playerid] = 0;g_IsPlayerDueling[playerid]  = 0;
  273.             g_GotInvitedToDuel[killerid] = 0;g_HasInvitedToDuel[killerid] = 0;g_IsPlayerDueling[killerid]  = 0;
  274.             g_DuelInProgress = 0;
  275.             return 1;
  276.         }
  277.         else
  278.         {
  279.             format(sString, sizeof(sString),"(News) %s has won the duel from %s and has %.2f health and %.2f armor left!", zName,pName,Health,Armor);
  280.             SendClientMessageToAll(COLOR_ORANGE, sString);
  281.  
  282.             g_GotInvitedToDuel[playerid] = 0;g_HasInvitedToDuel[playerid] = 0;g_IsPlayerDueling[playerid]  = 0;
  283.             g_GotInvitedToDuel[killerid] = 0;g_HasInvitedToDuel[killerid] = 0;g_IsPlayerDueling[killerid]  = 0;
  284.             g_DuelInProgress = 0;
  285.             return 1;
  286.        }
  287.     }
  288.     return 1;
  289. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement