03.09.2009, 19:58
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
under <a_samp>.
[size=15px]npcmodes[/size]
Add
under <a_npc>.
Add
in the OnNPCModeInit() callback.
_________________________________________________
[size=20px]2. Creating the timer[/size]
[size=15px]npcmodes[/size]
Make a forward for the public
Make a simple check to see if there is a command sent
If there is a command sent, reset the command to not sent (this will make sense later).
Add
in the OnNPCModeInit() callback.
_________________________________________________
[size=20px]3. Making a simple command[/size]
[size=15px]filterscripts[/size]
Send a command with this function
[size=15px]npcmodes[/size]
Remember when I said we would be adding commands "in this space"? That's where this will go
_________________________________________________
[size=20px]4. Making a command And sending a variable[/size]
[size=15px]filterscripts[/size]
[size=15px]npcmodes[/size]
_________________________________________________
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.
_________________________________________________
[size=20px]1. Setting up the include[/size]
[size=15px]filterscripts[/size]
Add
pawn Код:
#include <npc_s>
[size=15px]npcmodes[/size]
Add
pawn Код:
#include <npc_s>
Add
pawn Код:
Set_OnNPCModeInit();
_________________________________________________
[size=20px]2. Creating the timer[/size]
[size=15px]npcmodes[/size]
Make a forward for the public
pawn Код:
forward UpdateBot();
pawn Код:
public UpdateBot()
{
if(IsNPCCommandSet() == 0) return 1;
//we will make our command system in this space
ClearNPCCommand();
return 1;
}
Add
pawn Код:
SetTimer("UpdateBot", 500, 1);
_________________________________________________
[size=20px]3. Making a simple command[/size]
[size=15px]filterscripts[/size]
Send a command with this function
pawn Код:
SendNPCCommand("hello");
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);
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.