11.06.2011, 10:36
Hello,
I was just wondering what could possibly be wrong with this command. The compiling goes great, since there isn't a single error, but in game I keep getting the ClientMessage "Please enter a valid amount of bullets!", no matter what number I enter. The rest of the values do work as they should.
I was just wondering what could possibly be wrong with this command. The compiling goes great, since there isn't a single error, but in game I keep getting the ClientMessage "Please enter a valid amount of bullets!", no matter what number I enter. The rest of the values do work as they should.
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx, tmp[256];
cmd = strtok(cmdtext, idx); // Nog iets om strtok te laten werken enzovoort.
if(strcmp(cmd, "/giveweapon", true)==0)
{
new otherplayerid, weaponid, amount;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
otherplayerid = strval(tmp);
if(!IsPlayerConnected(otherplayerid))
{
SendClientMessage(playerid, COLOR_ORANGE, "The player took off without a piece!");
return 1;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
weaponid = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
if(weaponid < 1 && weaponid > 46)
{
SendClientMessage(playerid, COLOR_ORANGE, "Use a weaponid between 1 and 46!");
return 1;
}
amount = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
if(amount < 1)
{
SendClientMessage(playerid, COLOR_ORANGE, "Please enter a valid amount of bullets!");
return 1;
}
GivePlayerWeapon(otherplayerid, weaponid, amount);
SendClientMessage(otherplayerid, COLOR_ORANGE, "You've been given a weapon!");
SendClientMessage(playerid, COLOR_ORANGE, "You've successfully given a weapon to the player!");
return 1;
}

