[HELP] How to make the basic RP talks (ooc, ic, shout etc..)
#1

Can anyone help me setup the basic RP chats?
I need the following help:

--when you type in the chat box it sends it to Everyone, i need it so it sends it to people around you.
--when you type "/o" it sends it to everyone in the game
--when you type "/s" it allows your char to shout to the people around you.
--when you type "/w" it allows your char to whisper to the people around you

If anyone can help me out from the examples above, It would be greatly appreciated.
Reply
#2

Here is shout from wiki:

pawn Код:
if(strcmp(cmdtext,"/shout",true)==0)
{
   new tmp[256];//The variable for strtok.
   new string[256];// A Variable where we store a text/number with information.
   new pName[MAX_PLAYER_NAME];//You can use this variable to get the players name later on.
   new idx;//Also known as Index,Part of strtok.
   tmp = strtok(cmdtext,idx);//This Is where we define tmp to equal strtok.
   if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"USAGE:/me[action]");
   //this will see if the playerid filled all parameters,if not send him a message showing him how.
   //now continue with the command.
   if(IsPlayerConnected(playerid))//just a simple check to make it run smoother.
   {
      GetPlayerName(playerid,pName,sizeof(pName));//This Stores the playerid's name in a variable.
      format(string,sizeof(string),"%s Shouts: %s !!",pName,cmdtext[7]);
      /* In the format up,We used the stored text in the pName variable to show the player's name.
      cmdtext[7] means how many letters of the command we cut off to get the text of what he said.*/

      //and continue the command.
      SendClientMessageToAll(COLOR_WHITE,string)//now we send the formatted string.
   }// close the Connected Check.
   return 1;//make sure it returns something.
}//and close the ending bracket  
 
/* Written by iMatt */
Reply
#3

pawn Код:
if (strcmp(cmdtext, "/o ", true, 3)==0){
  new msg[128];
  GetPlayerName(playerid, msg, 128);
  format(msg, 128, "(( %s: %s ))", msg,cmdtext[3]);
  SendClientMessageToAll(color, msg);
  return 1;
}
The same with the others.
I don't know RPs, but I think they use a loop, and if target player is in range of the player, they send the message.
IsPlayerInRangeOfPoint
for()
GetPlayerPos

For the chatbox: if OnPlayerText returns 0, the message is not sent. And you can check with IsPlayerInRangeOfPoint, if the message can be sent for the player or not.
Reply
#4

Thanks a bunch for the above. But does it require to add in the script "dcmd_o" or "dcmd_shout"??
That's how my commands are in the GM...
Reply
#5

I don't know how dcmd works, this example has to be put into OnPlayerCommandText(), and it will work.
(http://pastebin.com/fdq8nC47)
Reply
#6

Quote:
Originally Posted by [HUN]Jaki
Посмотреть сообщение
I don't know how dcmd works, this example has to be put into OnPlayerCommandText(), and it will work.
(http://pastebin.com/fdq8nC47)
Alright, and for:

Quote:

For the chatbox: if OnPlayerText returns 0, the message is not sent. And you can check with IsPlayerInRangeOfPoint, if the message can be sent for the player or not.

What would the script be to add "IsPlayerInRangeOfPoint" ?
Reply
#7

A for loop, which checks every player, if it is in the range of the point. (In this case, the point is the position of the player who sends the message.)

for (i=0; while i<MAX_PLAYERS){
if (IsPlayerInRangeOfPoint(i)) SendTheMessage();
}
Reply
#8

Click me for tutorial
Reply
#9

the link the sa-mp wiki won't help much if he was already there and didn't find anything...
Reply
#10

But we already said all functions, that you need to solve this. If he want us to make this, that he copy&paste it, then go to script request.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)