Hello system(need real help)
#1

I have cmds like:
Код:
if (strcmp("/hello", cmdtext, true, 10) == 0)
{
	new pName[MAX_PLAYER_NAME];
  new string[48];
  GetPlayerName(playerid, pName, sizeof(pName));
  format(string, sizeof(string), "%s Said hi to all", pName);
  SendClientMessageToAll(0x3CFF00AA, string);
	return 1;
  }
if (strcmp("/bb", cmdtext, true, 10) == 0)
 {
	new pName[MAX_PLAYER_NAME];
	new string[48];
	GetPlayerName(playerid, pName, sizeof(pName));
	format(string, sizeof(string), "%s said bye", pName);
	SendClientMessageToAll(0x3CFF00AA, string);
	return 1;
  }
But if you can help me? show how to make his command to hello or to say bye to certain player
like: /hello(/bb)[playerid]
Reply
#2

https://sampwiki.blast.hk/wiki/Strtok
Reply
#3

the idx-for player id?
Reply
#4

Im not sure this will work, you should have the stock strtok sumwhere unless ur a noob :P
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[128], idx;
  cmd = strtok(cmdtext, idx);

  if(strcmp("/hello", cmd, true)==0)
  {
    new tmp[128]; tmp = strtok(cmdtext, idx);
    if(strlen(tmp))//If the player used params
    {
    new pName[MAX_PLAYER_NAME], iName[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(strval(tmp), iName, sizeof(iName));
    format(string, sizeof(string), "%s says hello to %s!", pName, iName);
    SendClientMessageToAll(color, string);//Change color
    }
    else if(!strlen(tmp))//If the player didnt use params
    {
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "%s says hello to all!", pName);
    SendClientMessageToAll(color, string);//Change color
    }
    return 1;
  }
  return 0;
}
Reply
#5

Tnx
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)