SA-MP Forums Archive
How can I do this? - 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: How can I do this? (/showthread.php?tid=139240)



How can I do this? - Jeffry - 04.04.2010

Hello guys,

I saw on a server that a "bot" sends randomly messages, but not with SendClientMessage.
The bot just wrote it into Mainchat, and it had a name.

I tried:
pawn Код:
SendPlayerMessage("Bot", "Hi");
but this didnt work....gave me error.

pawn Код:
SendPlayerMessage(playerid, "Hi");
works only for a player.

How can I define the playerid to a bot-name, means a name that I coose.

Can anyone help me?

PS: if you don't understand what I mean, please tell.


I would be happy about a solution.

Jeffry



Re: How can I do this? - Torran - 04.04.2010

Use SendChat..
Ive seen it in the bar on my pawno

Im guessing it works like SendCommand,
But makes the bot talk


Re: How can I do this? - ScottCFR - 04.04.2010

I have mine set up to SendClientMessageToAll(COLOR, "Bot: Hey");




Re: How can I do this? - Jeffry - 04.04.2010

Quote:
Originally Posted by ScottCFR
I have mine set up to SendClientMessageToAll(COLOR, "Bot: Hey");
Thats what i have too. But I want my Bot answering to people.
@ Joe: Oke, I will have a look on this later. im on laptop without pawn.

SendChatMessage belongs to this: http://forum.sa-mp.com/index.php?topic=49741.0 Wont work.


Re: How can I do this? - Jeffry - 05.04.2010

Bump!
Does anyone knows this?


Re: [UNSOLVED]How can I do this? - Babul - 05.04.2010

the trick is to script it in the NPC filterscript, have a look
Код:
#define RECORDING "PirateShip" //This is the filename of your recording without the extension.
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.
#include <a_npc>
new CyclesMin=20;
new CyclesMax=30;
new CyclesATM=0;
forward TimerPirateShip();
public OnRecordingPlaybackEnd()
	StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#if RECORDING_TYPE == 1
  public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
  public OnNPCExitVehicle() StopRecordingPlayback();
#else
  public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#endif
main()
{
  printf("PirateShip");
}
public OnNPCModeInit()
{
	SetTimer("TimerPirateShip",2000,1);
}
public TimerPirateShip()
{
	CyclesATM++;
	if(CyclesATM>CyclesMin)
	{
		if(CyclesATM>CyclesMax || random(10)<2)
		{
			new Amount=100000;
			new NPCcmd[32];
			format(NPCcmd,sizeof(NPCcmd),"/dt %d",Amount);
			SendCommand(NPCcmd);
			new msg[128];
			format(msg,128,"/Aq I lost a Treasure, it is worth $%d! Can someone bring it back?",Amount);
			SendCommand(msg);
			format(msg,128,"I lost a Treasure, it is worth $%d! Can someone bring it back?",Amount);
			SendChat(msg);
			CyclesATM=0;
		}
	}
}
of course i am too lazy to modify it to send random messages >-<


Re: [UNSOLVED]How can I do this? - Jeffry - 05.04.2010

Ahh, looks nice.
Only problem: Im having 0.2X server.

So will this only work with 0.3?


Re: [UNSOLVED]How can I do this? - Babul - 05.04.2010

umm.. idk, 2 weeks after i started scripting, the 0.3 update got released ^^
i dont see any reason why it shouldnt run at 0.2x


Re: [UNSOLVED]How can I do this? - Jeffry - 05.04.2010

0.2X hosted list.


Re: [UNSOLVED]How can I do this? - Desert - 05.04.2010

It wont work in 0.2 as bots only exist in 0.3. But you can just save a random message and then send as SendClientMessage

Example from 1 of my scripts
pawn Код:
new PoliceLetter[6][150] = {
{"Hello Kim. As you might have heard there is about to be going a big gang war soon. I don't know when or where. But you need to get some cops ready"},
{"Hey Kim. I just wrote this letter to say hi and hear hows it going out there? My phone is broke lately so i can't call you. Jack"},
{"Bad news. My best cop just got killed by the Mackoli's. Hope you can bring me some new soon. Jack"},
{"Great news Kim! I just got a mole inside the Bonelli family! With this mole we can get alot of information. Hope you feel well. Jack"},
{"Hello Kim. Have you heard? Some chineese triad just came to the city! Like we don't have enough shit to deal with... Jack"},
{"You have surely heard about The Pimp. He has recruited alot of men lately. Too many to just be protecting hes girls. Somethings wrong"}
};

dcmd_readletter(playerid,params[])
{
    #pragma unused params
    if(DeliverPoliceLetter[playerid] == 0) return 0;
    else
    {
      new rand = random(sizeof(PoliceLetter));
      SendClientMessage(playerid,COLOUR_GREEN,"You check if noone is looking and opens the letter");
      SendClientMessage(playerid,COLOUR_YELLOW,PoliceLetter[rand]);
      }
    return 1;
}
I have a police job where you deliver a letter to a person named "kim". Made this command for fun. It sends a random message when /readletter. Hope it helps