SA-MP Forums Archive
How will the player attack the NPC to be attacked by the NPC? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How will the player attack the NPC to be attacked by the NPC? (/showthread.php?tid=653029)



How will the player attack the NPC to be attacked by the NPC? - nguyendinhdat - 24.04.2018

Code :

#include <a_samp>

public OnFilterScriptInit()
{
print("\n-----------------------------------");
print(" NPC policijski botovi | StjepanS");
print("------------------------------------\n");
return 1;
}

public OnGameModeInit()
{
ConnectNPC("StjepanSBot","npcstjepans");
ConnectNPC("StjepanSBot1","npcstjepans1");
return 1;
}

public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) // Provjerava da li se spawnao NPC.
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); // Dobivanje imena NPCa
if(!strcmp(npcname, "StjepanSBot", true))
{
SetPlayerColor(playerid, 0xFFFFFFAA);// Stavlja bijelu boju NPCu.
SetPlayerSkin(playerid, 281);// Stavlja skin NPCu id 281
SetPlayerAttachedObject(playerid,0,19142,1,0.04930 0,0.035000,-0.003500,0.000000,0.000000,0.000000,1.100000,1.100 000,1.100000);// Postavlja NPCu objekt pancirke
}
if(!strcmp(npcname, "StjepanSBot1", true))
{
SetPlayerColor(playerid, 0xFFFFFFAA);// Stavlja bijelu boju NPCu.
SetPlayerSkin(playerid, 280);// Stavlja skin NPCu id 280
SetPlayerAttachedObject(playerid,0,19142,1,0.04930 0,0.035000,-0.003500,0.000000,0.000000,0.000000,1.100000,1.100 000,1.100000);// Postavlja NPCu objekt pancirke
}
}
return 1;
}


Re: How will the player attack the NPC to be attacked by the NPC? - Neutralneu - 26.04.2018

If you wish to make an NPC attack you in return then you should use FCNPC plugin which allows you to do almost everything with NPC and making complex artificial intelligence for it.