Giveweapon command -
KvdV_96 - 11.06.2011
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.
Код:
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;
}
Re: Giveweapon command -
KvdV_96 - 11.06.2011
Amount isn't defined at all now...
Re: Giveweapon command -
Skaizo - 11.06.2011
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx, tmp[256];
cmd = strtok(cmdtext, idx);
}
if(strcmp(cmd, "/giveweapon", true)==0)
{
new otherplayerid, weaponid;
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;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
if(strlen(tmp)< 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;
}
Re: Giveweapon command -
KvdV_96 - 11.06.2011
^. Ok, but what should happen to this rule? Because Pawno crashes at compiling now:
Код:
GivePlayerWeapon(otherplayerid, weaponid, amount);
Re: Giveweapon command -
Skaizo - 11.06.2011
remove GivePlayerWeapon(otherplayerid, weaponid, amount);
Re: Giveweapon command -
KvdV_96 - 11.06.2011
Then the player gets no weapon? O.o
Re: Giveweapon command -
Skaizo - 11.06.2011
try I think player get weapon
Re: Giveweapon command -
KvdV_96 - 11.06.2011
The compiler crashes when I try to compile it.
Re: Giveweapon command -
Skaizo - 11.06.2011
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx, tmp[256];
cmd = strtok(cmdtext, idx);
}
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;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
if(strlen(tmp)< 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;
}
Re: Giveweapon command -
KvdV_96 - 11.06.2011
Right now it keeps crashing, no matter which code I use for it.