08.09.2014, 08:27
hello guys today i was making cmds when i made /setspeedboost cmd my pawno crashed now whenever i try to compile my script and crahsed this is the code
i just converted this cmd
to
what mistake did i just did
i just converted this cmd
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
// Create variables
new cmd[256];
new idx;
// Get the command
cmd = strtok(cmdtext, idx);
// Check command typed
if (strcmp(cmd, "/setspeedboost", true) == 0 || strcmp(cmd, "/ssb", true) == 0)
{
// Create string variables
new strBoostMultiplier[256];
new strTempString[256];
// Get the vaue typed
strBoostMultiplier = strtok(cmdtext, idx);
// Check a boost factor was supplied
if (!strlen(strBoostMultiplier))
{
// Send message and exit here
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "** Usage: /setspeedboost <SpeedBoostMultiplier>");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Allows you to set the speed boost multiplier that is applied when you press the horn key.");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Accepted speed boost multiplier values are between 1.0 and 3.0");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* The shortcut for this command is: /ssb");
format(strTempString,sizeof(strTempString), "* Your current speed boost multiplier is: %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);
return 1;
}
// Check the boost factor supplied is numeric
if (!IsNumeric2(strBoostMultiplier))
{
// Send message and exit here
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "** Usage: /setspeedboost <BoostMultiplier>");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Allows you to set the speed boost multiplier that is applied when you press the horn key.");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Accepted speed boost multiplier values are between 1.0 and 3.0");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* The shortcut for this command is: /ssb");
format(strTempString,sizeof(strTempString), "* Your current speed boost multiplier is: %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);
return 1;
}
// Convert to float
new Float:BoostMultiplier = floatstr(strBoostMultiplier);
// Check speed boost multiplier is not too high or low
if (BoostMultiplier < 1.0 || BoostMultiplier > 3.0)
{
// Send message and exit here
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, you must enter a speed boost multiplier between 1.0 and 3.0");
return 1;
}
// Store the new speed boost multiplier value for the player
SpeedBoostMultiplier[playerid] = BoostMultiplier;
// Format and send message
format(strTempString,sizeof(strTempString), "* You set your speed boost multiplier to %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);
// Exit here
return 1;
}
// Exit here and return 0 (the command was not processed here)
return 0;
}
pawn Код:
CMD:setspeedboost(playerid, params);
{
new strTempString[256], strBoostMultiplier[256];
// if(sscanf(params,"f",SpeedBoostMultiplier)) return SendClientMessage(playerid,CMY,"[USAGE]: /setspeedboost <boostLevel>"); SendClientMessage(playerid,CMY,"This is speed boost command that sets your speed boost level and it can be only set it to 1.0"); SendClientMessage(playerid,CMY,"like this /setspeedboost 1.2! simply it sets your speed boost to 1.2 and you can use this speed boost"); SendClientMessage(playerid,CMY,"with the button CTRL")
// Check a boost factor was supplied
if (sscanf(params,"f",strBoostMultiplier))
{
// Send message and exit here
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "** Usage: /setspeedboost <SpeedBoostMultiplier>");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Allows you to set the speed boost multiplier that is applied when you press the horn key.");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Accepted speed boost multiplier values are between 1.0 and 3.0");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* The shortcut for this command is: /ssb");
format(strTempString,sizeof(strTempString), "* Your current speed boost multiplier is: %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);
return 1;
}
new Float:BoostMultiplier = floatstr(strBoostMultiplier);
if (BoostMultiplier < 1.0 || BoostMultiplier > 3.0)
{
SendClientMessage(playerid, CMY, "*** Error: You can just change it for 0.1 to 3.0");
return 1;
}
SpeedBoostMultiplier[playerid] = BoostMultiplier;
format(strTempString,sizeof(strTempString), "*** You set your speed boost multiplier to %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, CMY, strTempString);
return 1;
}