void CGameContext::ChatCmds(const char *pMsg, int ClientID) { pMsg ++;//on ignore le slash //bool IsOwner = Server()->IsOwner(ClientID); bool IsAdmin = Server()->IsAdmin(ClientID); bool IsMod = Server()->IsMod(ClientID); //bool IsPremium = Server()->IsPremium(ClientID); //bool IsPolice = Server()->IsPolice(ClientID); //bool IsTerrorist = Server()->IsTerrorist(ClientID); CPlayer *pPlayer = m_apPlayers[ClientID]; if(!str_comp_nocase_num(pMsg, "login", 5)) { if(pPlayer->m_AccountData.m_IsLoggedIn) { SendChatTarget(ClientID, "You are already logged in !"); return; } char aUsername[512]; char aPassword[512]; if(sscanf(pMsg, "login %s %s", aUsername, aPassword) != 2) { // notify the user that he is stupid SendChatTarget(ClientID, "Please stick to the given structure :"); SendChatTarget(ClientID, "/login <username> <password>"); return; } pPlayer->m_pAccount->Login(aUsername, aPassword); if(pPlayer->m_AccountData.m_IsLoggedIn) pPlayer->m_pAccount->Update(); return; } if(!str_comp_nocase(pMsg, "logout")) { if(!pPlayer->m_AccountData.m_IsLoggedIn) { SendChatTarget(ClientID, "You are already logged out !"); return; } pPlayer->SetTeam(TEAM_SPECTATORS); pPlayer->m_pAccount->Update(); pPlayer->m_pAccount->Reset(); SendChatTarget(ClientID, "You are now logged out"); pPlayer->m_AccountData.m_IsLoggedIn = false; CheckLoggedAccount(); Server()->SetClientAccountName(ClientID, ""); return; } if(!str_comp_nocase_num(pMsg, "register", 8)) { if(pPlayer->m_AccountData.m_IsLoggedIn) { SendChatTarget(ClientID, "You are already registered !"); return; } char aUsername[512]; char aPassword[512]; if(sscanf(pMsg, "register %s %s", aUsername, aPassword) != 2) { SendChatTarget(ClientID, "Please stick to the given structure :"); SendChatTarget(ClientID, "/register <username> <password>"); return; } pPlayer->m_pAccount->Create(aUsername, aPassword); return; } if(!str_comp_nocase_num(pMsg, "password", 8)) { if(!pPlayer->m_AccountData.m_IsLoggedIn) { SendChatTarget(ClientID, "You are not logged in !"); return; } char aNewPassword[512]; if(sscanf(pMsg, "password %s", aNewPassword) != 1) { SendChatTarget(ClientID, "Please stick to the given structure :"); SendChatTarget(ClientID, "/password <new password>"); return; } pPlayer->m_pAccount->ChangePassword(aNewPassword); return; } if(!str_comp_nocase(pMsg, "cmdlist")) { SendChatTarget(ClientID, "(***(---CMDLIST---)***)"); SendChatTarget(ClientID, "Type /infos - All informations"); SendChatTarget(ClientID, "Type /rules - Rules for all players"); SendChatTarget(ClientID, "Type /rules moderator - Rules for moderators"); SendChatTarget(ClientID, "Type /rules admin - Rules for admins"); SendChatTarget(ClientID, "Type /help - If you have problems with the registration"); SendChatTarget(ClientID, "Type /commands - All commands"); SendChatTarget(ClientID, "Type /lastupdate - See the last update of the mod"); return; } if(!str_comp_nocase(pMsg, "infos")) //cmdlist { SendChatTarget(ClientID, "(***(---INFOS---)***)"); SendChatTarget(ClientID, "Type /infos mod - For more informations about the mod"); SendChatTarget(ClientID, "Type /infos levels - For more informations about the levels"); SendChatTarget(ClientID, "Type /infos weapons - For more informations about the weapons"); SendChatTarget(ClientID, "Type /infos civil - For more informations about the civils"); SendChatTarget(ClientID, "Type /infos mafia - For more informations about the mafia"); SendChatTarget(ClientID, "Type /infos terrorist - For more informations about the terrorists"); SendChatTarget(ClientID, "Type /infos police - For more informations about the polices"); SendChatTarget(ClientID, "Type /infos benefits - For more informations about the benefits"); return; } if(!str_comp_nocase(pMsg, "infos mod")) //infos { SendChatTarget(ClientID, "(***(---INFOS MOD---)***)"); SendChatTarget(ClientID, "It's a mod civil, mafia, terrorist, police by Fefereta"); SendChatTarget(ClientID, "Server version : ?.?.? - ??.??.????"); SendChatTarget(ClientID, "Thx to Neox for helping me with the mod"); SendChatTarget(ClientID, "Type \"/infos civil\", \"/infos mafia\", \"/infos terrorist\" and \"/infos police\" for more informations"); return; } if(!str_comp_nocase(pMsg, "infos levels")) //infos { SendChatTarget(ClientID, "(***(---INFOS LEVELS---)***)"); SendChatTarget(ClientID, "Your score shows your current level"); SendChatTarget(ClientID, "You win 1 level per hour"); SendChatTarget(ClientID, "When you left the game, your playtime is saved automatically"); return; } if(!str_comp_nocase(pMsg, "infos weapons")) //infos { SendChatTarget(ClientID, "(***(---INFOS WEAPONS---)***)"); SendChatTarget(ClientID, "All weapons : Infinite ammo"); SendChatTarget(ClientID, "Hammer : No damage"); SendChatTarget(ClientID, "Gun : Auto gun, 3 damages per hit, more speed, infinite life"); SendChatTarget(ClientID, "Shotgun : 5 damages per ammo, long range"); SendChatTarget(ClientID, "Grenade : Long range, more speed, infinite life"); SendChatTarget(ClientID, "Laser : 15 damages per ammo"); SendChatTarget(ClientID, "Ninja : Switch"); return; } if(!str_comp_nocase(pMsg, "infos civil")) //infos { SendChatTarget(ClientID, "(***(---INFOS CIVIL---)***)"); SendChatTarget(ClientID, "When you spawn, you are a civil"); SendChatTarget(ClientID, "A civil can kill a terrorist and mafia members without penalty"); SendChatTarget(ClientID, "If the civil makes a deadly series (only killing civil), the civil is wanted"); SendChatTarget(ClientID, "If the civil kills a police, the civil is wanted"); SendChatTarget(ClientID, "If the civil wanted by the police, is killed by the police, the civil will respawn in a jail for a while"); return; } if(!str_comp_nocase(pMsg, "infos mafia")) //infos { SendChatTarget(ClientID, "(***(---INFOS MAFIA---)***)"); SendChatTarget(ClientID, "If you want to enter in the mafia, type this command :"); SendChatTarget(ClientID, "\"/mafia\" for enter in the mafia"); SendChatTarget(ClientID, "They are many mafia base on this map"); SendChatTarget(ClientID, "These bases could be controlled by anybody"); SendChatTarget(ClientID, "If the mafia user make a deadly series, the mafia user is wanted"); SendChatTarget(ClientID, "If the mafia user wanted by the police, is killed by the police, the mafia user respawn in a jail for a while"); return; } if(!str_comp_nocase(pMsg, "infos terrorist")) //infos { SendChatTarget(ClientID, "(***(---INFOS TERRORIST---)***)"); SendChatTarget(ClientID, "If you want to become a terrorist, type this command :"); SendChatTarget(ClientID, "\"/terrorist\" for become a terrorist"); SendChatTarget(ClientID, "When you are a terrorist,you can type the command :"); SendChatTarget(ClientID, "\"/terroristbase\" If you write this, you'll be teleported to the terrorist base"); SendChatTarget(ClientID, "In the terrorist base, you have the shotgun and the grenade"); SendChatTarget(ClientID, "If the terrorist make a deadly series, the terrorist is wanted"); SendChatTarget(ClientID, "If the terrorist wanted by the police, is killed by the police, the terrorist respawn in a jail for a while"); return; } if(!str_comp_nocase(pMsg, "infos police")) //infos { SendChatTarget(ClientID, "(***(---INFOS POLICE---)***)"); SendChatTarget(ClientID, "You can become a police if :"); SendChatTarget(ClientID, "You are premium"); SendChatTarget(ClientID, "You ask to an admin"); SendChatTarget(ClientID, "If the command is unlock, type :"); SendChatTarget(ClientID, "\"/police\" to become a police"); SendChatTarget(ClientID, "When you are a police, you can type the command :"); SendChatTarget(ClientID, "\"/policebase\" If you write this, you'll be teleported to the police base"); SendChatTarget(ClientID, "In the police base, you have all weapons"); SendChatTarget(ClientID, "The police can jail a player if he is wanted"); return; } if(!str_comp_nocase(pMsg, "infos benefits")) //infos { SendChatTarget(ClientID, "(***(---INFOS BENEFITS---)***)"); SendChatTarget(ClientID, "/premiumbenefits"); SendChatTarget(ClientID, "/howtobuypremium"); SendChatTarget(ClientID, "/basebenefits"); SendChatTarget(ClientID, "/howtobuybase"); SendChatTarget(ClientID, "/villabenefits"); SendChatTarget(ClientID, "/howtobuyvilla"); SendChatTarget(ClientID, "/powermodebenefits"); SendChatTarget(ClientID, "/howtobuypowermode"); return; } if(!str_comp_nocase(pMsg, "premiumbenefits")) //infos benefits { SendChatTarget(ClientID, "(***(---PREMIUM BENEFITS---)***)"); SendChatTarget(ClientID, "Premium benefits (Level 168 or 2 euros) :"); SendChatTarget(ClientID, "1 - A customizable house"); SendChatTarget(ClientID, "2 - A command to control the door of the house (open/close)"); SendChatTarget(ClientID, "3 - A command to teleport yourself in your house"); SendChatTarget(ClientID, "4 - All weapons in the house"); SendChatTarget(ClientID, "5 - Ninja"); SendChatTarget(ClientID, "6 - Splash"); SendChatTarget(ClientID, "7 - HP Regeneration"); SendChatTarget(ClientID, "8 - Jet pack"); SendChatTarget(ClientID, "9 - The ability to go into the premium places"); SendChatTarget(ClientID, "10 - Emotes"); SendChatTarget(ClientID, "11 - Infinite jumps/hook"); SendChatTarget(ClientID, "12 - Fly"); SendChatTarget(ClientID, "13 - Stars"); SendChatTarget(ClientID, "14 - More hp and ap"); SendChatTarget(ClientID, "15 - The command \"/police\" is unlocked"); SendChatTarget(ClientID, "Type \"/howtobuypremium\" to know how to buy the premium"); SendChatTarget(ClientID, "Press F1 (per default) to open the console and see all premium benefits"); return; } if(!str_comp_nocase(pMsg, "howtobuypremium")) //infos benefits { SendChatTarget(ClientID, "(***(---HOW TO BUY PREMIUM---)***)"); SendChatTarget(ClientID, "If you are level 168, you become automatically a premium user"); SendChatTarget(ClientID, "If you want to become a premium user now, donate 2 euros ON PAYPAL"); SendChatTarget(ClientID, "Donate here : [email protected]"); SendChatTarget(ClientID, "After your donation, ask Fefereta to become a premium user"); return; } if(!str_comp_nocase(pMsg, "basebenefits")) //infos benefits { SendChatTarget(ClientID, "(***(---BASE BENEFITS---)***)"); SendChatTarget(ClientID, "Base benefits (Level 200 or 5 euros) :"); SendChatTarget(ClientID, "1 - A base for your clan"); SendChatTarget(ClientID, "2 - Shotgun, grenade, laser in your base"); SendChatTarget(ClientID, "3 - All players can control the door with the switch (members will have to clean it)"); SendChatTarget(ClientID, "Type \"howtobuybase\" to know how buy a base"); return; } if(!str_comp_nocase(pMsg, "howtobuybase")) //infos benefits { SendChatTarget(ClientID, "(***(---HOW TO BUY BASE---)***)"); SendChatTarget(ClientID, "If you are level 200, you can have a base"); SendChatTarget(ClientID, "If you want to have a base now, donate 5 euros ON PAYPAL"); SendChatTarget(ClientID, "Donate here : [email protected]"); SendChatTarget(ClientID, "After your donation, ask Fefereta to have your base"); return; } if(!str_comp_nocase(pMsg, "villabenefits")) //infos benefits { SendChatTarget(ClientID, "(***(---VILLA BENEFITS---)***)"); SendChatTarget(ClientID, "Villa benefits (Level 300 or 5 euros) :"); SendChatTarget(ClientID, "1 - More space than the house"); SendChatTarget(ClientID, "2 - In the city"); SendChatTarget(ClientID, "3 - You can choose what you want in your villa"); SendChatTarget(ClientID, "4 - You have the control of the door"); SendChatTarget(ClientID, "5 - You can invit your friends in your villa"); SendChatTarget(ClientID, "Type \"howtobuyvilla\" to know how buy a villa"); return; } if(!str_comp_nocase(pMsg, "howtobuyvilla")) //infos benefits { SendChatTarget(ClientID, "(***(---HOW TO BUY VILLA---)***)"); SendChatTarget(ClientID, "If you are level 300, you can have a villa"); SendChatTarget(ClientID, "If you want to have a villa now, donate 5 euros ON PAYPAL"); SendChatTarget(ClientID, "Donate here : [email protected]"); SendChatTarget(ClientID, "After your donation, ask Fefereta to have your villa"); return; } if(!str_comp_nocase(pMsg, "powermodebenefits")) //infos benefits { SendChatTarget(ClientID, "(***(---POWER MODE BENEFITS---)***)"); SendChatTarget(ClientID, "Power mode benefits (Level 500 or 10 euros) :"); SendChatTarget(ClientID, "Type \"howtobuypowermode\" to know how buy a villa"); return; } if(!str_comp_nocase(pMsg, "howtobuypowermode")) //infos benefits { SendChatTarget(ClientID, "(***(---HOW TO BUY POWER MODE---)***)"); SendChatTarget(ClientID, "If you are level 500, you have automatically the power mode"); SendChatTarget(ClientID, "If you want to have the power mode now, donate 10 euros ON PAYPAL"); SendChatTarget(ClientID, "Donate here : [email protected]"); SendChatTarget(ClientID, "After your donation, ask Fefereta to have your power mode"); return; } if(!str_comp_nocase(pMsg, "rules")) //cmdlist { SendChatTarget(ClientID, "(***(---RULES---)***)"); SendChatTarget(ClientID, "Rule 1 : Don't insult !"); SendChatTarget(ClientID, "Rule 2 : Don't spam !"); SendChatTarget(ClientID, "Rule 3 : Don't spray !"); SendChatTarget(ClientID, "Rule 4 : Don't fake people !"); SendChatTarget(ClientID, "Rule 5 : Don't start funvotes !"); SendChatTarget(ClientID, "Rule 6 : Don't use bots !"); SendChatTarget(ClientID, "Rule 7 : Don't abuse bugs !"); SendChatTarget(ClientID, "Rule 8 : Don't troll !"); SendChatTarget(ClientID, "Rule 9 : Don't use an anti-afk !"); SendChatTarget(ClientID, "Rule 10 : Don't camp the spawn for kill a player !"); SendChatTarget(ClientID, "Don't break any rules or you will get punished, have fun !"); return; } if(!str_comp_nocase(pMsg, "rules moderator")) //cmdlist { if(!IsMod) { SendChatTarget(ClientID, "You are not a moderator"); return; } SendChatTarget(ClientID, "(***(---RULES MODERATOR---)***)"); SendChatTarget(ClientID, "Rule 1 : You have to help beginners"); SendChatTarget(ClientID, "Rule 2 : Don't use the moderation commands for fun"); SendChatTarget(ClientID, "Rule 3 : Take a screenshot when you're using a moderation commands"); return; } if(!str_comp_nocase(pMsg, "rules admin")) //cmdlist { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } SendChatTarget(ClientID, "(***(---RULES ADMIN---)***)"); SendChatTarget(ClientID, "Rule 1 : Don't kill a player with the admin commands"); SendChatTarget(ClientID, "Rule 2 : Don't use the admin rcon commands for fun"); SendChatTarget(ClientID, "Rule 3 : Don't spam with commands text"); SendChatTarget(ClientID, "Rule 4 : Don't use all the time the admin commands"); SendChatTarget(ClientID, "Rule 5 : Don't edit the settings of the server"); SendChatTarget(ClientID, "Rule 6 : Don't use admin rcon commands and admin commands on a other admin"); return; } if(!str_comp_nocase(pMsg, "help")) //cmdlist { SendChatTarget(ClientID, "(***(---HELP---)***)"); SendChatTarget(ClientID, "To register, type :"); SendChatTarget(ClientID, "/register <name> <password>"); SendChatTarget(ClientID, "Don't lost your account !"); SendChatTarget(ClientID, "When you register for the first time, you join automatically the game"); SendChatTarget(ClientID, "If you are already registered, type :"); SendChatTarget(ClientID, "/login <yourname> <yourpassword>"); SendChatTarget(ClientID, "If you can't register or login, ask a modo/admin for help"); SendChatTarget(ClientID, "Please report any bugs to an admin !"); SendChatTarget(ClientID, "Good game !"); return; } if(!str_comp_nocase(pMsg, "commands")) //cmdlist { SendChatTarget(ClientID, "(***(---COMMANDS---)***)"); SendChatTarget(ClientID, "/mafiacmds - Commands for mafia user"); SendChatTarget(ClientID, "/terroristcmds - Commands for terrorist user"); SendChatTarget(ClientID, "/policecmds - Commands for police user"); SendChatTarget(ClientID, "/premiumcmds - Commands for premium user"); SendChatTarget(ClientID, "/housecmds - Commands for control the house"); SendChatTarget(ClientID, "/villacmds - Commands for control the house"); SendChatTarget(ClientID, "/modercmds - Commands for moderator user"); SendChatTarget(ClientID, "/admincmds - Commands for admin user"); SendChatTarget(ClientID, "/adminrconcmds - Commands rcon for admin user"); return; } if(!str_comp_nocase(pMsg, "mafiacmds")) //commands { /*if(!IsTerrorist) { SendChatTarget(ClientID, "You are not a mafia user"); return; }*/ SendChatTarget(ClientID, "(***(---MAFIA CMDS---)***)"); SendChatTarget(ClientID, "/mafia - To enter in the mafia"); return; } if(!str_comp_nocase(pMsg, "terroristcmds")) //commands { /*if(!IsTerrorist) { SendChatTarget(ClientID, "You are not a terrorist"); return; }*/ SendChatTarget(ClientID, "(***(---TERRORIST CMDS---)***)"); SendChatTarget(ClientID, "/terrorist - To become a terrorist"); SendChatTarget(ClientID, "/terroristbase - Teleports to the terrorist base"); return; } if(!str_comp_nocase(pMsg, "policecmds")) //commands { /*if(!IsPolice) { SendChatTarget(ClientID, "You are not a police"); return; }*/ SendChatTarget(ClientID, "(***(---POLICE CMDS---)***)"); SendChatTarget(ClientID, "/police - To become a police"); SendChatTarget(ClientID, "/policebase - Teleport to the police base"); return; } if(!str_comp_nocase(pMsg, "premiumcmds")) //commands { /*if(!IsPremium) { SendChatTarget(ClientID, "You are not a premium user"); return; }*/ SendChatTarget(ClientID, "(***(---PREMIUM CMDS---)***)"); SendChatTarget(ClientID, "/ninja - Give the ninja"); SendChatTarget(ClientID, "/rainbow"); SendChatTarget(ClientID, "/splash"); SendChatTarget(ClientID, "/jetpack"); SendChatTarget(ClientID, "/emote, /stars"); SendChatTarget(ClientID, "/tpto (id) - Teleports to others players"); SendChatTarget(ClientID, "/tpfrom (id) - Teleports players to you"); SendChatTarget(ClientID, "/up, /down, /left, /right - You can move you through walls"); SendChatTarget(ClientID, "/jump, /hook, /fly - Infinite jumps and hook and you can fly"); return; } if(!str_comp_nocase(pMsg, "housecmds")) //commands { /*if(!IsPremium) { SendChatTarget(ClientID, "You are not a premium user"); return; }*/ SendChatTarget(ClientID, "(***(---HOUSE CMDS---)***)"); SendChatTarget(ClientID, "/househome - Teleports you in your house"); SendChatTarget(ClientID, "/doorhouse - Open/close your door of your house"); return; } if(!str_comp_nocase(pMsg, "villacmds")) //commands { /*if(!IsPremium) { SendChatTarget(ClientID, "You are not a premium user"); return; }*/ SendChatTarget(ClientID, "(***(---VILLA CMDS---)***)"); SendChatTarget(ClientID, "/villahome - Teleports you in your villa"); SendChatTarget(ClientID, "/doorvilla - Open/close your door of your villa"); return; } if(!str_comp_nocase(pMsg, "modercmds")) //commands { if(!IsMod) { SendChatTarget(ClientID, "You are not a moderator"); return; } SendChatTarget(ClientID, "(***(---MODERATION CMDS---)***)"); SendChatTarget(ClientID, "/status - See all players IDs"); SendChatTarget(ClientID, "/ban (id) (time) (reason) - The command for ban a player"); SendChatTarget(ClientID, "/kick (id) (time) (reason) - The command for kick a player"); SendChatTarget(ClientID, "/mute (id) (time) (reason) - The command for mute a player"); SendChatTarget(ClientID, "/jail (id) (time) (reason) - The command for jail a player"); SendChatTarget(ClientID, "/kill (id) (reason) - The command for kill a player"); SendChatTarget(ClientID, "/freeze (id) (time) (reason) - The command for freeze a player"); SendChatTarget(ClientID, "/bans - See a list with all players banned and with all IPs"); SendChatTarget(ClientID, "/unban (ip) - Unban a player"); SendChatTarget(ClientID, "/unmute (id) - Unmute a player"); SendChatTarget(ClientID, "/unjail (id) - Unjail a player"); SendChatTarget(ClientID, "/unfreeze (id) - Unfreeze a player"); SendChatTarget(ClientID, "/mutechat - Mute the chat, only admins/polices can write in the chat"); SendChatTarget(ClientID, "/unmutechat - Unmute the chat"); SendChatTarget(ClientID, "/slowchat (time) - Slow the chat, (time) is the time that the player must wait to write a message"); SendChatTarget(ClientID, "Press F1 (per default) to open the console and see all commands"); return; } if(!str_comp_nocase(pMsg, "admincmds")) //commands { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } SendChatTarget(ClientID, "(***(---ADMIN CMDS---)***)"); SendChatTarget(ClientID, "/immu - Immunity"); SendChatTarget(ClientID, "/fshot - (very) fast reload"); SendChatTarget(ClientID, "/invisible - Invisible on the server"); //SendChatTarget(ClientID, "/fullinvisible - Full invisible on the server"); SendChatTarget(ClientID, "/tele - Teleports you where you aim to"); SendChatTarget(ClientID, "/aimbot (id) - Active an aimbot for a player"); SendChatTarget(ClientID, "/giveweapons - Give all weapons"); SendChatTarget(ClientID, "/rainbow - Rainbow color"); return; } if(!str_comp_nocase(pMsg, "adminrconcmds")) //commands { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } SendChatTarget(ClientID, "(***(---ADMIN RCON CMDS---)***)"); SendChatTarget(ClientID, "Open the console of the server (F2) and you can type :"); SendChatTarget(ClientID, "say (text)"); SendChatTarget(ClientID, "sayby (id) (text)"); SendChatTarget(ClientID, "broadcast (text)"); SendChatTarget(ClientID, "change_name (id) (name)"); SendChatTarget(ClientID, "change_clan (id) (clan)"); SendChatTarget(ClientID, "set_hammer (id) (number)"); return; } if(!str_comp_nocase(pMsg, "lastupdate")) //cmdlist { SendChatTarget(ClientID, "(***(---LAST UPDATE---)***)"); SendChatTarget(ClientID, "Last update : 7/06/2016"); SendChatTarget(ClientID, "/rules moderator - Modified"); SendChatTarget(ClientID, "/rules admin - Modified"); SendChatTarget(ClientID, "/infos weapons - Modified"); SendChatTarget(ClientID, "/premiumbenefits - Modified"); SendChatTarget(ClientID, "/powermodebenefits - Added"); SendChatTarget(ClientID, "/howtobuypowermode - Added"); return; } if(!str_comp_nocase_num(pMsg, "aimbot", 6))//6 = nombre de character de "aimbot" { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } int Cid;//Cid = Client id if(sscanf(pMsg, "aimbot %d", &Cid) != 1) { SendChatTarget(ClientID, "Please stick to the given structure :"); SendChatTarget(ClientID, "/aimbot <id>"); return; } if(Cid < 0 || Cid >= MAX_CLIENTS) { SendChatTarget(ClientID, "You can only choose IDs between 0 and 15"); return; } if(!m_apPlayers[Cid]) { SendChatTarget(ClientID, "Invalid client ID"); return; } //^= ça change de false en true, de true en false. Ne fonctionne uniquement quand de base c'est à false, //je sais pas trop comment ça marche, c'est Piko qui me l'a apprit ^^ m_apPlayers[Cid]->m_AimBot ^= true; char aBuf[256]; str_format(aBuf, sizeof(aBuf), "'%s's aimbot %s", Server()->ClientName(Cid), m_apPlayers[Cid]->m_AimBot ? "enabled" : "disabled"); SendChatTarget(ClientID, aBuf); return; } if(!str_comp_nocase(pMsg, "invisible")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } if(pPlayer->m_Invis) { pPlayer->m_Invis = false; SendChatTarget(ClientID, "Invisible desactivated!"); } else { pPlayer->m_Invis = true; SendChatTarget(ClientID, "Invisible activated!"); } return; } if(!str_comp_nocase(pMsg, "tele")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } if(GetPlayerChar(ClientID)) GetPlayerChar(ClientID)->MovePos(vec2(pPlayer->m_LatestActivity.m_TargetX, pPlayer->m_LatestActivity.m_TargetY)); return; } if(!str_comp_nocase(pMsg, "giveweapons")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } if(!GetPlayerChar(ClientID)) { SendChatTarget(ClientID, "Wait to respawn to do this"); return; } for(int i = 0; i < NUM_WEAPONS; i++) { if(i == WEAPON_NINJA) continue; GetPlayerChar(ClientID)->GiveWeapon(i, 10);//On peut mettre -1 aussi pour munitions illimités, mais si on met -1 ça va ramasser les armes. } SendChatTarget(ClientID, "You now have all weapons"); return; } if(!str_comp_nocase(pMsg, "immu")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } pPlayer->m_Immunity ^= true; SendChatTarget(ClientID, pPlayer->m_Immunity ? "Immunity enabled !" : "Immunity disabled."); CCharacter *pChar = GetPlayerChar(ClientID); if(!pChar) return; CreateDeath(pChar->GetPos(), ClientID); return; } /*if(!str_comp_nocase(pMsg, "fullinvisible")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } pPlayer->m_FullInvisible ^= true; SendChatTarget(ClientID, pPlayer->m_Immunity ? "Fullinvisible enabled !" : "Fullinvisible disabled."); char aBuf[256]; if(pPlayer->m_FullInvisible) { str_format(aBuf, sizeof(aBuf), "'%s' has left the game", Server()->ClientName(ClientID)); SendChatTarget(-1, aBuf); } else { //faudra changer ça si tu veux faire plus réaliste, quand tu auras des comptes //pck tu vas entrer en spec avant, si y a pas le message de spec ça va paraitre (je l'ai mal écrit mais osef) chelou str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the game", Server()->ClientName(ClientID)); SendChatTarget(-1, aBuf); m_SendMsgTick = Server()->TickSpeed() * 2; m_SendMsgID = ClientID; } return; }*/ if(!str_comp_nocase(pMsg, "fshot")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } pPlayer->m_FastShooting ^= true; SendChatTarget(ClientID, pPlayer->m_FastShooting ? "Fast shooting enabled !" : "Fast shooting disabled."); return; } if(!str_comp_nocase(pMsg, "up")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } if(GetPlayerChar(ClientID)) GetPlayerChar(ClientID)->MovePos(vec2(0, -32)); return; } if(!str_comp_nocase(pMsg, "down")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } if(GetPlayerChar(ClientID)) GetPlayerChar(ClientID)->MovePos(vec2(0, 32)); return; } if(!str_comp_nocase(pMsg, "left")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } if(GetPlayerChar(ClientID)) GetPlayerChar(ClientID)->MovePos(vec2(-32, 0)); return; } if(!str_comp_nocase(pMsg, "right")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } if(GetPlayerChar(ClientID)) GetPlayerChar(ClientID)->MovePos(vec2(32, 0)); return; } if(!str_comp_nocase(pMsg, "rainbow")) { if(!IsAdmin) { SendChatTarget(ClientID, "You are not an admin"); return; } pPlayer->m_Rainbow ^= true; SendChatTarget(ClientID, pPlayer->m_Rainbow ? "Rainbow enabled !" : "Rainbow disabled."); return; } SendChatTarget(ClientID, "Unknow command. Try \"/cmdlist\"."); }
void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgID, pUnpacker); CPlayer *pPlayer = m_apPlayers[ClientID]; if(!pRawMsg) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn()); Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf); return; } if(MsgID == NETMSGTYPE_CL_SAY) { CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; int Team = pMsg->m_Team; if(Team) Team = pPlayer->GetTeam(); else Team = CGameContext::CHAT_ALL; if(g_Config.m_SvSpamprotection && pPlayer->m_LastChat && pPlayer->m_LastChat+Server()->TickSpeed() > Server()->Tick()) return; pPlayer->m_LastChat = Server()->Tick(); // check for invalid chars unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage; while (*pMessage) { if(*pMessage < 32) *pMessage = ' '; pMessage++; } SendChat(ClientID, Team, pMsg->m_pMessage); } else if(MsgID == NETMSGTYPE_CL_CALLVOTE) { if(g_Config.m_SvSpamprotection && pPlayer->m_LastVoteTry && pPlayer->m_LastVoteTry+Server()->TickSpeed()*3 > Server()->Tick()) return; int64 Now = Server()->Tick(); pPlayer->m_LastVoteTry = Now; if(pPlayer->GetTeam() == TEAM_SPECTATORS) { SendChatTarget(ClientID, "Spectators aren't allowed to start a vote."); return; } if(m_VoteCloseTime) { SendChatTarget(ClientID, "Wait for current vote to end before calling a new one."); return; } int Timeleft = pPlayer->m_LastVoteCall + Server()->TickSpeed()*60 - Now; if(pPlayer->m_LastVoteCall && Timeleft > 0) { char aChatmsg[512] = {0}; str_format(aChatmsg, sizeof(aChatmsg), "You must wait %d seconds before making another vote", (Timeleft/Server()->TickSpeed())+1); SendChatTarget(ClientID, aChatmsg); return; } char aChatmsg[512] = {0}; char aDesc[VOTE_DESC_LENGTH] = {0}; char aCmd[VOTE_CMD_LENGTH] = {0}; CNetMsg_Cl_CallVote *pMsg = (CNetMsg_Cl_CallVote *)pRawMsg; const char *pReason = pMsg->m_Reason[0] ? pMsg->m_Reason : "No reason given"; if(str_comp_nocase(pMsg->m_Type, "option") == 0) { CVoteOptionServer *pOption = m_pVoteOptionFirst; while(pOption) { if(str_comp_nocase(pMsg->m_Value, pOption->m_aDescription) == 0) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s' (%s)", Server()->ClientName(ClientID), pOption->m_aDescription, pReason); str_format(aDesc, sizeof(aDesc), "%s", pOption->m_aDescription); str_format(aCmd, sizeof(aCmd), "%s", pOption->m_aCommand); break; } pOption = pOption->m_pNext; } if(!pOption) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value); SendChatTarget(ClientID, aChatmsg); return; } } else if(str_comp_nocase(pMsg->m_Type, "kick") == 0) { if(!g_Config.m_SvVoteKick) { SendChatTarget(ClientID, "Server does not allow voting to kick players"); return; } if(g_Config.m_SvVoteKickMin) { int PlayerNum = 0; for(int i = 0; i < MAX_CLIENTS; ++i) if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) ++PlayerNum; if(PlayerNum < g_Config.m_SvVoteKickMin) { str_format(aChatmsg, sizeof(aChatmsg), "Kick voting requires %d players on the server", g_Config.m_SvVoteKickMin); SendChatTarget(ClientID, aChatmsg); return; } } int KickID = str_toint(pMsg->m_Value); if(KickID < 0 || KickID >= MAX_CLIENTS || !m_apPlayers[KickID]) { SendChatTarget(ClientID, "Invalid client id to kick"); return; } if(KickID == ClientID) { SendChatTarget(ClientID, "You cant kick yourself"); return; } if(Server()->IsAuthed(KickID)) { SendChatTarget(ClientID, "You cant kick admins"); char aBufKick[128]; str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID)); SendChatTarget(KickID, aBufKick); return; } str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), pReason); str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID)); if (!g_Config.m_SvVoteKickBantime) str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickID); else { char aAddrStr[NETADDR_MAXSTRSIZE] = {0}; Server()->GetClientAddr(KickID, aAddrStr, sizeof(aAddrStr)); str_format(aCmd, sizeof(aCmd), "ban %s %d Banned by vote", aAddrStr, g_Config.m_SvVoteKickBantime); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aCmd); } } else if(str_comp_nocase(pMsg->m_Type, "spectate") == 0) { if(!g_Config.m_SvVoteSpectate) { SendChatTarget(ClientID, "Server does not allow voting to move players to spectators"); return; } int SpectateID = str_toint(pMsg->m_Value); if(SpectateID < 0 || SpectateID >= MAX_CLIENTS || !m_apPlayers[SpectateID] || m_apPlayers[SpectateID]->GetTeam() == TEAM_SPECTATORS) { SendChatTarget(ClientID, "Invalid client id to move"); return; } if(SpectateID == ClientID) { SendChatTarget(ClientID, "You cant move yourself"); return; } str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to move '%s' to spectators (%s)", Server()->ClientName(ClientID), Server()->ClientName(SpectateID), pReason); str_format(aDesc, sizeof(aDesc), "move '%s' to spectators", Server()->ClientName(SpectateID)); str_format(aCmd, sizeof(aCmd), "set_team %d -1", SpectateID); } if(aCmd[0]) { SendChat(-1, CGameContext::CHAT_ALL, aChatmsg); StartVote(aDesc, aCmd, pReason); pPlayer->m_Vote = 1; pPlayer->m_VotePos = m_VotePos = 1; m_VoteCreator = ClientID; pPlayer->m_LastVoteCall = Now; } } else if(MsgID == NETMSGTYPE_CL_VOTE) { if(!m_VoteCloseTime) return; if(pPlayer->m_Vote == 0) { CNetMsg_Cl_Vote *pMsg = (CNetMsg_Cl_Vote *)pRawMsg; if(!pMsg->m_Vote) return; pPlayer->m_Vote = pMsg->m_Vote; pPlayer->m_VotePos = ++m_VotePos; m_VoteUpdate = true; } } else if (MsgID == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused) { CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg; if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetTeam && pPlayer->m_LastSetTeam+Server()->TickSpeed()*3 > Server()->Tick())) return; // Switch team on given client and kill/respawn him if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID)) { if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team)) { pPlayer->m_LastSetTeam = Server()->Tick(); if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS) m_VoteUpdate = true; pPlayer->SetTeam(pMsg->m_Team); (void)m_pController->CheckTeamBalance(); } else SendBroadcast("Teams must be balanced, please join other team", ClientID); } else { char aBuf[128]; str_format(aBuf, sizeof(aBuf), "Only %d active players are allowed", g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots); SendBroadcast(aBuf, ClientID); } } else if (MsgID == NETMSGTYPE_CL_SETSPECTATORMODE && !m_World.m_Paused) { CNetMsg_Cl_SetSpectatorMode *pMsg = (CNetMsg_Cl_SetSpectatorMode *)pRawMsg; if(pPlayer->GetTeam() != TEAM_SPECTATORS || pPlayer->m_SpectatorID == pMsg->m_SpectatorID || ClientID == pMsg->m_SpectatorID || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetSpectatorMode && pPlayer->m_LastSetSpectatorMode+Server()->TickSpeed()*3 > Server()->Tick())) return; pPlayer->m_LastSetSpectatorMode = Server()->Tick(); if(pMsg->m_SpectatorID != SPEC_FREEVIEW && (!m_apPlayers[pMsg->m_SpectatorID] || m_apPlayers[pMsg->m_SpectatorID]->GetTeam() == TEAM_SPECTATORS)) SendChatTarget(ClientID, "Invalid spectator id used"); else pPlayer->m_SpectatorID = pMsg->m_SpectatorID; } else if (MsgID == NETMSGTYPE_CL_STARTINFO) { if(pPlayer->m_IsReady) return; CNetMsg_Cl_StartInfo *pMsg = (CNetMsg_Cl_StartInfo *)pRawMsg; pPlayer->m_LastChangeInfo = Server()->Tick(); // set start infos Server()->SetClientName(ClientID, pMsg->m_pName); Server()->SetClientClan(ClientID, pMsg->m_pClan); Server()->SetClientCountry(ClientID, pMsg->m_Country); str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; m_pController->OnPlayerInfoChange(pPlayer); // send vote options CNetMsg_Sv_VoteClearOptions ClearMsg; Server()->SendPackMsg(&ClearMsg, MSGFLAG_VITAL, ClientID); CNetMsg_Sv_VoteOptionListAdd OptionMsg; int NumOptions = 0; OptionMsg.m_pDescription0 = ""; OptionMsg.m_pDescription1 = ""; OptionMsg.m_pDescription2 = ""; OptionMsg.m_pDescription3 = ""; OptionMsg.m_pDescription4 = ""; OptionMsg.m_pDescription5 = ""; OptionMsg.m_pDescription6 = ""; OptionMsg.m_pDescription7 = ""; OptionMsg.m_pDescription8 = ""; OptionMsg.m_pDescription9 = ""; OptionMsg.m_pDescription10 = ""; OptionMsg.m_pDescription11 = ""; OptionMsg.m_pDescription12 = ""; OptionMsg.m_pDescription13 = ""; OptionMsg.m_pDescription14 = ""; CVoteOptionServer *pCurrent = m_pVoteOptionFirst; while(pCurrent) { switch(NumOptions++) { case 0: OptionMsg.m_pDescription0 = pCurrent->m_aDescription; break; case 1: OptionMsg.m_pDescription1 = pCurrent->m_aDescription; break; case 2: OptionMsg.m_pDescription2 = pCurrent->m_aDescription; break; case 3: OptionMsg.m_pDescription3 = pCurrent->m_aDescription; break; case 4: OptionMsg.m_pDescription4 = pCurrent->m_aDescription; break; case 5: OptionMsg.m_pDescription5 = pCurrent->m_aDescription; break; case 6: OptionMsg.m_pDescription6 = pCurrent->m_aDescription; break; case 7: OptionMsg.m_pDescription7 = pCurrent->m_aDescription; break; case 8: OptionMsg.m_pDescription8 = pCurrent->m_aDescription; break; case 9: OptionMsg.m_pDescription9 = pCurrent->m_aDescription; break; case 10: OptionMsg.m_pDescription10 = pCurrent->m_aDescription; break; case 11: OptionMsg.m_pDescription11 = pCurrent->m_aDescription; break; case 12: OptionMsg.m_pDescription12 = pCurrent->m_aDescription; break; case 13: OptionMsg.m_pDescription13 = pCurrent->m_aDescription; break; case 14: { OptionMsg.m_pDescription14 = pCurrent->m_aDescription; OptionMsg.m_NumOptions = NumOptions; Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); OptionMsg = CNetMsg_Sv_VoteOptionListAdd(); NumOptions = 0; OptionMsg.m_pDescription1 = ""; OptionMsg.m_pDescription2 = ""; OptionMsg.m_pDescription3 = ""; OptionMsg.m_pDescription4 = ""; OptionMsg.m_pDescription5 = ""; OptionMsg.m_pDescription6 = ""; OptionMsg.m_pDescription7 = ""; OptionMsg.m_pDescription8 = ""; OptionMsg.m_pDescription9 = ""; OptionMsg.m_pDescription10 = ""; OptionMsg.m_pDescription11 = ""; OptionMsg.m_pDescription12 = ""; OptionMsg.m_pDescription13 = ""; OptionMsg.m_pDescription14 = ""; } } pCurrent = pCurrent->m_pNext; } if(NumOptions > 0) { OptionMsg.m_NumOptions = NumOptions; Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); NumOptions = 0; } // send tuning parameters to client SendTuningParams(ClientID); // client is ready to enter pPlayer->m_IsReady = true; CNetMsg_Sv_ReadyToEnter m; Server()->SendPackMsg(&m, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID); } else if (MsgID == NETMSGTYPE_CL_CHANGEINFO) { if(g_Config.m_SvSpamprotection && pPlayer->m_LastChangeInfo && pPlayer->m_LastChangeInfo+Server()->TickSpeed()*5 > Server()->Tick()) return; CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg; pPlayer->m_LastChangeInfo = Server()->Tick(); // set infos char aOldName[MAX_NAME_LENGTH]; str_copy(aOldName, Server()->ClientName(ClientID), sizeof(aOldName)); Server()->SetClientName(ClientID, pMsg->m_pName); if(str_comp(aOldName, Server()->ClientName(ClientID)) != 0) { char aChatText[256]; str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientID)); SendChat(-1, CGameContext::CHAT_ALL, aChatText); } Server()->SetClientClan(ClientID, pMsg->m_pClan); Server()->SetClientCountry(ClientID, pMsg->m_Country); str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; m_pController->OnPlayerInfoChange(pPlayer); } else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused) { CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg; if(g_Config.m_SvSpamprotection && pPlayer->m_LastEmote && pPlayer->m_LastEmote+Server()->TickSpeed()*3 > Server()->Tick()) return; pPlayer->m_LastEmote = Server()->Tick(); SendEmoticon(ClientID, pMsg->m_Emoticon); } else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused) { if(pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*3 > Server()->Tick()) return; pPlayer->m_LastKill = Server()->Tick(); pPlayer->KillCharacter(WEAPON_SELF); } }
void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgID, pUnpacker); CPlayer *pPlayer = m_apPlayers[ClientID]; if(!pRawMsg) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn()); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); return; } if(MsgID == NETMSGTYPE_CL_SAY) { CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; int Team = pMsg->m_Team; if(Team) Team = pPlayer->GetTeam(); else Team = CGameContext::CHAT_ALL; if(g_Config.m_SvSpamprotection && pPlayer->m_Last_Chat && pPlayer->m_Last_Chat+Server()->TickSpeed() > Server()->Tick()) return; pPlayer->m_Last_Chat = Server()->Tick(); // check for invalid chars unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage; while (*pMessage) { if(*pMessage < 32) *pMessage = ' '; pMessage++; } SendChat(ClientID, Team, pMsg->m_pMessage); } else if(MsgID == NETMSGTYPE_CL_CALLVOTE) { if(g_Config.m_SvSpamprotection && pPlayer->m_Last_VoteTry && pPlayer->m_Last_VoteTry+Server()->TickSpeed()*3 > Server()->Tick()) return; int64 Now = Server()->Tick(); pPlayer->m_Last_VoteTry = Now; if(pPlayer->GetTeam() == TEAM_SPECTATORS) { SendChatTarget(ClientID, "Spectators aren't allowed to start a vote."); return; } if(m_VoteCloseTime) { SendChatTarget(ClientID, "Wait for current vote to end before calling a new one."); return; } int Timeleft = pPlayer->m_Last_VoteCall + Server()->TickSpeed()*60 - Now; if(pPlayer->m_Last_VoteCall && Timeleft > 0) { char aChatmsg[512] = {0}; str_format(aChatmsg, sizeof(aChatmsg), "You must wait %d seconds before making another vote", (Timeleft/Server()->TickSpeed())+1); SendChatTarget(ClientID, aChatmsg); return; } char aChatmsg[512] = {0}; char aDesc[512] = {0}; char aCmd[512] = {0}; CNetMsg_Cl_CallVote *pMsg = (CNetMsg_Cl_CallVote *)pRawMsg; if(str_comp_nocase(pMsg->m_Type, "option") == 0) { CVoteOption *pOption = m_pVoteOptionFirst; while(pOption) { if(str_comp_nocase(pMsg->m_Value, pOption->m_aCommand) == 0) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s'", Server()->ClientName(ClientID), pOption->m_aCommand); str_format(aDesc, sizeof(aDesc), "%s", pOption->m_aCommand); str_format(aCmd, sizeof(aCmd), "%s", pOption->m_aCommand); break; } pOption = pOption->m_pNext; } if(!pOption) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value); SendChatTarget(ClientID, aChatmsg); return; } } else if(str_comp_nocase(pMsg->m_Type, "kick") == 0) { if(!g_Config.m_SvVoteKick) { SendChatTarget(ClientID, "Server does not allow voting to kick players"); return; } int KickID = str_toint(pMsg->m_Value); if(KickID < 0 || KickID >= MAX_CLIENTS || !m_apPlayers[KickID]) { SendChatTarget(ClientID, "Invalid client id to kick"); return; } if(KickID == ClientID) { SendChatTarget(ClientID, "You cant kick yourself"); return; } if(Server()->IsAuthed(KickID)) { SendChatTarget(ClientID, "You cant kick admins"); char aBufKick[128]; str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID)); SendChatTarget(KickID, aBufKick); return; } const char *pReason = "No reason given"; for(const char *pStr = pMsg->m_Value; *pStr; ++pStr) { if(*pStr == ' ') { pReason = pStr+1; break; } } str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), pReason); str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID)); if (!g_Config.m_SvVoteKickBantime) str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickID); else { char aBuf[64] = {0}; Server()->GetClientIP(KickID, aBuf, sizeof(aBuf)); str_format(aCmd, sizeof(aCmd), "ban %s %d Banned by vote", aBuf, g_Config.m_SvVoteKickBantime); } } if(aCmd[0]) { SendChat(-1, CGameContext::CHAT_ALL, aChatmsg); StartVote(aDesc, aCmd); pPlayer->m_Vote = 1; pPlayer->m_VotePos = m_VotePos = 1; m_VoteCreator = ClientID; pPlayer->m_Last_VoteCall = Now; } } else if(MsgID == NETMSGTYPE_CL_VOTE) { if(!m_VoteCloseTime) return; if(pPlayer->m_Vote == 0) { CNetMsg_Cl_Vote *pMsg = (CNetMsg_Cl_Vote *)pRawMsg; if(!pMsg->m_Vote) return; pPlayer->m_Vote = pMsg->m_Vote; pPlayer->m_VotePos = ++m_VotePos; m_VoteUpdate = true; } } else if (MsgID == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused) { CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg; if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_Last_SetTeam && pPlayer->m_Last_SetTeam+Server()->TickSpeed()*3 > Server()->Tick())) return; // Switch team on given client and kill/respawn him if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID)) { if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team)) { pPlayer->m_Last_SetTeam = Server()->Tick(); if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS) m_VoteUpdate = true; pPlayer->SetTeam(pMsg->m_Team); (void)m_pController->CheckTeamBalance(); } else SendBroadcast("Teams must be balanced, please join other team", ClientID); } else { char aBuf[128]; str_format(aBuf, sizeof(aBuf), "Only %d active players are allowed", g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots); SendBroadcast(aBuf, ClientID); } } else if (MsgID == NETMSGTYPE_CL_CHANGEINFO || MsgID == NETMSGTYPE_CL_STARTINFO) { CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg; if(g_Config.m_SvSpamprotection && pPlayer->m_Last_ChangeInfo && pPlayer->m_Last_ChangeInfo+Server()->TickSpeed()*5 > Server()->Tick()) return; pPlayer->m_Last_ChangeInfo = Server()->Tick(); pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; // copy old name char aOldName[MAX_NAME_LENGTH]; str_copy(aOldName, Server()->ClientName(ClientID), MAX_NAME_LENGTH); Server()->SetClientName(ClientID, pMsg->m_pName); if(MsgID == NETMSGTYPE_CL_CHANGEINFO && str_comp(aOldName, Server()->ClientName(ClientID)) != 0) { char aChatText[256]; str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientID)); SendChat(-1, CGameContext::CHAT_ALL, aChatText); } // set skin str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); m_pController->OnPlayerInfoChange(pPlayer); if(MsgID == NETMSGTYPE_CL_STARTINFO) { // send vote options CNetMsg_Sv_VoteClearOptions ClearMsg; Server()->SendPackMsg(&ClearMsg, MSGFLAG_VITAL, ClientID); CVoteOption *pCurrent = m_pVoteOptionFirst; while(pCurrent) { CNetMsg_Sv_VoteOption OptionMsg; OptionMsg.m_pCommand = pCurrent->m_aCommand; Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); pCurrent = pCurrent->m_pNext; } // send tuning parameters to client SendTuningParams(ClientID); // CNetMsg_Sv_ReadyToEnter m; Server()->SendPackMsg(&m, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID); } } else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused) { CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg; if(g_Config.m_SvSpamprotection && pPlayer->m_Last_Emote && pPlayer->m_Last_Emote+Server()->TickSpeed()*3 > Server()->Tick()) return; pPlayer->m_Last_Emote = Server()->Tick(); SendEmoticon(ClientID, pMsg->m_Emoticon); } else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused) { if(pPlayer->m_Last_Kill && pPlayer->m_Last_Kill+Server()->TickSpeed()*3 > Server()->Tick()) return; pPlayer->m_Last_Kill = Server()->Tick(); pPlayer->KillCharacter(WEAPON_SELF); pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()*3; } }