[INC] Zezombia's Simple Communication Bot Sync System
#1

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.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)