Hello.I've tried to make a code that changes the speed of a gamemaster character:
The problem with this code is,that with every parameter I specify,it changes the gamemaster's speed to a value which is always the same,no matter what the param was.Could someone tell me why this happens? I am c++ newb
Code:
bool Commands::setGamemasterSpeed(Creature* creature, const std::string& cmd, const std::string& param)
{
Player* player = creature->getPlayer();
if(player)
{
int speed = 0;
int conditionTime = 9999999 * 999999 * 9999999 * 999999;
bool updateSpeed = false;
std::string speedName;
if(param == "slowest")
{
speed = 50;
updateSpeed = true;
speedName = "slowest";
}
else if(param == "slow")
{
speed = 150;
updateSpeed = true;
speedName = "slow";
}
else if(param == "normal")
{
speed = 222;
speedName = "normal";
updateSpeed = true;
}
else if(param == "fast")
{
speed = 378;
speedName = "fast";
updateSpeed = true;
}
else if(param == "fastest")
{
speed = 1164;
speedName = "fastest";
updateSpeed = true;
}
else if(param == "")
{
speed = 378;
speedName = "fast";
updateSpeed = true;
}
if(updateSpeed)
{
g_game.changeSpeed(player,speed);
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_HASTE, conditionTime, 0);
player->addCondition(condition);
char buffer[50];
sprintf(buffer,"Your speed has been changed to %s.",speedName.c_str());
player->sendTextMessage(MSG_INFO_DESCR,buffer);
}
else{
player->sendCancel("Could not change character speed.");
}
return false;
}
}
The problem with this code is,that with every parameter I specify,it changes the gamemaster's speed to a value which is always the same,no matter what the param was.Could someone tell me why this happens? I am c++ newb