WTFCS Community | Gaming community @ since 2011

Full Version: [Tutorial] Cum faci un NPC sa execute un ANIM + ChatBubble
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Acest tutorial este pentru cei care se pricep cat de cat in pawno, daca nu aveti cunostinte suficiente nu urmariti acest tutorial.



Pentru inceput trebuie sa vedem daca NPC-ul este langa player




forward GetClosestNPC(p1);
public GetClosestNPC(p1)
{
new x,Float:dis,Float:dis2,player;
player = -1;
dis = 99999.99;
for (x=0;x<MAX_PLAYERS;x++)
{
if(IsPlayerNPC(x))
{
if(x != p1)
{
dis2 = GetDistanceBetweenPlayers(x,p1);
if(dis2 < dis && dis2 != -1.00)
{
dis = dis2;
player = x;
}
}
}
}
return player;
}



Sa zicem ca vrei sa pui un NPC la bariera Los Santos Department, iar cand un player va deschide bariera, NPC-ul sa execute o animatie + un text (ChatBubble, pentru cunoscatori)



Simplu


if(newkeys==KEY_CROUCH)
{
new bot = GetClosestNPC(playerid); // Aceasta este importanta
if(IsPlayerInAnyVehicle(playerid))
{
if((IsACop(playerid)) && PlayerToPoint(15.0, playerid, 1588.2966,-1637.8121,13.4255))
{
MoveObject(PDGATE,1597.846802, -1638.088257, 14.655367,1);
SetTimer("PDGATECLOSE", 10000, false);
}
if((IsACop(playerid)) && PlayerToPoint(15.0, playerid,1541.8696,-1628.0836,13.3828))
{
SetObjectRot(barrier, 0, 0, 270);
SetTimer("outbarrier", 6000, false);
SetPlayerChatBubble(bot,"I opened the barrier for you Officer! Have a nice day!",COLOR_WHITE,35.0,5000); // textul care sa i se afiseze npc-ului deasupra capului
ApplyAnimation(bot, "BAR","Barserve_bottle", 4.0, 0, 0, 0, 0, 0, 1); // aici puneti animatia dorita pt bot
}