[HELP] Scripting
#1

Could u please tell me this (read please)
Player(mannu) do the command /hi <id>.
and then it send Message to player "mannu said hi to you"
Now here's the prob
How would i print the mesage to praticular id
like how do print the name of player doing command and how do i send it to that particlur id please tell
Reply
#2

You need ReturnUser and strtok.
Reply
#3

pawn Код:
if(strcmp(cmd, "/hi", true) == 0)
        {
          new tmp[256], string[256], str[256], PlayerName[24], OtherPlayerName[24];
          tmp = strtok(cmdtext, idx);
          new OtherPlayer = strval(tmp);
          GetPlayerName( OtherPlayer, OtherPlayerName, 24 );
          GetPlayerName( playerid, PlayerName, 24 );
          if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /hi <playerid>");
          if(!IsPlayerConnected(OtherPlayer)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Playerid.");
          if(OtherPlayer == playerid) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You cannot say hi to yourself!");
            format(string, sizeof(string), "You have said hi to %s.", OtherPlayerName);
            format(str, sizeof(str), "%s said hi to you.", PlayerName);
          SendClientMessage(playerid, COLOR_GREEN, string);
          SendClientMessage(OtherPlayer, COLOR_GREEN, str);
            return 1;
        }
Reply
#4

Thanks both of you
but please tell me line to line usage i mean what each line if for and what it means
Reply
#5

help please
Reply
#6

Matthias, read this before posting any code. Also, this code isn't really "newbie" friendly.

Try writing this command by your own. This is how you should do it: Create a string with 128 as string size. Get the name of the player and put them together into a message. Use %s for a string and %d for a number(in case you want the playerid there also). Send them to all the players, and you have done one part.
Reply
#7

Код:
if (strcmp(cmd, "/hi",true) == 0)
	{
	if (IsPlayerConnected(giveplayerid))
   {
	    tmp = strtok(cmdtext, idx);
	    if (!strlen(tmp))
	    {
	      SendClientMessage(playerid,0xFFFFFFAA," USAGE: /hi [playerid]");
	      return 1;
		 }
			new giveplayerid = ReturnUser(tmp, playerid);
			tmp = strtok(cmdtext, idx);
			if (giveplayerid != INVALID_PLAYER_ID)
			{


			  	GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
			  	GetPlayerName(playerid, sendername, sizeof(sendername));
			  	format(string, sizeof(string), " * %s said hi to you!", giveplayername);
			  	SendClientMessage(giveplayerid, 0xFFFFFFAA, string);
				

				}
				else SendClientMessage(playerid,0xFFFFFFAA," * Player is not connected!");
			   return 1;
			   }
You need the ReturnUser function then and obviously strtok.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)