#include #include "W3SIncs/War3Source_Interface" public Plugin:myinfo= { name="SH chooserace", author="Ownz", description="War3Source Core Plugins", version="1.0", url="http://war3source.com/" }; public SHONLY(){} //new WantsRace[MAXPLAYERSCUSTOM]; public OnPluginStart() { } public bool:InitNativesForwards(){ CreateNative("SHTryToGiveClientHero",NSHTryToGiveClientHero); return true; } public NSHTryToGiveClientHero(Handle:plugin,numParams){ new client=GetNativeCell(1); new race_selected=GetNativeCell(2); new bool:allowshowchangeraceagain=bool:GetNativeCell(3); new maxheroes=SHGetHeroesClientCanHave(client); new String:heroname[32]; SHGetHeroName(race_selected,heroname,sizeof(heroname)); new bool:allowselect=true; if(allowselect&&SHHasHeroesNum(client)>=maxheroes){ War3_ChatMessage(client,"You can only have %d heroes",maxheroes); allowselect=false; } else if(SHHasHero(client,race_selected)){ War3_ChatMessage(client,"You already have %s",heroname); allowselect=false; } else if(W3GetRaceMinLevelRequired(race_selected)>SHGetLevel(client)){ War3_ChatMessage(client,"This Hero requires level %d",W3GetRaceMinLevelRequired(race_selected)); allowselect=false; } if(allowselect&&SHGetHeroHasPowerBind(race_selected)){ new bool:foundempty=false; for(new i=0;i<3;i++){ if(SHGetPowerBind(client,i)==0){ SHSetPowerBind(client,i,race_selected); foundempty=true; War3_ChatMessage(client,"%s has power bind, bounded to +power%d ",heroname,i+1); break; } } if(foundempty==false){ War3_ChatMessage(client,"You can only have max 3 heroes that have power binds"); allowselect=false; } } if(allowselect){ SHSetHasHero(client,race_selected,true); } if(allowshowchangeraceagain&&SHHasHeroesNum(client)":"",rname); new minlevel=W3GetRaceMinLevelRequired(raceid); if(minlevel<0) minlevel=0; if(minlevel) { Format(rdisp,sizeof(rdisp),"%s %T",rdisp,"reqlvl {amount}",GetTrans(),minlevel); } AddMenuItem(crMenu,rbuf,rdisp); } SetMenuTitle(crMenu,"%s\n \n",title); DisplayMenu(crMenu,client,MENU_TIME_FOREVER); } public War3Source_CRMenu_Selected(Handle:menu,MenuAction:action,client,selection) { if(action==MenuAction_Select) { if(ValidPlayer(client)) { decl String:SelectionInfo[4]; decl String:SelectionDispText[256]; new SelectionStyle; GetMenuItem(menu,selection,SelectionInfo,sizeof(SelectionInfo),SelectionStyle, SelectionDispText,sizeof(SelectionDispText)); new race_selected=StringToInt(SelectionInfo); //PrintToChat(client,"selected %d",race_selected); SHTryToGiveClientHero(client,race_selected,true); } } if(action==MenuAction_End) { CloseHandle(menu); } } InternalClearPowers(client){ //if(IsPlayerAlive(client)){ for(new i=1;i<=War3_GetRacesLoaded();i++){ SHSetHasHero(client,i,false); } for(new i=0;i<3;i++){ SHSetPowerBind(client,i,0); } InternalSHChangeRaceMenu(client); //} } InternalShowMyHeroes(client){ if(SHHasHeroesNum(client)==0){ War3_ChatMessage(client,"You do not have any heroes"); InternalSHChangeRaceMenu(client); } else{ //PrintToChatAll("3"); new Handle:hMenu=CreateMenu(InternalShowMyHeroesSelected); SetMenuExitButton(hMenu,true); new String:title[400]; Format(title,400,"%s\n \n[SuperHero:Source] Your Heroes\nSelect the hero to remove",title) ; //AddMenuItem(hMenu,"0","0"); for(new heroid=1;heroid<=War3_GetRacesLoaded();heroid++){ if(SHHasHero(client,heroid)){ decl String:rbuf[5]; Format(rbuf,sizeof(rbuf),"%d",heroid); //DATA FOR MENU! decl String:rname[32]; SHGetHeroName(heroid,rname,sizeof(rname)); decl String:rdisp[100] Format(rdisp,sizeof(rdisp),">%s",rname); AddMenuItem(hMenu,rbuf,rdisp); } } //PrintToChatAll("4"); SetMenuTitle(hMenu,"%s\n \n",title); DisplayMenu(hMenu,client,MENU_TIME_FOREVER); //PrintToChatAll("5"); } } public InternalShowMyHeroesSelected(Handle:menu,MenuAction:action,client,selection) { if(action==MenuAction_Select) { if(ValidPlayer(client)) { decl String:SelectionInfo[4]; decl String:SelectionDispText[256]; new SelectionStyle; GetMenuItem(menu,selection,SelectionInfo,sizeof(SelectionInfo),SelectionStyle, SelectionDispText,sizeof(SelectionDispText)); new race_selected=StringToInt(SelectionInfo); SHSetHasHero(client,race_selected,false); if(SHGetHeroHasPowerBind(race_selected)){ for(new i=0;i<3;i++){ if(SHGetPowerBind(client,i)==race_selected){ SHSetPowerBind(client,i,0); } } for(new i=0;i<2;i++){ if(SHGetPowerBind(client,i)==0){ SHSetPowerBind(client,i,SHGetPowerBind(client,i+1)); SHSetPowerBind(client,i+1,0); } } } if(SHHasHeroesNum(client)>0){ InternalShowMyHeroes(client) } } } if(action==MenuAction_End) { CloseHandle(menu); } }