Giveweapon command
#1

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;
	}
Reply
#2

Amount isn't defined at all now...
Reply
#3

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;
      }
Reply
#4

^. Ok, but what should happen to this rule? Because Pawno crashes at compiling now:
Код:
GivePlayerWeapon(otherplayerid, weaponid, amount);
Reply
#5

remove GivePlayerWeapon(otherplayerid, weaponid, amount);
Reply
#6

Then the player gets no weapon? O.o
Reply
#7

try I think player get weapon
Reply
#8

The compiler crashes when I try to compile it.
Reply
#9

Код:
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;
      }
Reply
#10

Right now it keeps crashing, no matter which code I use for it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)