PDA

View Full Version : [Include] [INC] NPC-Bridge (GM to NPC Communication)


Whiteagle
04/09/2009, 04:45 AM
NNNNNNNN NNNNNNNNPPPPPPPPPPPPPPPPP CCCCCCCCCCCCC
N:::::::N N::::::NP::::::::::::::::P CCC::::::::::::C
N::::::::N N::::::NP::::::PPPPPP:::::P CC:::::::::::::::C
N:::::::::N N::::::NPP:::::P P:::::P C:::::CCCCCCCC::::C
N::::::::::N N::::::N P::::P P:::::P C:::::C CCCCCC
N:::::::::::N N::::::N P::::P P:::::PC:::::C
N:::::::N::::N N::::::N P::::PPPPPP:::::P C:::::C
N::::::N N::::N N::::::N P:::::::::::::PP C:::::C
N::::::N N::::N:::::::N P::::PPPPPPPPP C:::::C
N::::::N N:::::::::::N P::::P C:::::C
N::::::N N::::::::::N P::::P C:::::C
N::::::N N:::::::::N P::::P C:::::C CCCCCC
N::::::N N::::::::NPP::::::PP C:::::CCCCCCCC::::C
N::::::N N:::::::NP::::::::P CC:::::::::::::::C
N::::::N N::::::NP::::::::P CCC::::::::::::C
NNNNNNNN NNNNNNNPPPPPPPPPP CCCCCCCCCCCCC

88888888ba 88888888ba 88 88888888ba, ,ad8888ba, 88888888888
88 "8b 88 "8b 88 88 `"8b d8"' `"8b 88
88 ,8P 88 ,8P 88 88 `8b d8' 88
88aaaaaa8P' 88aaaaaa8P' 88 88 88 88 88aaaaa
88""""""8b, 88""""88' 88 88 88 88 88888 88"""""
88 `8b 88 `8b 88 88 8P Y8, 88 88
88 a8P 88 `8b 88 88 .a8P Y8a. .a88 88
88888888P" 88 `8b 88 88888888Y"' `"Y88888P" 88888888888

So this is my first public release of anything Pawno related.

This is a communication Bridge between any GameMode and NPC.

Installation

ON YOUR GAMEMODE:
After your includes:

#define SECRETCODE "!:S3cr3tC0d3:!" // Insert your secret code here, this allow communication to the NPC's, make it safe since it can be used in chat or anyone can control any bot!!!!, Consider it as a rcon password!
#define TOTALCHARS 14 // Total chars of the Secret word, sorry cant use sizeof :(
#include <npc_bridge> // Our include.


ON YOUR NPC:
After your includes:

#define SECRETCODE "!:S3cr3tC0d3:!" // Insert your secret code here, this allow communication to the NPC's, make it safe since it can be used in chat or anyone can control any bot!!!!, Consider it as a rcon password!
#define TOTALCHARS 14 // Total chars of the Secret word, sorry cant use sizeof :(
#include <npc_bridge> // Our include.


In the end of your script:


public OnClientMessage(color, text[])
{
ClientMessageBridge(text); // Call the function needed.
}



Usage:
Run a command trough your gamemod:
NPCMessage(<NPC ID>, "<SYNTAX>", "<COMMAND HERE>");

Examples & Current available commands:

NPCMessage(NPCIdHere, "This is a sample SendChat", "SendChat"); // SendChat("This is a sample SendChat")
NPCMessage(NPCIdHere, "/mycommand", "SendCommand"); // SendCommand("/mycommand")
NPCMessage(NPCIdHere, "2 square", "StartRecordingPlayback"); // StartRecordingPlayback(2,"square");
NPCMessage(NPCIdHere, "StopRecordingPlayback", "StopRecordingPlayback"); // StopRecordingPlayback();
NPCMessage(NPCIdHere, "PauseRecordingPlayback", "PauseRecordingPlayback"); // PauseRecordingPlayback();
NPCMessage(NPCIdHere, "ResumeRecordingPlayback", "ResumeRecordingPlayback"); // ResumeRecordingPlayback();


Commands & Syntax:

[COMMAND] - [SYNTAX]
SendChat - Message
SendCommand - /Command
StartRecordingPlayback - <Recording Type ID>[space]<Recording Name>
StopRecordingPlayback - None
PauseRecordingPlayback - None
ResumeRecordingPlayback - None


Thanks to:
> Kye & The SA:MP Dev team (Not only for the new great version but also for the nice examples that i was able to modify)
> Backwardsman97 for this (http://forum.sa-mp.com/index.php?topic=98861.msg629274#msg629274)
> Zezombia, because he release "made"/"inspired" me to release this :)

Download it Here (http://www.digital-games.org/NPC_Bridge011.zip)

PS: Please report any bugs!

Changelog:
0.1: Released
0.1.1: Removed some forgotten debug functions

Wanted1900
04/09/2009, 05:18 AM
Looks nice, but your download link is not working.

Whiteagle
04/09/2009, 05:28 AM
Looks nice, but your download link is not working.


Sorry about that,

There was an error during the upload, fixed :)

Wanted1900
04/09/2009, 05:36 AM
Looks nice, but your download link is not working.


Sorry about that,

There was an error during the upload, fixed :)


Thank you.

Whiteagle
04/09/2009, 11:27 AM
Looks nice, but your download link is not working.


Sorry about that,

There was an error during the upload, fixed :)


Thank you.


You're welcome, please report any bugs that you find :)

Ricop522
12/02/2010, 02:54 AM
Cool

BlackFoX
12/02/2010, 02:58 AM
But it is Wrong Section i think :D

Whiteagle
12/02/2010, 03:04 AM
Oh this is old :P

This is here since the pre-beta for developers, when SA:MP 0.3 was still a dream for us mortals.

This was in fact posted over the 0.3 stuff but with the changes this got lost here :)

Going to report to get moved to FS & Inc's.

Thanks guys ;)

cyber_punk
01/03/2010, 11:28 AM
Seems like the easiest system around for NPC communication but I can't get it to work when using YSI, more specifically (I believe) its foreach that is causing the problems. I am running some tests now to see if I can't figure out exactly why.

[Edit] Out I figured out the problem, it has to do with the way foreach determines if something is a bot (SendChat) and since this include uses that it broke foreach. Since I am not using this feature (I only want it for the playback features) I was able to comment those sections out and everything is compiling fine now.