|
Title: Faster changerace Post by: M.A.C.A.B.R.A on June 26, 2012, 02:50:08 AM I think race changing takes too long. And it can probably easily be shortened. Correct me if I'm wrong.
Now you need to type "changerace" and select correct race from the list. It's not good solution if you have many races on server. How about adding simple functionality: changerace <race_name> ? I don't know where the hell is called command changing race in code (cant find it), but maybe it can be done just like that? You just need to find the race using the argument: Code: new String:racenamearg[64]; // does race name have max length? I put there 64 prophylactically GetCmdArg(1, racenamearg, sizeof(racenamearg)); // copying argument to our string new RacesCounter = 0; // counter of races, which have substring (our argument) in name new RaceIndex = -1; // race index for(new i = 1; i <= War3_GetRacesLoaded(); i++) // finding valid race { new String:racenametmp[64]; // races names War3_GetRaceName(i,racenametmp,sizeof(racenametmp)); if(StrContains(racenametmp, racenamearg, false) != -1) // if substring from argument found in race name { RacesCounter++; RaceIndex = i; } if(RacesCounter > 1) // if substring from argument found in more than one race name { RaceIndex = -2; // error, break the loop break; } } // messages if(RaceIndex == -1) { // Race not found. return Plugin_Handled; } else if(RaceIndex == -2) { // More than one race found. Player need to type specific part of racename return Plugin_Handled; } War3_SetRace(client,RaceIndex); // race change If it is so simple, it probably would have been done long time ago, but it doesn't hurt to check. I don't know that can it be done like that, but this functionality would be helpful :) //Edit: Why is this topic sticked? :P |