09.11.2011, 23:37
Hi, I am wanting to freeze my npc when it detects someone Infront of them, I know it's possible, PRRP have done it. Thanks.
new Float: fA, Float: X, Float: Y, Float: Z, Float: nX, Float: nY;
GetPlayerFacingAngle(npcid, fA);
GetPlayerPos(npcid, X, Y, Z);
nX = X + ( 2.0 * floatcos(fA, degrees) );
nY = Y + ( 2.0 * floatsin(fA, degrees) );
if(IsPlayerInRangeOfPoint(playerid, nX, nY, Z)) return true; // his at the loc
if(IsPlayerNPC(playerid)) { "STEP5" }
new
playerid
;
for(new i; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && IsPlayerNPC(i))
{
GetPlayerPos(g_NpcID[i], X, Y, Z);
for(new all; all < MAX_PLAYERS; all++)
{
if(IsPlayerInRangeOfPoint(all, nX, nY, Z)) //Basic calculation said before
{
}
}
}
pawn Код:
|
forward BotChecks(playerid);
public BotChecks(playerid)
{
new Float:pPos[3], Float:Pos[3], Float:npPos[4], Float:nPos[3], string[100], id;
GetPlayerPos(id, npPos[0], npPos[1], npPos[2]);
GetPlayerFacingAngle(id, npPos[3]);
Pos[0] = npPos[0] + ( 15.5 * floatcos(npPos[3], degrees) );
Pos[1] = npPos[1] + ( 15.5 * floatsin(npPos[3], degrees) );
if(IsPlayerInRangeOfPoint(playerid, 15.5, Pos[0], Pos[1], npPos[2]))
{
TogglePlayerControllable(id, 0);
SetTimer("NPCFreeze", 6000, false);
}
return 1;
}
forward NPCFreeze(playerid);
public NPCFreeze(playerid)
{
new string[128], id;
format(string, sizeof(string), "%s[%d]: {FFFFFF}Hey! %s move out the way. I'm trying to do my job here!", Name(id), id, Name(playerid));
SendClientMessageToAll(GetPlayerColor(id), string);
TogglePlayerControllable(id, 1);
return 1;
}
I've been using this and here's my code, which fails I know xD, is there any problems with it?
pawn Код:
|
Good idea!
One way you could possibly do this is to: 1. Use the file functions and write as the file header the NPC's name. 2. Connect the NPC 3. Go to OnPlayerRequestSpawn 4. pawn Код:
6. If this has been set out correctly and he has a file create a basic array "new g_NpcID[MAX_PLAYERS];" 7. g_NpcID[MAX_PLAYERS] = playerid; 8. Get the NPC ID: pawn Код:
HOWEVER. Hooking the file creation method to ConnectNPC would be the best idea i guess lol |