Errors with /buyGrenades (Giving Credits!)
#2

The commando is:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256];
	new idx;

	cmd = strtok(cmdtext, idx);
  if (strcmp(cmd, "/BuyGrenades", true) == 0)
	{
	new
	tmp[20],
	amount;
	
	if (strlen(tmp))
	{
	amount = strval(tmp);
	if (IsPlayerConnected(amount))
	{
   GivePlayerWeapon(playerid,16,342);
	 GivePlayerMoney(playerid,- 1000);
	}
	else
	{
	SendClientMessage(playerid, 0xFF0000AA, "You Don't Have enough Money!");
	}
	}
	else
	{
	SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/buygrenades <amount>\"");
	}
	return 1;
	}
	return 0;
}
And it adds at the end of gamemode or filterscript:
Код:
strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}
Reply


Messages In This Thread
Errors with /buyGrenades (Giving Credits!) - by Sal_Kings - 07.08.2009, 21:37
Re: Errors with /buyGrenades (Giving Credits!) - by kingworldsoft - 07.08.2009, 22:18

Forum Jump:


Users browsing this thread: 1 Guest(s)