25.10.2009, 03:47
#define MAX_NPCS (number, the npc that what you have.)
(example)
i have 3 npcs.
#define MAX_NPCS 3
stock NPCAnswer(playerid, ask[], ans[], text[]) // Base Made by [Star]Panic.
{ // Source Made by [Pro]Master, Zenis Transco (Korean)
new string[256];
if(strcmp(ask, text, true) == 0)
{
for(new npc=0; npc<MAX_NPCS; npc++)
{
new NPCName[MAX_PLAYER_NAME];
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerName(npc,NPCName,sizeof(NPCName));
if(IsPlayerNPC(npc))
{
if(IsPlayerInRangeOfPoint(npc, 10.0, X,Y,Z))
{
if(GetClosestNPC(playerid))
{
format(string, sizeof(string), "%s: %s.", NPCName, ans);
SendClientMessageToAll(0xFFFFFFFA, string);
TurnPlayerFaceToPlayer(npc,playerid);
return 1;
}
}
}
}
}
return 1;
}
stock NPCAnswer2(playerid, ask[], ans1[], ans2[], text[]) // Base Made by [Star]Panic.
{ // Source Made by [Pro]Master, Zenis Transco.
new string[256];
if(strcmp(ask, text, true) == 0)
{
for(new npc=0; npc<MAX_NPCS; npc++)
{
new NPCName[MAX_PLAYER_NAME];
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerName(npc,NPCName,sizeof(NPCName));
if(IsPlayerNPC(npc))
{
if(IsPlayerInRangeOfPoint(npc, 10.0, X,Y,Z))
{
if(GetClosestNPC(playerid))
{
new Say = random(2);
if(Say == 0){format(string, sizeof(string), "%s: %s.", NPCName, ans1);}
if(Say == 1){format(string, sizeof(string), "%s: %s.", NPCName, ans2);}
SendClientMessageToAll(0xFFFFFFFA, string);
TurnPlayerFaceToPlayer(npc,playerid);
return 1;
}
}
}
}
}
return 1;
}
stock NPCAnswer3(playerid, ask[], ans1[], ans2[], ans3[], text[]) // Base Made by [Star]Panic.
{ // Source Made by [Pro]Master, Zenis Transco.
new string[256];
if(strcmp(ask, text, true) == 0)
{
for(new npc=0; npc<MAX_NPCS; npc++)
{
new NPCName[MAX_PLAYER_NAME];
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerName(npc,NPCName,sizeof(NPCName));
if(IsPlayerNPC(npc))
{
if(IsPlayerInRangeOfPoint(npc, 10.0, X,Y,Z))
{
if(GetClosestNPC(playerid))
{
new Say = random(3);
if(Say == 0){format(string, sizeof(string), "%s: %s.", NPCName, ans1);}
if(Say == 1){format(string, sizeof(string), "%s: %s.", NPCName, ans2);}
if(Say == 2){format(string, sizeof(string), "%s: %s.", NPCName, ans3);}
SendClientMessageToAll(0xFFFFFFFA, string);
TurnPlayerFaceToPlayer(npc,playerid);
return 1;
}
}
}
}
}
return 1;
}
stock TurnPlayerFaceToPlayer(playerid, facingtoid)
{
new Float:angle;
new Float:misc = 5.0;
new Float, Float:y, Float:z;
new Float:ix, Float:iy, Float:iz;
GetPlayerPos(facingtoid, x, y, z);
GetPlayerPos(playerid, ix, iy, iz);
angle = 180.0-atan2(ix-x,iy-y);
angle += misc;
misc *= -1;
SetPlayerFacingAngle(playerid, angle+misc);
}
HOW TO USE IT ?
(Example)
public OnPlayerText(playerid, text[])
{
NPCAnswer(playerid,"Hey","What...",text);
NPCAnswer2(playerid,"Hmm","Hmmmm..","Have you any ploblem sir?",text);
NPCAnswer3(playerid,"Fuck","Don't say like that.","Sorry?","Pardon?",text);
return 1;
}
Good working now.
Sorry to my bad english .
If you want to see the server,
Message to me plz.
(example)
i have 3 npcs.
#define MAX_NPCS 3
stock NPCAnswer(playerid, ask[], ans[], text[]) // Base Made by [Star]Panic.
{ // Source Made by [Pro]Master, Zenis Transco (Korean)
new string[256];
if(strcmp(ask, text, true) == 0)
{
for(new npc=0; npc<MAX_NPCS; npc++)
{
new NPCName[MAX_PLAYER_NAME];
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerName(npc,NPCName,sizeof(NPCName));
if(IsPlayerNPC(npc))
{
if(IsPlayerInRangeOfPoint(npc, 10.0, X,Y,Z))
{
if(GetClosestNPC(playerid))
{
format(string, sizeof(string), "%s: %s.", NPCName, ans);
SendClientMessageToAll(0xFFFFFFFA, string);
TurnPlayerFaceToPlayer(npc,playerid);
return 1;
}
}
}
}
}
return 1;
}
stock NPCAnswer2(playerid, ask[], ans1[], ans2[], text[]) // Base Made by [Star]Panic.
{ // Source Made by [Pro]Master, Zenis Transco.
new string[256];
if(strcmp(ask, text, true) == 0)
{
for(new npc=0; npc<MAX_NPCS; npc++)
{
new NPCName[MAX_PLAYER_NAME];
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerName(npc,NPCName,sizeof(NPCName));
if(IsPlayerNPC(npc))
{
if(IsPlayerInRangeOfPoint(npc, 10.0, X,Y,Z))
{
if(GetClosestNPC(playerid))
{
new Say = random(2);
if(Say == 0){format(string, sizeof(string), "%s: %s.", NPCName, ans1);}
if(Say == 1){format(string, sizeof(string), "%s: %s.", NPCName, ans2);}
SendClientMessageToAll(0xFFFFFFFA, string);
TurnPlayerFaceToPlayer(npc,playerid);
return 1;
}
}
}
}
}
return 1;
}
stock NPCAnswer3(playerid, ask[], ans1[], ans2[], ans3[], text[]) // Base Made by [Star]Panic.
{ // Source Made by [Pro]Master, Zenis Transco.
new string[256];
if(strcmp(ask, text, true) == 0)
{
for(new npc=0; npc<MAX_NPCS; npc++)
{
new NPCName[MAX_PLAYER_NAME];
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerName(npc,NPCName,sizeof(NPCName));
if(IsPlayerNPC(npc))
{
if(IsPlayerInRangeOfPoint(npc, 10.0, X,Y,Z))
{
if(GetClosestNPC(playerid))
{
new Say = random(3);
if(Say == 0){format(string, sizeof(string), "%s: %s.", NPCName, ans1);}
if(Say == 1){format(string, sizeof(string), "%s: %s.", NPCName, ans2);}
if(Say == 2){format(string, sizeof(string), "%s: %s.", NPCName, ans3);}
SendClientMessageToAll(0xFFFFFFFA, string);
TurnPlayerFaceToPlayer(npc,playerid);
return 1;
}
}
}
}
}
return 1;
}
stock TurnPlayerFaceToPlayer(playerid, facingtoid)
{
new Float:angle;
new Float:misc = 5.0;
new Float, Float:y, Float:z;
new Float:ix, Float:iy, Float:iz;
GetPlayerPos(facingtoid, x, y, z);
GetPlayerPos(playerid, ix, iy, iz);
angle = 180.0-atan2(ix-x,iy-y);
angle += misc;
misc *= -1;
SetPlayerFacingAngle(playerid, angle+misc);
}
HOW TO USE IT ?
(Example)
public OnPlayerText(playerid, text[])
{
NPCAnswer(playerid,"Hey","What...",text);
NPCAnswer2(playerid,"Hmm","Hmmmm..","Have you any ploblem sir?",text);
NPCAnswer3(playerid,"Fuck","Don't say like that.","Sorry?","Pardon?",text);
return 1;
}
Good working now.
Sorry to my bad english .
If you want to see the server,
Message to me plz.