SA-MP Forums Archive
Hello system(need real help) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Hello system(need real help) (/showthread.php?tid=131300)



Hello system(need real help) - Nexotronix - 02.03.2010

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]


Re: Hello system(need real help) - VonLeeuwen - 02.03.2010

https://sampwiki.blast.hk/wiki/Strtok


Re: Hello system(need real help) - Nexotronix - 02.03.2010

the idx-for player id?


Re: Hello system(need real help) - bajskorv123 - 02.03.2010

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;
}



Re: Hello system(need real help) - Nexotronix - 03.03.2010

Tnx