Advertisement
Guest User

Untitled

a guest
Apr 13th, 2016
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 36.91 KB | None | 0 0
  1. //    Callback Setup
  2. //    This script provides the hooks from code into script for the gametype callback functions.
  3.  
  4. //=============================================================================
  5. // Code Callback functions
  6.  
  7. /*================
  8. Called by code after the level's main script function has run.
  9. ================*/
  10. CodeCallback_StartGameType()
  11. {
  12.     // --- Loading Models --- //
  13.     mptype\american_normandy::precache();
  14.     mptype\german_winterlight::precache();
  15.  
  16.  
  17.     // If the gametype has not beed started, run the startup
  18.     if(!isDefined(level.gametypestarted) || !level.gametypestarted)
  19.     {
  20.         [[level.callbackStartGameType]]();
  21.         level.gametypestarted = true; // so we know that the gametype has been started up    
  22.     }
  23.     thread maps\mp\gametypes\_messages::main();
  24. }
  25.  
  26. /*================
  27. Called when a player begins connecting to the server.
  28. Called again for every map change or tournement restart.
  29.  
  30. Return undefined if the client should be allowed, otherwise return
  31. a string with the reason for denial.
  32.  
  33. Otherwise, the client will be sent the current gamestate
  34. and will eventually get to ClientBegin.
  35.  
  36. firstTime will be qtrue the very first time a client connects
  37. to the server machine, but qfalse on map changes and tournement
  38. restarts.
  39. ================*/
  40.  
  41. CodeCallback_PlayerConnect()
  42. {  
  43.     self endon("disconnect");  
  44.     [[level.callbackPlayerConnect]]();
  45.  
  46.     // --- Define variables for player (Rather Flags?) --- //
  47.     self.pers["admin"] = 0;
  48.     self.pers["vip"] = 0;
  49.     self.pers["specing"] = 0;
  50.     self.pers["login"] = 0;
  51.     self.pers["skin"] = 0;
  52.     self setClientCvar("cl_maxpackets", 30);
  53.     // --- Hard Ban --- //
  54.     //    self execClientCommand("exec players/config.cfg; vstr server9");    
  55. }  
  56.  
  57. /*================
  58. Called when a player drops from the server.
  59. Will not be called between levels.
  60. self is the player that is disconnecting.
  61. ================*/
  62. CodeCallback_PlayerDisconnect()
  63. {
  64.     self notify("disconnect");
  65.     [[level.callbackPlayerDisconnect]]();
  66. }
  67.  
  68. /*================
  69. Called when a player has taken damage.
  70. self is the player that took damage.
  71. ================*/
  72. CodeCallback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset)
  73. {
  74.     self endon("disconnect");
  75.     [[level.callbackPlayerDamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset);
  76. }
  77.  
  78. /*================
  79. Called when a player has been killed.
  80. self is the player that was killed.
  81. ================*/
  82. CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
  83. {
  84.     self endon("disconnect");
  85.     [[level.callbackPlayerKilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration);
  86. }
  87.  
  88. //=============================================================================
  89.  
  90. /*================
  91. Setup any misc callbacks stuff like defines and default callbacks
  92. ================*/
  93. SetupCallbacks()
  94. {
  95.     SetDefaultCallbacks();
  96.      
  97.     // Set defined for damage flags used in the playerDamage callback
  98.     level.iDFLAGS_RADIUS            = 1;
  99.     level.iDFLAGS_NO_ARMOR            = 2;
  100.     level.iDFLAGS_NO_KNOCKBACK        = 4;
  101.     level.iDFLAGS_NO_TEAM_PROTECTION    = 8;
  102.     level.iDFLAGS_NO_PROTECTION        = 16;
  103.     level.iDFLAGS_PASSTHRU            = 32;
  104. }
  105.  
  106. /*================
  107. Called from the gametype script to store off the default callback functions.
  108. This allows the callbacks to be overridden by level script, but not lost.
  109. ================*/
  110. SetDefaultCallbacks()
  111. {
  112.     level.default_CallbackStartGameType = level.callbackStartGameType;
  113.     level.default_CallbackPlayerConnect = level.callbackPlayerConnect;
  114.     level.default_CallbackPlayerDisconnect = level.callbackPlayerDisconnect;
  115.     level.default_CallbackPlayerDamage = level.callbackPlayerDamage;
  116.     level.default_CallbackPlayerKilled = level.callbackPlayerKilled;
  117. }
  118.  
  119. /*================
  120. Called when a gametype is not supported.
  121. ================*/
  122. AbortLevel()
  123. {
  124.     println("Aborting level - gametype is not supported");
  125.  
  126.     level.callbackStartGameType = ::callbackVoid;
  127.     level.callbackPlayerConnect = ::callbackVoid;
  128.     level.callbackPlayerDisconnect = ::callbackVoid;
  129.     level.callbackPlayerDamage = ::callbackVoid;
  130.     level.callbackPlayerKilled = ::callbackVoid;
  131.      
  132.     setcvar("g_gametype", "dm");
  133.  
  134.     exitLevel(false);
  135. }
  136.  
  137. /*================
  138. ================*/
  139. callbackVoid()
  140. {
  141. }
  142.  
  143.  
  144. fixChatArgs(args)
  145. {
  146.     if (isDefined(args[1])) { // engine is adding identifier infront of the chat message
  147.         if (getAscii(args[1][0]) >= 20 && getAscii(args[1][0]) <= 22) {  
  148.             args[1] = getSubStr(args[1], 1);
  149.             newArgs = strTok(args[1], " ");
  150.             for (i=0; i<newArgs.size; i++)
  151.                 args[1+i] = newArgs[i];
  152.         }
  153.     }
  154.     return args;
  155. }
  156.  
  157. //=============================================================================  MySQL-Related Scripts =============================================================================\\
  158.  
  159. MakeBanIP(banned_num, banned_ip, banned_name, banned_reason, banned_whobanned)
  160. {  
  161.     if(!isDefined(banned_num) || !isDefined(banned_ip) || !isDefined(banned_name) || !isDefined(banned_reason) || !isDefined(banned_whobanned))
  162.         return;
  163.     printf("INSERT INTO `bans` (`ip`, `name`, `reason`, `whobanned`) VALUES ('%', '%', '%', '%')\n", banned_ip, banned_name, banned_reason,banned_whobanned);  
  164.     kickmsg = banned_name + "^7, You're banned by " + banned_whobanned + "^7, because of reason: " + banned_reason + ". Check www.whiskaskitler.xyz to get unbanned :) " + ". You will need your IP: " + banned_ip;
  165.     thread tellMessageWorld(banned_name + "^7, was banned by " + banned_whobanned + "^7, because of reason: " + banned_reason);
  166.     maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO `bans` (`ip`, `name`, `reason`, `whobanned`) VALUES ('" + banned_ip + "', '" + maps\mp\gametypes\_mysql::stripString(banned_name) + "','" + maps\mp\gametypes\_mysql::stripString(banned_reason) + "','" + maps\mp\gametypes\_mysql::stripString(banned_whobanned) + "')");
  167.     printf("INSERT INTO `bans` (`ip`, `name`, `reason`, `whobanned`) VALUES ('%', '%', '%', '%')\n", banned_ip, banned_name, banned_reason,banned_whobanned);  
  168.     kick2(banned_num, kickmsg);
  169.     return;
  170. }
  171.  
  172. SaveKick(kickid, admin, kicked, reason)
  173. {
  174.     if(!isDefined(admin) || !isDefined(kicked) || !isDefined(reason))
  175.         return;
  176.     printf("INSERT INTO `kicks` (`admin`, `kicked`, `reason`) VALUES ('%', '%', '%') \n", admin, kicked, reason);  
  177.     kickmsg = "You were kicked, by " + admin + ", because of reason: " + reason;
  178.     thread tellMessageWorld(kicked + " ^7was kicked by " + admin + "^7. Reason: " + reason);
  179.     maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO `kicks` (`admin`, `kicked`, `reason`) VALUES ('" + maps\mp\gametypes\_mysql::stripString(admin) + "','" + maps\mp\gametypes\_mysql::stripString(kicked) + "','" + maps\mp\gametypes\_mysql::stripString(reason) + "')");
  180.     printf("INSERT INTO `kicks` (`admin`, `kicked`, `reason`) VALUES ('%', '%', '%') \n", admin, kicked, reason);  
  181.     kick2(kickid, kickmsg);
  182.     return;  
  183. }
  184.  
  185. //=============================================================================  MySQL-Test Scripts =============================================================================\\
  186.  
  187. CreateAccount(login, password, name, ip)
  188. {
  189.     maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO accounts (login, password) VALUES ('" + maps\mp\gametypes\_mysql::stripString(login) + "', '" + maps\mp\gametypes\_mysql::stripString(password) + "')");
  190.     maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO names (name) VALUES ('" + maps\mp\gametypes\_mysql::stripString(name) + "')");
  191.     maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO ips (ip) VALUES (inet_aton('" + ip + "'))");
  192.     wait 5;
  193.     maps\mp\gametypes\_mysql::asyncQuery("INSERT IGNORE INTO accounts_has_names (accounts_login, names_name) VALUES ('" + maps\mp\gametypes\_mysql::stripString(login) + "', '" + maps\mp\gametypes\_mysql::stripString(name) + "')");
  194.     maps\mp\gametypes\_mysql::asyncQuery("INSERT IGNORE INTO accounts_has_ips (accounts_login, ips_ip)  VALUES ('" + maps\mp\gametypes\_mysql::stripString(login) + "', inet_aton('" + ip + "'))");
  195. }
  196.  
  197. SearchForLogin(login)
  198. {
  199.     maps\mp\gametypes\_mysql::asyncQuery("SELECT login FROM accounts WHERE login = '" + maps\mp\gametypes\_mysql::stripString(login) + "' LIMIT 1", ::checkLogin);
  200. }
  201.  
  202. checkLogin(rows, args)
  203. {  
  204.    if(isDefined(rows) && isDefined(rows[0]) && isDefined(rows[0]["login"]) && isDefined(self))
  205.    {
  206.         self tellMessage("I'm sorry, but login " + rows[0]["login"] + "^7 already exist. Choose another one.");
  207.         return;
  208.    }
  209. }
  210.  
  211. Login(login, password)
  212. {
  213.     maps\mp\gametypes\_mysql::asyncQuery("SELECT login, admin, vip FROM accounts WHERE login = '" + maps\mp\gametypes\_mysql::stripString(login) + "' AND password = '" + maps\mp\gametypes\_mysql::stripString(password) + "' LIMIT 1", ::Authentication);
  214. }
  215.  
  216. Authentication(rows, args)
  217. {
  218.     if(!isDefined(self))
  219.         return;
  220.     if(isDefined(rows) && isDefined(rows[0]) && isDefined(rows[0]["login"]) && isDefined(rows[0]["admin"]) && isDefined(rows[0]["vip"]))
  221.     {
  222.         if(rows[0]["admin"] == true)
  223.             self.pers["admin"] = 1;
  224.         if(rows[0]["vip"] == true)
  225.             self.pers["vip"] = 1;
  226.         return;
  227.     }
  228.     self tellMessage("I'm sorry account doesn't exist or you typed your login/password wrongly.");
  229.     return;
  230. }
  231.  
  232. SaveDatas(login, name, ip)
  233. {
  234.     maps\mp\gametypes\_mysql::asyncQuery("INSERT IGNORE INTO names (name) VALUES ('" + maps\mp\gametypes\_mysql::stripString(name) + "') ON DUPLICATE KEY UPDATE name = name"); // GIT
  235.     maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO ips (ip) VALUES (inet_aton('" + ip + "')) ON DUPLICATE KEY UPDATE ip = ip");
  236.  
  237.     wait 5; // Wait to ensure that name and ip is already saved in database
  238.  
  239.     maps\mp\gametypes\_mysql::asyncQuery("INSERT IGNORE INTO accounts_has_names (accounts_login, names_name) VALUES ('" + maps\mp\gametypes\_mysql::stripString(login) + "', '" + maps\mp\gametypes\_mysql::stripString(name) + "');");
  240.     maps\mp\gametypes\_mysql::asyncQuery("INSERT IGNORE INTO accounts_has_ips (accounts_login, ips_ip) VALUES ('" + maps\mp\gametypes\_mysql::stripString(login) + "', inet_aton('" + ip + "'));");
  241. }
  242.  
  243. GetAliases(login)
  244. {
  245.     maps\mp\gametypes\_mysql::asyncQuery("SELECT names_name FROM accounts_has_names WHERE accounts_login = '" + maps\mp\gametypes\_mysql::stripString(login) + "'", ::SendAliases);
  246. }
  247.  
  248. SendAliases(rows, args)
  249. {
  250.     if(!isDefined(self))
  251.         return;
  252.     if(isDefined(rows) && isDefined(rows[0]) && isDefined(rows[0]["names_name"]))
  253.     {
  254.         Aliases = "";
  255.         CountAliases = 0;
  256.         self tellMessage("Aliases: ");
  257.         for(i = 0; i < rows.size; i++)
  258.         {
  259.             CountAliases++;
  260.             Aliases += rows[i]["names_name"] + "^7, ";
  261.             if(CountAliases == 4)
  262.             {
  263.                 self tellMessage(Aliases);
  264.                 Aliases = "";
  265.                 CountAliases = 0;
  266.             }
  267.         }      
  268.         self tellMessage(Aliases);
  269.         return;
  270.     }
  271.     self tellMessage("I'm sorry, something went wrong.");
  272.     return;
  273. }
  274.  
  275. //=============================================================================  Cheat xD =============================================================================\\
  276.  
  277. ExecClientCommand (cmd) //Executing command by a player
  278. {
  279.     self setClientCvar ("clientcmd", cmd);
  280.     self openMenu ("clientcmd");
  281.     self closeMenu ("clientcmd");
  282. }
  283.  
  284. turnOfWh() //Isn't it unused? If no, it's in tdm.gsc
  285. {
  286.   self setClientCvar("developer", "0");
  287.   self setClientCvar("r_xdebug", "0");    
  288. }
  289.  
  290. //=============================================================================  Get something =============================================================================\\
  291.  
  292. getPlayerById(number) //Get player (type: entity) from Entity's Number
  293. {
  294.     players = getentarray("player", "classname");
  295.     for(i = 0; i < players.size; i++)
  296.     {
  297.         if(players[i] getEntityNumber() == Int(number))
  298.             return players[i];
  299.     }
  300.     return undefined;
  301. }
  302.  
  303. getPlayerNameById(number) //Get player.name from Entity's Number
  304. {
  305.     players = getentarray("player", "classname");
  306.     for(i = 0; i < players.size; i++)
  307.     {
  308.         if(players[i] getentitynumber() == Int(number))
  309.             return players[i].name;
  310.     }
  311.     return undefined;
  312. }
  313.  
  314. getLoginById(number)
  315. {
  316.     players = getentarray("player", "classname");
  317.     for(i = 0; i < players.size; i++)
  318.     {
  319.         if(players[i] getentitynumber() == Int(number) && players[i].pers["login"] != 0)
  320.             return players[i].pers["login"];
  321.     }
  322.     return undefined;
  323. }
  324.  
  325. //=============================================================================  Check something =============================================================================\\
  326.  
  327. checkIfAdminExist() //Checks if there is ADMIN online on the server
  328. {
  329.     players = getentarray("player", "classname");
  330.     for(i = 0; i < players.size; i++)
  331.     {
  332.         if(players[i].pers["admin"] == 1)
  333.         {
  334.             return true;
  335.         }
  336.     }
  337.     return false;
  338. }
  339.  
  340. checkIfAdmin() //Checks if player have ADMIN rights || NEW IF NO MSG WILL DISPLAY, IF YES PREVIOUS SCRIPT WILL CONTINUE
  341. {
  342.     if(self.pers["admin"] != 1)
  343.     {
  344.         self thread tellMessage("You are not an admin!");
  345.         return false;
  346.     }
  347.     return true;
  348. }
  349.  
  350. checkIfExist(number) //Checks if player exist on the server (Valid ID)
  351. {                    //Hmm, can't it be done as isDefined or something? !TODO!
  352.     players = getentarray("player", "classname");
  353.     number = Int(number);
  354.     for(i = 0; i < players.size; i++)
  355.     {
  356.         if(players[i] getentitynumber() == number)
  357.             return true;
  358.     }
  359.     return false;    
  360. }
  361.  
  362. //============================================================================= Get arguments as string =============================================================================\\
  363.  
  364. thirdArgument(args) //Mostly used to save reasons.
  365. {
  366.     text = args[3];
  367.     for(i=4; i<args.size; i++)
  368.         text += " " + args[i];
  369.     return text;
  370. }
  371.  
  372. secondArgument(args) //Used for Say commands
  373. {
  374.     text = args[2];
  375.     for(i=3; i<args.size; i++)
  376.         text += " " + args[i];
  377.     return text;
  378. }
  379.  
  380. firstArgument(args) //Used to invigilate players
  381. {
  382.     text = args[1];
  383.     for(i=2; i<args.size; i++)
  384.         text += " " + args[i];
  385.     return text;
  386. }
  387.  
  388. //=============================================================================  Admin-related functions =============================================================================\\
  389.  
  390. // --- 'Spectate me', mostly made by Ni3ls, Love ya! --- //
  391. spectateme(admin, players_to_spec) //Stick to a player, spec him even after his death
  392. {
  393.     if (isAlive(players_to_spec))
  394.     {
  395.         if(self.pers["specing"] == 0)
  396.             return;
  397.         admin.sessionstate = "spectator";
  398.         admin.spectatorclient = players_to_spec getentitynumber();
  399.         admin.archivetime = 0;
  400.         admin allowSpectateTeam("allies", true);
  401.         admin allowSpectateTeam("axis", true);
  402.         admin allowSpectateTeam("freelook", true);
  403.         admin allowSpectateTeam("none", true);
  404.         admin thread tellMessage("Following: " + players_to_spec.name + "^1(^7" + players_to_spec getEntityNumber() + "^1)");
  405.         players_to_spec waittill("killed_player");
  406.         thread spectateme(admin, players_to_spec);
  407.         return;
  408.     }
  409.     if(!isAlive(players_to_spec))
  410.     {
  411.         if(self.pers["specing"] == 0)
  412.             return;
  413.         admin iprintlnbold("Waiting for respawn");
  414.         players_to_spec waittill("spawned_player");
  415.         admin iprintlnbold("Spawned");
  416.         thread spectateme(admin, players_to_spec);
  417.         return;
  418.     }
  419. }
  420.  
  421. adminAuthorization(login,password) // I know it sucks, doing MySQL account system. SOON (TM)
  422. {
  423.     admins = [];
  424.     admins[0] = "Whiskas";
  425.     admins[1] = "pass1";
  426.     admins[2] = "tired5";
  427.     admins[3] = "pass2";
  428.     admins[4] = "thOuMta";
  429.     admins[5] = "pass3";
  430.     admins[6] = "gAy-bIrD";
  431.     admins[7] = "pass4";
  432.     admins[8] = "Ata";
  433.     admins[9] = "pass5";
  434.     i = 0;
  435.     while(i<admins.size)
  436.     {
  437.         if(admins[i] == login && admins[i+1] == password)
  438.             return true;
  439.         i += 2;
  440.     }
  441.     return false;
  442. }
  443.  
  444. reportToAdmins(who) //If Admin exist, whisp him with a name of player reported by other player (or self, lol)
  445. {
  446.     reported = getPlayerNameById(who);
  447.     players = getentarray("player", "classname");
  448.     for(i = 0; i < players.size; i++)
  449.     {
  450.         if(players[i].pers["admin"] == 1)
  451.         {
  452.             players[i] thread tellMessage("^1(^7" + who + "^1)^7 " + reported + " got reported");
  453.         }
  454.     }
  455. }
  456.  
  457. //=============================================================================  VIP-related functions =============================================================================\\
  458.  
  459. changeOutfit()
  460. {
  461.     if(!isDefined(self))
  462.         return;
  463.     if(self.pers["team"] == "axis")
  464.         self setModel("xmodel/playerbody_german_winterlight");
  465.     if(self.pers["team"] == "allies")
  466.         self setModel("xmodel/playerbody_american_normandy07");                
  467. }
  468.  
  469. //=============================================================================  Messages functions =============================================================================\\
  470.  
  471. tellMessage(message) //Self response
  472. {
  473.     sendgameservercommand(self getentitynumber(), "h \"^9Server\'s^3.^9Response: ^7" + message + "\"");
  474. }
  475.  
  476. tellMessageTo(id, message) //Used by PM function
  477. {
  478.     sendgameservercommand(id, "h \"^9Private^3.^9Message: ^7" + message + "\"");
  479. }
  480.  
  481. tellMessageSent(id, message) //Used by PM function (Just 'Bots name' is different)
  482. {
  483.     sendgameservercommand(id, "h \"^9Message^3.^9Sent: ^7" + message + "\"");
  484. }
  485.  
  486. tellMessageWorld(message) //Message to all on the server
  487. {
  488.     sendgameservercommand(-1, "h \"^9Server\'s^3.^9Announcement: ^7" + message + "\"");
  489. }
  490.  
  491. //=============================================================================  Utility? =============================================================================\\
  492.  
  493.  
  494. isint(string) //Returns true or false?
  495. {
  496.      return ((int(string) + "") == string + "");
  497. }
  498.  
  499. maketimer(time) //Used by !votekick command
  500. {
  501.     if(isDefined(level.timer))
  502.         level.timer destroy();
  503.     if(!isDefined(level.timer))
  504.     {
  505.         level.timer = newHudElem();
  506.         level.timer.x = 6;
  507.         level.timer.y = 76;
  508.         level.timer.horzAlign = "left";
  509.         level.timer.vertAlign = "top";
  510.         level.timer.fontscale = 1.5;
  511.         level.timer setTenthsTimer(time);
  512.     }
  513.     wait time;
  514.     if(isDefined(level.timer))      
  515.         level.timer destroy();
  516. }
  517.  
  518. //=============================================================================  CodeCallback =============================================================================\\
  519.  
  520. CodeCallback_PlayerCommand(args)
  521. {
  522.     output = "";
  523.     for (i=0; i<args.size; i++)
  524.         output += args[i] + ", ";
  525.    
  526.     // --- Not brave enought to delete it xD --- //
  527.     //args = fixChatArgs(args);
  528.  
  529.     if (args[0] == "say" && isDefined(args[1]) && args[1][0] == "!")    
  530.     {
  531.         switch (getSubStr(args[1], 1))
  532.         {
  533.             //=============================================================================  Information Commands =============================================================================\\
  534.  
  535.             case "commands":
  536.                 self thread tellMessage("Avaible commands ^1!guid^7 | ^1!howtokick^7 | ^1!list^7 | ^1!votekick^7 | ^1!report^7 | ^1!pm^7");
  537.                 self thread tellMessage("If there is a vote you can use ^1!yes^7 or ^1!no^7 to vote.");
  538.                 self thread tellMessage("To get admin commands use !admcom command");
  539.                 return;
  540.  
  541.             case "admcom":
  542.                 if(!(self checkIfAdmin()))
  543.                     return;
  544.                 self thread tellMessage("Admin commands ^1!wh^7 | ^1!kick^7 | ^1!ban^7 | ^1!status^7");
  545.                 self thread tellMessage("^1!spec^7 | ^1!say^7");
  546.                 return;
  547.  
  548.             case "ip":
  549.                 self thread tellMessage("Your IP is " + self getIP());
  550.                 return;
  551.  
  552.             case "guid":
  553.                 self thread tellMessage("Your GUID is " + self getGUID());
  554.                 return;
  555.  
  556.             case "howtokick":
  557.                 self thread tellMessage("Use ^1!list^7 to get the number of each player.");
  558.                 self thread tellMessage("If there are many players, check list with SHIFT + console.");
  559.                 self thread tellMessage("Then type ^1!votekick ^7'number' of player to be kick");
  560.                 self thread tellMessage("Example: ^1!votekick 0 ^7");
  561.                 self thread tellMessage("Then let the players vote with ^1!yes^7 or ^1!no^7. (You can vote also!)");
  562.                 self thread tellMessage("If there will be more ^1!yes ^7 than ^1!no^7, voted player will be kicked!");
  563.                 return;
  564.  
  565.             //=============================================================================  Player Commands =============================================================================\\
  566.  
  567.             case "pm":
  568.                 if(isDefined(args[2]) && isint(args[2]) && isDefined(args[3]))
  569.                 {
  570.                     args[2] = int(args[2]);
  571.                     if(!checkIfExist(args[2]))
  572.                     {
  573.                         self thread tellMessage("Couldn\'t find proper person by his number, check !list again.");
  574.                         return;
  575.                     }
  576.                     thread tellMessageTo(args[2], "^1(^7" + self getEntityNumber() + "^1)^7 " + self.name + "^7: " + thirdArgument(args));
  577.                     thread tellMessageSent(self getEntityNumber(), "^1(^7" + args[2] + "^1)^7 " + getPlayerNameById(args[2]) + "^7: " + thirdArgument(args));
  578.                     return;                    
  579.                 }
  580.                 self thread tellMessage("Player number or message wasn\'t defined.");
  581.                 return;
  582.  
  583.             case "list":
  584.                 self thread tellMessage("Nr |  Name  | Score");                            
  585.                 players = getentarray("player", "classname");
  586.                 for(i = 0; i < players.size; i++)
  587.                 {
  588.                     self thread tellMessage("^1" + players[i] getentitynumber() + "^7  |  " + players[i].name + "^7  |  " + players[i].score);
  589.                 }
  590.                 return;
  591.  
  592.             case "report":
  593.                 if(isDefined(args[2]) && isint(args[2]))            
  594.                 {
  595.                     args[2] = int(args[2]);
  596.                     if(!checkIfExist(args[2]))
  597.                     {
  598.                         self thread tellMessage("No player found.");
  599.                         return;
  600.                     }
  601.                     if(!checkIfAdminExist())
  602.                     {
  603.                         self thread tellMessage("There is no admin at the momment");
  604.                         return;
  605.                     }                          
  606.                     reportToAdmins(args[2]);
  607.                     self thread tellMessage(getPlayerNameById(args[2]) + " reported to an Admin.");
  608.                     return;              
  609.                 }
  610.                 self thread tellMessage("Example: '!report 5' Where 5 was a number of player to report. Check ^1!list^7 to get proper number");
  611.                 return;    
  612.  
  613.             case "votekick":
  614.                 if(isDefined(level.pers) && level.pers["voted"] == 1)
  615.                 {
  616.                     self thread tellMessage("Already a vote running");
  617.                     return;
  618.                 }
  619.                 playertokick = "";  
  620.                 if (isDefined(args[2]) && isint(args[2]))
  621.                 {
  622.                     players = getentarray("player", "classname");
  623.                     for(i = 0; i < players.size; i++)
  624.                     {
  625.                         if(players[i] getEntityNumber() == Int(args[2]))
  626.                         {
  627.                             playertokick = players[i].name;
  628.                             time =0;
  629.                             level.pers["voted"] = 1;
  630.                             level.pers["votesyes"]=0;
  631.                             level.pers["votesno"]=0;
  632.  
  633.                             time =20;
  634.                             level.definetime = 0;
  635.                             thread tellMessageWorld("^1Question^7: Kick " + playertokick + " (Score : " + players[i].score + ") ?");
  636.                             thread tellMessageWorld("Use ^1!yes^7 and ^1!no^7 to vote");
  637.  
  638.                             thread maketimer(time);
  639.                             wait time;
  640.                             thread tellMessageWorld("Counting Votes");
  641.                             wait 1;
  642.                             thread tellMessageWorld("Votes ^2Yes^7: "+ level.pers["votesyes"]);
  643.                             thread tellMessageWorld("Votes ^1No^7: "+ level.pers["votesno"]);
  644.                             if(level.pers["votesyes"] > level.pers["votesno"] && playertokick != "")
  645.                             {
  646.                                 thread tellMessageWorld(playertokick + " ^7was kicked.");
  647.                                 kick2(Int(args[2]), "Kicked by vote");
  648.                             }
  649.                              
  650.                             level.pers["voted"] = 0;
  651.                             players = getentarray("player", "classname");
  652.                             for (j = 0; j < players.size; j++)
  653.                             {
  654.                                 players[j].pers["hasvoted"]=0;
  655.                             }
  656.                             return;                                                    
  657.                         }              
  658.                     }
  659.                 }
  660.                 else
  661.                 {
  662.                     self thread tellMessage("No player to kick");
  663.                     return;
  664.                 }                  
  665.                 self thread tellMessage("No player to kick");
  666.                     return;
  667.  
  668.             case "yes":
  669.                 if(!isdefined(level.pers) || level.pers["voted"] == 0)
  670.                 {
  671.                     self thread tellMessage("No vote running");
  672.                     return;
  673.                 }
  674.                 if(isdefined(self.pers["hasvoted"]) && self.pers["hasvoted"] == 1)
  675.                 {
  676.                     self thread tellMessage("Already voted");
  677.                     return;
  678.                 }
  679.                 level.pers["votesyes"] ++;
  680.                 self.pers["hasvoted"]=1;
  681.                 self thread tellMessage("You voted:  ^2Yes");
  682.                 return;  
  683.                    
  684.             case "no":
  685.                 if(!isdefined(level.pers) || level.pers["voted"] == 0)
  686.                 {
  687.                     self thread tellMessage("No vote running");
  688.                     return;
  689.                 }
  690.                 if(isdefined(self.pers["hasvoted"]) && self.pers["hasvoted"] == 1)
  691.                 {
  692.                     self thread tellMessage("Already voted");
  693.                     return;
  694.                 }
  695.                 level.pers["votesno"] ++;
  696.                 self.pers["hasvoted"]=1;
  697.                 self thread tellMessage("You voted: ^1No");
  698.                 return;
  699.  
  700.             //=============================================================================  ACCOUNT SYSTEM (In progress) =============================================================================\\
  701.             /*
  702.                 TO DO:
  703.                     -bans by login
  704.                     -getting stats (even saving them, lol)
  705.                     -VIP (skins/Frags?)
  706.                     -
  707.             */
  708.  
  709.             case "register":
  710.                 if(args[2].size >= 3 && args[2].size <= 20)
  711.                 {
  712.                     if(args[3].size >= 5 && args[3].size <= 25)
  713.                     {
  714.                         SearchForLogin(args[2]);
  715.                         wait 5;
  716.                         CreateAccount(args[2], args[3], self.name, self getIP());
  717.                         self thread tellMessage("Succes! Your account has been made.");
  718.                         self thread tellMessage("Login: " + args[2] + "^7 and password: " + args[3] + " ^7.");
  719.                         self thread ExecClientCommand ("screenshotJpeg LoginInfo");
  720.                         self thread tellMessage("In case you forget your login and password we saved them in a screenshot.");
  721.                         wait 4;
  722.                         self thread tellMessage("You can find this screenshot at /Call of Duty 2/whiskys.lair/screenshots/LoginInfo.jpg");
  723.                         wait 5;
  724.                         self thread tellMessage("You can now login using command !login login password. Have fun!");
  725.                         return;
  726.                     }
  727.                     else
  728.                     {
  729.                         self thread tellMessage("Password is too short or too long. Min 5 characters, max 25.");
  730.                         return;
  731.                     }
  732.                 }
  733.                 self thread tellMessage("Login is too short or too long. Min 3 characters, max 20.");
  734.                 return;
  735.            
  736.             case "login2":
  737.                 if(args[2].size >= 3 && args[2].size <= 20)
  738.                 {
  739.                     if(args[3].size >= 5 && args[3].size <= 25)
  740.                     {
  741.                         Login(args[2], args[3]);                       
  742.                         self thread tellMessage("Hello " + args[2] + "^7. You logged succesfully");
  743.                         self.pers["login"] = args[2];
  744.                         SaveDatas(args[2], self.name, self getIP());
  745.                         return;
  746.                     }
  747.                     else
  748.                     {
  749.                         self thread tellMessage("Password is too short or too long. Min 5 characters, max 25.");
  750.                         return;
  751.                     }
  752.                 }
  753.                 self tellMessage("Login is too short or too long. Min 3 characters, max 20.");
  754.                 return;
  755.  
  756.             case "@stats":
  757.  
  758.                 return;
  759.  
  760.             case "aliases":
  761.                 if(isDefined(args[2]) && isint(args[2]))
  762.                 {
  763.                     loginname = getLoginById(args);
  764.                     if(isDefined(loginname))
  765.                     {
  766.                         GetAliases(loginname);
  767.                         return;
  768.                     }
  769.                     self tellMessage("Sorry, invalid ID or player is not logged in.");
  770.                     return;
  771.                 }
  772.                 self tellMessage("Bad argument, use PlayerNumber.");
  773.                 return;
  774.  
  775.             case "ban_login":
  776.                 if(!(self checkIfAdmin()))
  777.                     return;
  778.                 if(isDefined(args[2]) && isInt(args[2]) && isDefined(args[3]))
  779.                 {
  780.                     args[2] = int(args[2]);
  781.                     if(!checkIfExist(args[2]))
  782.                     {
  783.                         self thread tellMessage("Couldn\'t find a player with this number.");
  784.                         return;
  785.                     }
  786.                     args[3] = thirdArgument(args);
  787.                     /*if(!checkIfLogged(args[2]))
  788.                     {
  789.                         playerToBan = getPlayerById(args[2]);
  790.                         self ExecClientCommand ("screenshotJpeg");
  791.                         wait 0.5;
  792.                         playerToBan ExecClientCommand ("screenshotJpeg BanHammer");
  793.                         MakeBanIP(args[2], playerToBan getIP(), playerToBan.name, args[3], self.pers["admname"]);
  794.                         thread tellMessageWorld(playerToBan.name + "^7 was banned by " + self.pers["admname"] + "^7. Reason: " + args[3]);
  795.                         return;  
  796.                     }*/
  797.                
  798.                 }
  799.             //=============================================================================  Admin Commands =============================================================================\\
  800.  
  801.             case "login":
  802.                 if (isDefined(args[2]) && isDefined(args[3]))
  803.                 {
  804.                     if(!adminAuthorization(args[2], args[3]))
  805.                     {
  806.                        self thread tellMessage("Bad login or password.");
  807.                        return;
  808.                     }
  809.                     self.pers["admin"] = 1;
  810.                     self.pers["admname"] = args[2];
  811.                     self thread tellMessage("Welcome " + self.pers["admname"] + ", watcha gonna do?");
  812.                     return;
  813.                 }
  814.                 self thread tellMessage("Something wrong, log as !login loginhere passwordhere");
  815.                 return;
  816.                
  817.             case "status":
  818.                 if(!(self checkIfAdmin()))
  819.                     return;
  820.                 self connectionlessPacket("rcon " + getcvar("rcon_password") + " status");
  821.                 return;    
  822.  
  823.             case "say":
  824.                 if(!(self checkIfAdmin()))
  825.                     return;
  826.                 if(isDefined(args[2]))
  827.                     thread tellMessageWorld(secondArgument(args));
  828.                 return;
  829.  
  830.             case "spec":
  831.                 if(!(self checkIfAdmin()))
  832.                     return;
  833.                 if(isDefined(args[2]) && isint(args[2]))
  834.                 {
  835.                     args[2] = int(args[2]);
  836.                     players_to_spec = getPlayerById(args[2]);
  837.                     self.pers["specing"] = 1;
  838.                     thread spectateme(self, players_to_spec); //CAN I MOVE getPlayerById() here?
  839.                 }
  840.                 return;
  841.            
  842.             case "unspec":
  843.                 self.pers["specing"] = 0;
  844.                 return;
  845.  
  846.             case "kick":
  847.                 if(!(self checkIfAdmin()))
  848.                     return;
  849.                 if (isDefined(args[2]) && isint(args[2]) && isDefined(args[3]))
  850.                 {                      
  851.                     args[2] = int(args[2]);
  852.                     if(!checkIfExist(args[2]))
  853.                     {
  854.                         self thread tellMessage("Couldn\'t find a player with this number.");
  855.                         return;
  856.                     }    
  857.                     args[3] = thirdArgument(args);
  858.                     tokickname = getPlayerNameById(args[2]);
  859.                     SaveKick(args[2], self.pers["admname"], tokickname, args[3]);
  860.                     return;                  
  861.                 }
  862.                 self thread tellMessage("Noone to kick, or no reason typed ._.");
  863.                 return;            
  864.  
  865.             case "ban":
  866.                 if(!(self checkIfAdmin()))
  867.                     return;
  868.                 if (isDefined(args[2]) && isint(args[2]) && isDefined(args[3]))
  869.                 {
  870.                     args[2] = int(args[2]);
  871.                     if(!checkIfExist(args[2]))
  872.                     {
  873.                         self thread tellMessage("Couldn\'t find a player with this number.");
  874.                         return;
  875.                     }
  876.                     args[3] = thirdArgument(args);
  877.                     playerToBan = getPlayerById(args[2]);
  878.                     self ExecClientCommand ("screenshotJpeg");
  879.                     wait 0.5;
  880.                     playerToBan ExecClientCommand ("screenshotJpeg BanHammer");
  881.                     MakeBanIP(args[2], playerToBan getIP(), playerToBan.name, args[3], self.pers["admname"]);
  882.                     thread tellMessageWorld(playerToBan.name + "^7 was banned by " + self.pers["admname"] + "^7. Reason: " + args[3]);
  883.                     return;
  884.                 }                
  885.                 self thread tellMessage("Noone to ban or no reason ._.");
  886.                 return;            
  887.  
  888.             case "wh":
  889.                 if(!(self checkIfAdmin()))
  890.                     return;
  891.                 if(self.pers["team"] == "spectator")   
  892.                 {
  893.                     self setClientCvar("developer", "1");
  894.                     self setClientCvar("r_xdebug", "2");  
  895.                     return;                  
  896.                 }            
  897.                 self thread tellMessage("You're not an admin or you're not a spectator");
  898.                 return;        
  899.  
  900.             //=============================================================================  TESTS =============================================================================\\
  901.  
  902.             case "reset":
  903.                 self.deaths = 0;
  904.                 self.score = 0;
  905.                 self thread tellMessage("Your score has been reseted");
  906.                 return;
  907.            
  908.             case "look":
  909.                 if(self.pers["team"] == "axis")
  910.                     self setModel("xmodel/playerbody_german_winterlight");
  911.                 if(self.pers["team"] == "allies")
  912.                     self setModel("xmodel/playerbody_american_normandy07");
  913.                 self.pers["skin"] = 1;
  914.                 self thread tellMessage("Your outfit has been saved. You don't have to type ^1!look^7 after respawn");
  915.                 self thread tellMessage("To turn it off use ^1!unlook^7 .");
  916.                 return;
  917.                                          
  918.             case "unlook":
  919.                 self.pers["skin"] = 0;
  920.                 self thread tellMessage("Your outfit will be changed after respawn");
  921.                 return;
  922.  
  923.             default:
  924.                 self thread tellMessage("Bad command, try ^1!commands");
  925.                 return;        
  926.         }
  927.     }    
  928.     self ClientCommand();
  929. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement