id, gun id
#2

use strtok

Put it near the end of file

Код:
stock 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;
}
This at the start of OnPlayerCommandText

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[256];
  new tmp[256];
  new idx;
  cmd = strtok(cmdtext,idx);
	if(strcmp(cmd, "/pvp", true) == 0)
	{
	  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "");//If the playerid isn't admin (put the message)
	  tmp = strtok(cmdtext, idx);
	  if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USO: /givegun [playerid] [weapon].");
	  new playerid2;
	  playerid2 = strval(tmp);
	  new tmp2[256];
	  tmp2 = strtok(cmdtext, idx);
	  new weapid= strval(tmp2);
	  new string[256];
	  new name[MAX_PLAYER_NAME];
	  new name2[MAX_PLAYER_NAME];
	  new name3[MAX_PLAYER_NAME];
	  GetPlayerName(playerid,name,sizeof(name));
	  GetPlayerName(playerid2,name2,sizeof(name2));
	  GetWeaponName(armaid,name3,sizeof(name3));
	  format(string,sizeof(string),"Admin %s(%d) gave the weapon %s(%d) to player %s(%d).",name,playerid,name3,weapid,name2,playerid2);
	  print(string);//Print to server_log
	  format(string,sizeof(string),"Admin %s(%d) gave you the weapon %s(%d).",name,playerid,name3,weapid);
	  SendClientMessage(playerid2,COLOR_RED,string);
	  format(string,sizeof(string),"You gave %s(%d) the weapon %s(%d).",name2,playerid2,name3,weapid);
	  SendClientMessage(playerid,COLOR_RED,string);
	  GivePlayerWeapon(playerid2,weapid,50000);//Unlimited ammo.(if u dont want it change 50000).
	  return 1;
	}
}
Reply


Messages In This Thread
simple command, to dcmd, help - by jaksimaksi - 25.01.2011, 18:05
Re: id, gun id - by Sasino97 - 25.01.2011, 18:17
Re: id, gun id - by jaksimaksi - 25.01.2011, 19:14
Re: id, gun id - by Sasino97 - 25.01.2011, 19:35
Re: id, gun id - by jaksimaksi - 26.01.2011, 08:55

Forum Jump:


Users browsing this thread: 1 Guest(s)