SA-MP Forums Archive
[INC] Zezombia's Simple Communication Bot Sync System - 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: [INC] Zezombia's Simple Communication Bot Sync System (/showthread.php?tid=95500)



[INC] Zezombia's Simple Communication Bot Sync System - Zezombia - 03.09.2009

A very simple system that uses 2 text files to transfer variables.

_________________________________________________

[size=20px]1. Setting up the include[/size]

[size=15px]filterscripts[/size]
Add
pawn Код:
#include <npc_s>
under <a_samp>.

[size=15px]npcmodes[/size]
Add
pawn Код:
#include <npc_s>
under <a_npc>.

Add
pawn Код:
Set_OnNPCModeInit();
in the OnNPCModeInit() callback.

_________________________________________________

[size=20px]2. Creating the timer[/size]

[size=15px]npcmodes[/size]
Make a forward for the public
pawn Код:
forward UpdateBot();
Make a simple check to see if there is a command sent
pawn Код:
public UpdateBot()
{
    if(IsNPCCommandSet() == 0) return 1;

    //we will make our command system in this space

    ClearNPCCommand();
    return 1;
}
If there is a command sent, reset the command to not sent (this will make sense later).

Add
pawn Код:
SetTimer("UpdateBot", 500, 1);
in the OnNPCModeInit() callback.

_________________________________________________

[size=20px]3. Making a simple command[/size]

[size=15px]filterscripts[/size]
Send a command with this function
pawn Код:
SendNPCCommand("hello");
[size=15px]npcmodes[/size]
Remember when I said we would be adding commands "in this space"? That's where this will go
pawn Код:
#define cmdtext GetNPCCommand() // this is not necessary

if(strcmp(cmdtext, "hello", true) == 0) // just like you remember it ;)
{
    SendMessage("Hello world!");
}
_________________________________________________

[size=20px]4. Making a command And sending a variable[/size]

[size=15px]filterscripts[/size]
pawn Код:
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));

SendNPCCommand("hello");
SendVariableString(pname);
[size=15px]npcmodes[/size]

pawn Код:
#define cmdtext GetNPCCommand()
#define pname GetVariableString()

if(strcmp(cmdtext, "hello", true) == 0)
{
    new string[128];
    format(string, sizeof(string), "%s told me to say hello!", pname);
    SendMessage(string);
}
_________________________________________________

I'm not very good at scriptfiles, so I'm only able to make it send 1 variable at a time. If you can make it send multi-variables, by all means do it (I place no copyright protection on this script).

You will be able to see all the functions in this script on your pawno sidebar >>>.

[size=15px]Download[/size]
mpc_s.inc

_________________________________________________

Old post: http://pastebin.com/f62797428.


Re: My (simple) way of communicating with your bots. - Google63 - 03.09.2009

Good job !


Re: My (simple) way of communicating with your bots. - Jese - 03.09.2009

This looks cool zezy!


Re: My (simple) way of communicating with your bots. - Zeex - 03.09.2009

There is already more simplier way of doing that...


Re: My (simple) way of communicating with your bots. - Zezombia - 03.09.2009

No ZeeX, http://y-less.pastebin.ca/1551737 and http://y-less.pastebin.ca/1551739 is not simpler then writting to a text file.


Re: My (simple) way of communicating with your bots. - Zeromanster - 03.09.2009

Is this timer going to create a lot of lagg ?


Re: [INC] Zezombia's Simple Communication Bot Sync System - Zezombia - 04.09.2009

Most of you arn't getting it. Updated to a inc.


Re: [INC] Zezombia's Simple Communication Bot Sync System - brett7 - 04.09.2009

nice work


Re: [INC] Zezombia's Simple Communication Bot Sync System - Whiteagle - 04.09.2009

Nice Zezombia

But i would opt by sendding a special message to the bot like:

Global secret key defines on the gamemode and NPC codes:
Код:
new secretcode[] = "!:S3cr3tC0d4:!";
Message from the gamemode
Код:
new MessageToSend[128];
format(MessageToSend, sizeof(MessageToSend), "%s This is a sample message", secretcode);
SendClientMessage(TheBotId,COLOR,MessageToSend);
And on the NPC:
Код:
public OnClientMessage(color, text[])
{
  if(strfind(text, secretcode) != -1)
  {
    new Message[sizeof(text)];
    new CurrentChange;
    new start = sizeof(secretcode)+1
    for(new i = start; i <= sizeof(text); i++)
    {
        CurrentChange = i - sizeof(secretcode);
        Message[CurrentChange] = text[i];
    }
    SendChat(Message);
  }
It's more effective, to me

I'll release this quickly


Re: [INC] Zezombia's Simple Communication Bot Sync System - Zezombia - 04.09.2009

Hum your right, I'm an idiot. Rofl.