#include #include "W3SIncs/War3Source_Interface" new Handle:Cvar_ChatBlocking; new Handle:g_OnUltimateCommandHandle; new Handle:g_OnAbilityCommandHandle; public Plugin:myinfo= { name="W3S Engine Command Hooks", author="Ownz (DarkEnergy)", description="War3Source Core Plugins", version="1.0", url="http://war3source.com/" }; public OnPluginStart() { Cvar_ChatBlocking=CreateConVar("war3_command_blocking","0","block chat commands from showing up"); if(W3()){ RegConsoleCmd("say",War3Source_SayCommand); RegConsoleCmd("say_team",War3Source_SayCommand); RegConsoleCmd("+ultimate",War3Source_UltimateCommand); RegConsoleCmd("-ultimate",War3Source_UltimateCommand); RegConsoleCmd("+ability",War3Source_NoNumAbilityCommand); RegConsoleCmd("-ability",War3Source_NoNumAbilityCommand); //dont blame me if ur race is a failure because theres too much buttons to press RegConsoleCmd("+ability1",War3Source_AbilityCommand); RegConsoleCmd("-ability1",War3Source_AbilityCommand); RegConsoleCmd("+ability2",War3Source_AbilityCommand); RegConsoleCmd("-ability2",War3Source_AbilityCommand); RegConsoleCmd("+ability3",War3Source_AbilityCommand); RegConsoleCmd("-ability3",War3Source_AbilityCommand); RegConsoleCmd("+ability4",War3Source_AbilityCommand); RegConsoleCmd("-ability4",War3Source_AbilityCommand); RegConsoleCmd("ability",War3Source_OldWCSCommand); RegConsoleCmd("ability1",War3Source_OldWCSCommand); RegConsoleCmd("ability2",War3Source_OldWCSCommand); RegConsoleCmd("ability3",War3Source_OldWCSCommand); RegConsoleCmd("ability4",War3Source_OldWCSCommand); RegConsoleCmd("ultimate",War3Source_OldWCSCommand); RegConsoleCmd("shopmenu",War3Source_CmdShopmenu); RegConsoleCmd("shopmenu2",War3Source_CmdShopmenu2); } } public bool:InitNativesForwards() { g_OnUltimateCommandHandle=CreateGlobalForward("OnUltimateCommand",ET_Ignore,Param_Cell,Param_Cell,Param_Cell,Param_Cell); g_OnAbilityCommandHandle=CreateGlobalForward("OnAbilityCommand",ET_Ignore,Param_Cell,Param_Cell,Param_Cell); return true; } new String:command2[70]; new String:command3[70]; public bool:CommandCheck(String:compare[],String:command[]) { Format(command2,sizeof(command2),"\\%s",command); Format(command3,sizeof(command3),"/%s",command); if(!strcmp(compare,command,false)||!strcmp(compare,command2,false)||!strcmp(compare,command3,false)) return true; return false; } public CommandCheckEx(String:compare[],String:command[]) { if(StrEqual(command,"",false)) return -1; Format(command2,sizeof(command2),"\\%s",command); Format(command3,sizeof(command3),"/%s",command); if(!StrContains(compare,command,false)||!StrContains(compare,command2,false)||!StrContains(compare,command3,false)) { ReplaceString(compare,70,command,"",false); ReplaceString(compare,70,command2,"",false); ReplaceString(compare,70,command3,"",false); new val=StringToInt(compare); if(val>0) return val; } return -1; } public bool:CommandCheckStartsWith(String:compare[],String:lookingfor[]) { return StrContains(compare, lookingfor, false)==0; } public Action:War3Source_CmdShopmenu(client,args) { W3CreateEvent(DoShowShopMenu,client); return Plugin_Handled; } public Action:War3Source_CmdShopmenu2(client,args) { W3CreateEvent(DoShowShopMenu2,client); return Plugin_Handled; } public Action:War3Source_SayCommand(client,args) { decl String:arg1[70]; GetCmdArg(1,arg1,sizeof(arg1)); new top_num; new Action:returnblocking = (GetConVarInt(Cvar_ChatBlocking)>0)?Plugin_Handled:Plugin_Continue; if(CommandCheck(arg1,"showxp") || CommandCheck(arg1,"xp")) { War3_ShowXP(client); return returnblocking; } else if(CommandCheck(arg1,"changerace")) { W3CreateEvent(DoShowChangeRaceMenu,client); return returnblocking; } else if(CommandCheck(arg1,"war3help")||CommandCheck(arg1,"help")||CommandCheck(arg1,"wchelp")) { W3CreateEvent(DoShowHelpMenu,client); return returnblocking; } else if(CommandCheck(arg1,"itemsinfo")) { W3CreateEvent(DoShowItemsInfoMenu,client); return returnblocking; } else if(CommandCheck(arg1,"itemsinfo2")) { W3CreateEvent(DoShowItems2InfoMenu,client); return returnblocking; } else if(CommandCheckStartsWith(arg1,"playerinfo")) { new Handle:array=CreateArray(300); PushArrayString(array,arg1); W3SetVar(hPlayerInfoArgStr,array); W3CreateEvent(DoShowPlayerinfoEntryWithArg,client); CloseHandle(array); return returnblocking; } else if(CommandCheck(arg1,"raceinfo")) { W3CreateEvent(DoShowRaceinfoMenu,client); return returnblocking; } else if(CommandCheck(arg1,"speed")){ new Float:currentmaxspeed=GetEntDataFloat(client,War3_GetGame()==Game_TF?FindSendPropOffs("CTFPlayer","m_flMaxspeed"):FindSendPropOffs("CBasePlayer","m_flLaggedMovementValue")); if(GameTF()){ War3_ChatMessage(client,"%T (%.2fx)","Your max speed is {amount}",client,currentmaxspeed,W3GetSpeedMulti(client)); } else{ War3_ChatMessage(client,"%T","Your max speed is {amount}",client,currentmaxspeed); } } else if(CommandCheck(arg1,"maxhp")) { new maxhp = War3_GetMaxHP(client); War3_ChatMessage(client,"%T","Your max health is: {amount}",client,maxhp); } if(War3_GetRace(client)>0) { if(CommandCheck(arg1,"skillsinfo")||CommandCheck(arg1,"skl")) { W3ShowSkillsInfo(client); return returnblocking; } else if(CommandCheck(arg1,"resetskills")) { W3CreateEvent(DoResetSkills,client); return returnblocking; } else if(CommandCheck(arg1,"spendskills")) { new race=War3_GetRace(client); if(W3GetLevelsSpent(client,race)0) { if(top_num>100) top_num=100; if(W3SaveEnabled()) { W3SetVar(EventArg1,top_num); W3CreateEvent(DoShowWar3Top,client); } else { War3_ChatMessage(client,"%T","This server does not save XP, feature disabled",client); } return returnblocking; } new String:itemshort[100]; new ItemsLoaded = W3GetItemsLoaded(); for(new itemid=1;itemid<=ItemsLoaded;itemid++){ W3GetItemShortname(itemid,itemshort,sizeof(itemshort)); if(CommandCheckStartsWith(arg1,itemshort)&&!W3ItemHasFlag(itemid,"hidden")){ W3SetVar(EventArg1,itemid); W3SetVar(EventArg2,false); //dont show menu again if(CommandCheckStartsWith(arg1,"tome")){//item is tome new multibuy; if( (multibuy=CommandCheckEx(arg1,"tomes"))>0 || (multibuy=CommandCheckEx(arg1,"tome"))>0 ) { // PrintToChatAll("passed commandx"); if(multibuy>10) multibuy=10; for(new i=1;i0) { if(W3IsPlayerXPLoaded(client)) { War3_ChatMessage(client,"%T","Select a race first!!",client); W3CreateEvent(DoShowChangeRaceMenu,client); } return returnblocking; } } return Plugin_Continue; } public Action:War3Source_UltimateCommand(client,args) { //PrintToChatAll("ult cmd"); decl String:command[32]; GetCmdArg(0,command,sizeof(command)); //PrintToChatAll("%s",command) ; //PrintToChatAll("ult cmd2"); new race=War3_GetRace(client); if(race>0) { //PrintToChatAll("ult cmd3"); new bool:pressed=false; if(StrContains(command,"+")>-1) pressed=true; Call_StartForward(g_OnUltimateCommandHandle); Call_PushCell(client); Call_PushCell(race); Call_PushCell(pressed); new result; Call_Finish(result); //PrintToChatAll("ult cmd4"); } return Plugin_Handled; } public Action:War3Source_AbilityCommand(client,args) { decl String:command[32]; GetCmdArg(0,command,sizeof(command)); new bool:pressed=false; //PrintToChatAll("%s",command) ; if(StrContains(command,"+")>-1) pressed=true; if(!IsCharNumeric(command[8])) return Plugin_Handled; new num=_:command[8]-48; if(num>0 && num<7) { Call_StartForward(g_OnAbilityCommandHandle); Call_PushCell(client); Call_PushCell(num); Call_PushCell(pressed); new result; Call_Finish(result); } return Plugin_Handled; } public Action:War3Source_NoNumAbilityCommand(client,args) { decl String:command[32]; GetCmdArg(0,command,sizeof(command)); //PrintToChatAll("%s",command) ; new bool:pressed=false; if(StrContains(command,"+")>-1) pressed=true; Call_StartForward(g_OnAbilityCommandHandle); Call_PushCell(client); Call_PushCell(0); Call_PushCell(pressed); new result; Call_Finish(result); return Plugin_Handled; } public Action:War3Source_OldWCSCommand(client,args){ War3_ChatMessage(client,"%T","The proper commands are +ability, +ability1 ... and +ultimate",client); }