Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

[Tutorial] Zombie bot's, functions for me

$
0
0
Well, today i come to demonstrate simple examples to appear BOT's, thanks to the creation of the FCNPC by OrMisicL. (It's my firts post and filterscript).

It is important to emphasize that you have to have a little knowledge in FCNPC to be able to carry out these activities.

I'll start with the simple, includes, define MAX_BOTS and commands:

PHP Code:

#include a_samp
#include foreach
#include zcmd //or Pawn.cmd
#include FCNPC //required
#define MAX_BOTS 1 //the number can change, it depends on how many bots you want to appear

forward Move(npcid);//required 

This will be the command to start the functions of the BOT's
PHP Code:

CMD:joinzombies(playeridparams[])return start_zombies(playerid); 

Following this, i will describe the main functions of the BOTS, spawn, attack and death

PHP Code:

stock start_zombies(playerid)
{
    
FCNPC_SetUpdateRate(100);// I recommend leaving it like this (configuration by OrMisicL)
    
for(new 0MAX_BOTSi++)
    {
        new 
string[30];
          
format(stringsizeof(string), "zombie_%d"1);//name for the BOT's
        
new npcid FCNPC_Create(string);

        new 
Float:xFloat:yFloat:z;
        
GetPlayerPos(playeridx,y,z);

        
FCNPC_Spawn(npcid87x,y+3,z);//Spawnear bots according to your position
        
FCNPC_SetHealth(npcid,100.0);//set health for the BOT's
        
FCNPC_MeleeAttack(npcid, -1true);
        
FCNPC_SetSkin(npcid,77);//skin for the BOT's
        
SetTimerEx("Move",100,1,"i",npcid);//timer for the move of the BOTS
    
}
    return 
1;
}

public 
Move(npcid)
{
    new 
Float:p[3];
    foreach(
Player,i)
    {
        
GetPlayerPos(i,p[0],p[1],p[2]);
        if(
IsPlayerInRangeOfPoint(npcid,50,p[0],p[1],p[2]))
        {
            
FCNPC_IsAttacking(npcid);
            
FCNPC_GoTo(npcid,p[0],p[1],p[2],MOVE_TYPE_SPRINT,2);
        }
    }
    return 
1;
}

//A simple example of a shot to the head for the BOT, with sniper, desert_eagle and silenced 9mm
public FCNPC_OnTakeDamage(npciddamageridweaponidbodypart)
{
    if(
weaponid == 34 && weaponid == 24 && weaponid == 23 && bodypart == 9)
    {
    
FCNPC_SetHealth(npcid,0);
    }
    return 
1;
}

//And finally, a simple example when the BOT kills you
public OnPlayerDeath(playeridkilleridreason)
{
if(
IsPlayerNPC(killerid))//BOT kill
{
GameTextForPlayer(playerid,"_~n~_~n~_~n~_~n~_~n~_~n~_~n~~r~zombie_win",4000,6);
}
else
{
if(
IsPlayerConnected(killerid))//normal kill
{
GameTextForPlayer(playerid,"owned"30006);
}
}
return 
1;


It should be noted that this tutorial is simple, according to your knowledge you can improve it.

Attachment 11382 - archives for the BOT's
Attachment 11383 - includes required
Original post of the creation( http://forum.sa-mp.com/showthread.php?t=428066 )

I accept all kinds of suggestions, a bug or error comment here.

Attached Files
File Type: rar FCNPC archives.rar (1.08 MB)
File Type: rar other archives.rar (13.6 KB)

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>