Vice City: Multiplayer

Server Development => Community Plugins => Topic started by: habi on Apr 01, 2022, 05:37 PM

Title: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Apr 01, 2022, 05:37 PM
Introduction

An attempt to implement Non Playable Characters (NPC) for vc-mp has been made. The working of this was inspired by SA-MP.

ConnectNPCEx("Oliver", Vector (235.399, -1293.33, 11.071),  -0.272573, 1);

ConnectNPCEx("Meera", Vector(233.236, -1291.67, 11.0706), -1.47619, 63);

(https://i.imgur.com/djJDziZ.png)


Limitation:

Application Download links ( v1.7 Beta 3)( 2023-10-08) (YYYY-MM-DD)
rel006
Windows:    Windows-installer (https://sourceforge.net/projects/npc-for-vcmp/files/npcclient-setup-v1.7-beta3.exe/download)     

Linux x64 (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x64_v1.7-beta3.zip/download)    Linux x86 (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x86_v1.7-beta3.zip/download)         

rel004
Windows+Linux: binaries (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel004_win_lin_v1.7-beta3.zip/download)

Discord:
A discord has been setup at my friends request to discuss about NPC question, answers: here (https://discord.gg/qRCyXbBpVp)

Tutorials :  1. Creating an idle NPC (https://forum.vc-mp.org/?topic=8802.0)    2. Recording player actions (https://forum.vc-mp.org/?topic=8803.0)  3. Recording vehicle drivings (https://forum.vc-mp.org/?topic=8806.0)

11 minute long video tutorial of setting up (w/o installer) and recording/replay: here (https://forum.vc-mp.org/index.php?topic=8812.0)

NPC Full Wiki - documentation ( Click image to open )
(https://i.imgur.com/ocuw2fN.png) (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/Main_Page)

Functions and callbacks plain documentation
---------------------------------------------------------------------------
NPC Callbacks
---------------
OnNPCScriptLoad( params )
OnNPCScriptUnload()
OnNPCConnect([integer] myplayerid)
OnNPCDisconnect([integer] reason)
OnNPCSpawn()
OnNPCEnterVehicle([integer] vehicleid, [integer] seatid )
OnNPCExitVehicle()
OnClientMessage([integer] r, [integer] g, [integer] b, [string] message )
OnPlayerDeath([integer] playerid )
OnPlayerText([integer] playerid, [string] message )
OnPlayerStreamIn([integer] playerid )
OnPlayerStreamOut([integer] playerid )
OnVehicleStreamIn([integer] vehicleid )
OnVehicleStreamOut([integer[ vehicleid )
OnRecordingPlaybackEnd()
OnPlayerUpdate( [integer]playerid, [integer]updatetype )
OnSniperRifleFired( [integer]playerid, [integer]weaponid, [float]x, [float]y, [float]z, [float]dx, [float]dy, [float]dz )
OnConsoleInput( [string]text )
OnServerData( [blob]data )
-------------------------------------------------------------------------------
--------------
NPC Functions
--------------
[true/null]StartRecordingPlayback([integer] playbacktype, [string] recordname )
[true/null]StopRecordingPlayback()
[true/null]PauseRecordingPlayback()
[true/null]ResumeRecordingPlayback()
[null]SendChat([string] text)
[null]SendCommand([string] command) //without '/'
[Vector|null]GetMyPos()   
[null]SetMyPos( [Vector] position )
[float]GetMyFacingAngle()
[null]SetMyFacingAngle( [float] angle ) //in radians
[float]GetDistanceFromMeToPoint( [Vector] point )
[bool]IsVehicleStreamedIn( [integer] vehicleid )
[bool]IsPlayerStreamedIn( [integer] playerid )

[integer] SetTimer( [string] FunctionName, [integer] interval, [integer] repeat) //repeat=1 means loop
[null]KillTimer( [integer] timerid )
[integer] GetPlayerState( [integer] playerid )
[Vector] GetPlayerPos( [integer] playerid )
[integer] GetPlayerVehicleID( [integer] playerid )
[integer] GetPlayerArmedWeapon( [integer] playerid )
[integer] GetPlayerHealth( [integer] playerid )
[integer] GetPlayerArmour( [integer] playerid )
[integer] GetPlayerKeys( [integer] playerid )
[float(in radians)] GetPlayerFacingAngle( [integer] playerid )
[bool]IsPlayerInRangeOfPoint( [integer] playerid, [float] radius, [Vector] point )
[string/null] GetPlayerName( [integer] playerid )
[bool] IsPlayerConnected( [integer] playerid )

[null]SendOnFootSyncData( [integer] keys, [float]posx, [float]posy, [float]posz, [float]angle, [integer]health, [integer]armour, [integer]weapon, [integer]ammo, [float]speedx, [float]speedy, [float]speedz, [float]aimposx, [float]aimposy, [float]aimposz, [float|integer]aimdirx, [float|integer]aimdiry, [float|integer]aimdirz, [bool]isCrouching, [bool]isReloading )
[true]SendOnFootSyncDataEx( [integer] keys, [Vector]pos,  [float]angle, [integer]health, [integer]armour, [integer]weapon, [integer]ammo, [Vector]speed, [Vector]aimpos, [Vector]aimdir, [bool]isCrouching, [bool]isReloading )
[null]FireSniperRifle( [integer]rifleid, [float]aimposx, [float]aimposy, [float]aimposz, [float|integer]dx, [float|integer]dy, [float|integer]dz)
[true]FireSniperRifleEx( [integer]rifleid, [Vector]aimpos, [Vector]naimdir )
[true]SendInCarSyncData( [integer]keys, [integer]health, [integer]armour, [integer]weapon, [integer]ammo, [float|integer]carhealth, [integer]damage, [float|integer]posx, [float|integer]posy, [float|integer]posz, [float|integer]rotx, [float|integer]roty, [float|integer]rotz, [float|integer]rotw, [float|integer]speedx, [float|integer]speedy, [float|integer]speedz, [float|integer]turretx, [float|integer]turrety )
[true]SendInCarSyncDataEx( [integer]keys, [integer]health, [integer]armour, [integer]weapon, [integer]ammo, [float|integer]carhealth, [integer]damage, [Vector]pos, [Quaternion]rotation, [Vector]speed, [float|integer]turretx, [float|integer]turrety )
[bool]EnterVehicle( [integer]vehicleid, [integer]seatid )
[null]SendShotInfo( [integer]bodypartId, [integer]animationId )
[null/true]SetLocalValue( [integer]field, [integer|float]value)
[integer/float/null]GetLocalValue( [integer]field )
[null]SendOnFootSyncDataLV()
[null]SendDeathInfo( [integer]weaponId, [integer]killerId, [integer]bodypartId )
[null/true/false]FaceNPCToPlayer( [integer]playerid )
[float/null]WhereIsPlayer( [integer]playerid )
[integer]GetPlayerSlotWeapon( [integer]playerid, [integer]slotid )
[integer]GetPlayerSlotAmmo( [integer]playerid, [integer]slotid )
[integer]GetSlotFromWeaponId( [integer]weaponid )
[integer|null]SetTimerEx( [string]functionname, [integer]interval, [integer]n, ...)
[integer]GetTickCount()
[null/true/false]SendPassengerSyncData()
[null]SetPSLimit([integer] n)
[integer]GetPlayerSkin( [integer]playerid )
[integer]GetPlayerTeam( [integer]playerid )
[integer]GetClosestPlayer( [bool]checkteam=false )

[string/null]GetMyName()
[integer/null]GetMyID()
[true]QuitServer()

[bool]SendServerData([blob]data)

[integer]ReadInt([blob]data)
[integer]ReadByte([blob]data)
[float]ReadFloat([blob]data)
[string]ReadString([blob]data)
[true]WriteInt([blob]data, [integer]int)
[true]WriteByte([blob]data, [integer]int)
[true]WriteFloat([blob]data, [float]fval)
[true]WriteString([blob]data, [string]str)
----------------------------------------------------------------------------------------------------------------
Classes
-------
1. Vector
    Constructor( float x, float y, float z )
    Metamethods: _add, _sub, _mul(float), _div(float), _tostring
    methods:
        [float]Length()
        [Vector]Normalized()
2. Quaternion
    Constructor( float x, float y, float z, float w )
    Metamethods: _add, _sub, _mul(float), _div(float), _tostring
----------------------------------------------------------------------------------------------------------------
Constants
---------
PLAYER_RECORDING_TYPE_ONFOOT        <-  1
PLAYER_RECORDING_TYPE_DRIVER        <-    2

MAX_PLAYERS                            <-    100
MAX_PLAYER_NAME                        <-    24
MAX_VEHICLES                        <-    1000
INVALID_PLAYER_ID                    <-    0xFF
INVALID_VEHICLE_ID                    <-    0

PLAYER_STATE_NONE                    <-    0
PLAYER_STATE_ONFOOT                    <-    1
PLAYER_STATE_AIM                    <-    2
PLAYER_STATE_DRIVER                    <-    3
PLAYER_STATE_PASSENGER                <-    4
PLAYER_STATE_ENTER_VEHICLE_DRIVER    <-    5
PLAYER_STATE_ENTER_VEHICLE_PASSENGER<-    6
PLAYER_STATE_EXIT_VEHICLE            <-    7
PLAYER_STATE_WASTED                    <-    8
PLAYER_STATE_SPAWNED                <-    9

KEY_ONFOOT_AIM        1   
KEY_ONFOOT_NEXTWEP        2   
KEY_ONFOOT_PREVWEP        4   
KEY_ONFOOT_PUNCH        64   
KEY_ONFOOT_CROUCH        288   
KEY_ONFOOT_FIRE        576   
KEY_ONFOOT_SPRINT        1024   
KEY_ONFOOT_JUMP        2176   
KEY_ONFOOT_RIGHT        4096   
KEY_ONFOOT_LEFT        8192   
KEY_ONFOOT_BACKWARD        16384   
KEY_ONFOOT_FORWARD        32768   
KEY_ONFOOT_LOOKBHND        65536   
KEY_INCAR_HANDBRAKE        1   
KEY_INCAR_LOOKRIGHT        2   
KEY_INCAR_LOOKLEFT        4   
KEY_INCAR_LEANDOWN        8   
KEY_INCAR_LEANUP        16   
KEY_INCAR_FORWARD        1024   
KEY_INCAR_HORN        288   
KEY_INCAR_BACKWARD        2176   
KEY_INCAR_RIGHT        4096   
KEY_INCAR_LEFT        8192   
KEY_INCAR_SUB_MISSION        65536   

BODYPART_BODY  0
BODYPART_TORSO  1
BODYPART_LEFTARM  2
BODYPART_RIGHTARM  3
BODYPART_LEFTLEG  4
BODYPART_RIGHTLEG  5
BODYPART_HEAD  6

fields and types( of 'SetLocalValue' and 'GetLocalValue' )
I_KEYS    integer
F_POSX    float
F_POSY    float
F_POSZ    float
F_ANGLE    float
I_HEALTH    integer
I_ARMOUR    integer
I_CURWEP    integer
I_CURWEP_AMMO    integer
V_ONFOOT_SPEED    Vector
V_AIMPOS    Vector
V_AIMDIR    Vector
V_POS        Vector
Q_CAR_ROTATION    Quaternion
F_CAR_HEALTH    float
I_CAR_DAMAGE    integer
V_CAR_SPEED        Vector
F_CAR_TURRETX    float
F_CAR_TURRETY    float
---------------------------------------------------------------------------------------------------------------
Squirrel Add-On Plugin npc04relxx functions
-------------------------------------------
ConnectNPC( [string] name, [string] script="", [bool]enableconsoleinput=false, [string] host="127.0.0.1", [string] plugins="")
ConnectNPCEx( [string] name, [float|integer]x, [float|integer]y, [float|integer]z, [float|integer]angle, [integer] skinId=default, [integer] weaponId=default, [integer] classId=0, [string]script="", [bool]enableconsoleinput=false, [string]host="127.0.0.1", [string]plugins="", [string]... )
ShowNPCConsole()
HideNPCConsole()
[bool]IsPlayerNPC( [integer] playerid )
[bool]StartRecordingPlayerData( [integer] playerid, [integer] recordtype, [string]recordname )//recordname without .rec extn
[bool]StopRecordingPlayerData( [integer] playerid )

[bool]SetMaxPlayersOut( [integer] maxplayers )
[bool]SetNameOfAllNPC([string]name)

[function a]F([string]funcname or [userdata] returned by another F)
   
    function a, Variable Parameters( null, integer, float, string, bool, array, userdata made by another F, Vector,
    and Quaternion).
    returns userdata

[function b]RFC([integer]npcid, [string]funcname|[userdata])
   
    function b, Variable Parameters( null, integer, float, string, bool, array, userdata returned by F, Vector,
    and Quaternion).
    returns bool

Squirrel Add-On Plugin npc04relxx functions
-------------------------------------------
ConnectNPC( [string] name, [string] script, [string] host="127.0.0.1")
[bool]IsPlayerNPC( [integer] playerid )
[bool]StartRecordingPlayerData( [integer] playerid, [integer] recordtype, [string]recordname )//recordname without .rec extn
[bool]StopRecordingPlayerData( [integer] playerid )

See also on wiki: v1.7 beta 3 release notes  (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_7_beta3_release_notes)

Source: Click here (https://github.com/habi498/npc-vcmp) ( github ), License: GPL v3
Title: Re: An implementation of NPC in VCMP 0.4
Post by: AroliS^ on Apr 01, 2022, 07:19 PM
Nice work!
Title: Re: An implementation of NPC in VCMP 0.4
Post by: Sebastian on Apr 02, 2022, 09:27 PM
Now imagine the Vice City coming to life, with NPCs simulating the traffic. I would love to see that!
(if you guys do that, please tell me the server ip)

habi, man, I don't know what will happen to vc:mp in the future, but I'm glad you shown people a way to play with NPCs !
Everybody screaming for them. Well, here they are! Everything looks pretty easy to use.

Thanks for this!
Title: Re: An implementation of NPC in VCMP 0.4
Post by: MEGAMIND on Apr 03, 2022, 07:28 AM
A long wait came to reality, thanks @habi + a video tutorial about implementing and creating an npc would be appreciated
Title: Re: An implementation of NPC in VCMP 0.4
Post by: SexAppeal on Apr 04, 2022, 08:45 AM
Impressive :o
Title: Re: An implementation of NPC in VCMP 0.4
Post by: habi on Apr 05, 2022, 04:29 AM
Quote from: MVrc0v on Apr 04, 2022, 08:45 AMImpressive :o
thanks
Title: Re: An implementation of NPC in VCMP 0.4
Post by: Spiller on Apr 06, 2022, 04:52 AM
This looks amazing!
(Though I'm not sure if I'll go through the pain of working with the squirrel plugin again)
Title: Re: An implementation of NPC in VCMP 0.4
Post by: habi on Apr 21, 2022, 05:14 AM
Quote from: Spiller on Apr 06, 2022, 04:52 AMThough I'm not sure if I'll go through the pain of working with the squirrel plugin again
Actually, this works with the squirrel plugin. This is supposed to work with java plugin also, if you are using it. i.e. if your server language is java, you still can npc without switching to squirrel. In that case a separate plugin is to be made, a plugin that attaches to the java host, and creating two functions "ConnectNPC" and "IsPlayerNPC". (The codes are available. Check the first post. )
The intelligence of NPC lies in the scripts which ofcourse have to be scripted in squirrel.

If you are recording actions of player (tutorial 2),  you can run a blank squirrel server with above npc04relxx module.  Then copy the. rec file to its place. Then make NPC Script which may use the. rec  file.  Then from java call the npc program using system command.
Title: Re: NPC implementation in VCMP 0.4
Post by: NicusorN5 on May 27, 2022, 12:53 AM
The older plugin "actor" is very similar to this? Why rewrite it?
Title: Re: NPC implementation in VCMP 0.4
Post by: habi on May 27, 2022, 02:40 PM
Yes, earlier plugin called "actor" is very similar to this. Here are the reasons why i rewrite it.

First, "actor" plugin used "server hooks" somewhere. So a possible bug in the plugin will affect the server.
But in the new model,  any possible bug cannot affect server because server calls an external application to run. A bug will result in the failing of the external application and not the server.

Secondly, in the earlier plugin if you want to check say "a specific actor (say John) entered a vehicle,
1. you have to first find squirrel onPlayerVehicleEnter function in main.nut
2. Check if the player is an actor
3. Check if the name of the player == "John"
4. Script the codes
But in the new model, the code is separate. It is not coded in main.nut.
It is a separate nut file which determines all events of John like onNPCEnterVehicle, onNPCSpawn, onClientMessage, etc. And you connect John with the script file. ( It is like saying "Hey John, take this script file and connect to my server " )


Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Nov 14, 2022, 11:08 PM
Working with npcs and sniper rifles,
(https://i.imgur.com/gYq5uBq.jpg) (https://i.imgur.com/JqulBnE.jpg)
'habi' in the image is npc and it is shooting me with a weapon 29 (laser sniper)

This function in npc's script
FireSniperRifle([integer]wep(28/29), [float]aimPosX, [float]aimPosY, [float]aimPosZ, [float](alpha), [float]Angle ) where alpha is an angle in radians. 0. 0 means complete horizonal, postive means above, negative means below. can be obtained from aimdir.y. Angle - npc's facing angle if faced to target.
which fires a sniper shot from npc to any target.

Need to perfect some codes and will release here.

Version 1.3
npcclient.exe here (https://www.dropbox.com/s/0q7ex4pdo4i8kwd/npcclient.exe?dl=0)

Changelog below[spoiler]Version 1.3 Changes (15.11.2022)
Extended Timer implemented SetTimerEx (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/SetTimerEx)
Fixed npc running unwantedly just after sending some packet.
Added boolean parameter for crouching in SendOnFootSyncData[/spoiler]
Title: NPCs new functions added
Post by: habi on Dec 05, 2022, 07:17 AM
Version 1.5 released ( 05-Dec-2022 )

Lot of bugs fixed
-Version 1.4 (was available to download from npc-wiki) has been compiled on older version of linux and hence had problems running on Ubuntu 18.04

New changes

-NPCs can be connected without a script. ( See ConnectNPCEx on wiki (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/New_Release) ). This new functions parameters include position, skin, weapon and class to spawn. This is useful in creating models in shops like ammunation, toolstore or similary places.
ConnectNPCEx(name, x, y, z, angle, skinId, weaponId, classId, script="", host="127.0.0.1", ...)
ConnectNPCEx( "Mercedes", 100.0, 200.0, 10.0, 0.0, 116, 0, 0,"mercedes_script.nut","","parameter1", "parameter2", "parameter3");
//Mercedes will be created at the specified position with tag 'Mercedes'. The 'parameter1', 'parameter2', 'parameter3' will be passed to npcscript. Note that 'mercedes_script.nut' must lie in [Server folder]/npcscripts folder.

-Parameters can be passed to the npcscripts ( like argv of C ) ( from server main.nut). This is passed as an array to OnNPCScriptLoad( params ).

-GetTickCount on npcscripts

- old scripts are not compatible with this version due to the addition of argument 'params' in onNPCScriptLoad. Other than that, it works fine.

-Playback recordings created prior to v1.4 are incompatible. A command-line tool to convert old .rec files to new format .rec files is provided along with setup. See npcclient/recupdate folder.

-Introduction of 'SendDeathInfo' function which will let the npc's be killed by a player.
//  [Server folder]/npcscripts/mynpc.nut
function ICantTakeItAnyMore
{
SendDeathInfo( 70, 255, 0 ); //70 means weapon Id. 255 the killer ID (for suicide). 0 the bodypart.
}

Download links v1.5

Windows       Windows x86 and x64 (https://sourceforge.net/projects/npc-for-vcmp/files/npcclient-v1.5-setup.exe/download)
Linux             Linux x86 (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_linux_x86_v1.5.zip/download)
Linux             Linux x64 (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_linux_x64_v1.5.zip/download)

Challenge
A small mission-like server here:        172.105.41.83:8192

If you find any bugs, do report it.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Yyg on Dec 05, 2022, 04:30 PM
Amazing work, bringing life to the world!
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Sebastian on Dec 06, 2022, 09:35 PM
Damn,  only if I would have checked this few hours ago.
Now I need to wait until tomorrow to join that server with demo mission,  haha.

Great job,  man!
All the effort you put into this is enormous,  and the new features sound great!
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Dec 07, 2022, 08:03 AM
Quote from: Sebastian on Dec 06, 2022, 09:35 PMDamn,  only if I would have checked this few hours ago.
Now I need to wait until tomorrow to join that server with demo mission.
I'm glad to hear it
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Sebastian on Dec 07, 2022, 10:13 PM
https://forum.vc-mp.org/?topic=8952

here is a short video I made while testing out the server
Pure Awesome!
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Sebastian on Dec 08, 2022, 04:39 PM
Now, regarding the plugin.
I've done some tries now to get the npc shooting at me, but with not much success.
I've used the examples from wiki, for both Melee attack and Ruger attack, but none of them really worked...
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Mikimon on Dec 08, 2022, 11:27 PM
bro, u always improving something and surprising us a lot, thanks ;D ;D
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Dec 09, 2022, 08:13 AM
ok, i will look into it.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Dec 09, 2022, 11:23 AM
The function 'SendOnFootSyncData' is to be called with a timer.
Try something like
SetTimerEx( "ShootPlayer", 60, 0 );

So in 60ms interval, send packets continuously.

This will make player shoot.

Advanced: Take a note of no: bullets fired.

Logic

function ShootPlayer

Is Time to Reduce Ammo ?
Yes--> shots_fired++, ammo=ammo-1 ( to get and set use I_CURWEP_AMMO and 'GetLocalValue' fn. )
No-->nothing.

Is It time for Reloading  ?
Yes-->You know, some parameter true.
No-->parameter false.

I have made a sample script with comments and untested ( no time now ), from the demo server.here (https://pastebin.com/K25tmWaD)

The following table gives information of various weapons to npcs.
class WEAPON
{
    range=80;
    firingrate=250; //interval ms
    reload=500; //ms
    clipsize=30;
    damage=25;
    constructor( range, firingrate, reload, clipsize, damage)
    {
        this.range= range;
        this.firingrate=firingrate;
        this.reload=reload;
        this.clipsize=clipsize;
        this.damage=damage;
    }
};
Weapon<-array( 34 ); //minigun id is 33. plus 1 for weapon 0
Weapon[0] = WEAPON(2.4,250, 100, 1000, 8);
Weapon[1] = WEAPON(2.0,450, 100, 1000, 16);
Weapon[2] = WEAPON(1.8,250, 100, 1000, 45);
Weapon[3] = WEAPON(1.5,450, 100, 1000, 21);
Weapon[4] = WEAPON(1.5,450, 100, 1000, 21);
Weapon[5] = WEAPON(1.8,250, 100, 1000, 21);
Weapon[6] = WEAPON(2.0,450, 100, 1000, 21);
Weapon[7] = WEAPON(1.5,450, 100, 1000, 21);
Weapon[8] = WEAPON(1.9,250, 100, 1000, 24);
Weapon[9] = WEAPON(2.0,250, 100, 1000, 24);
Weapon[10] = WEAPON(2.1,250, 100, 1000, 30);
Weapon[11] = WEAPON(1.7,900, 100, 1000, 35);
Weapon[12] = WEAPON(30.0,100, 1, 1, 75);
Weapon[13] = WEAPON(30.0,100, 1, 1, 75);
Weapon[14] = WEAPON(30.0,100, 1, 1, 75);
Weapon[15] = WEAPON(25.0,100, 1, 1, 75);
Weapon[16] = WEAPON(30.0,100, 1, 1, 75);
Weapon[17] = WEAPON(30.0,210, 450, 17, 25);
Weapon[18] = WEAPON(30.0,630, 1000, 6, 135);
Weapon[19] = WEAPON(20.0,250, 450, 1, 80);
Weapon[20] = WEAPON(15.0,250, 750, 7, 100);
Weapon[21] = WEAPON(10.0,250, 250, 1, 120);
Weapon[22] = WEAPON(30.0,119, 500, 50, 20);
Weapon[23] = WEAPON(45.0,59, 500, 30, 20);
Weapon[24] = WEAPON(30.0,60, 500, 30, 15);
Weapon[25] = WEAPON(45.0,90, 500, 30, 35);
Weapon[26] = WEAPON(90.0,90, 1000, 30, 40);
Weapon[27] = WEAPON(90.0,150, 1000, 30, 35);
Weapon[28] = WEAPON(100.0,89, 1401, 1, 125);
Weapon[29] = WEAPON(100.0,180, 1401, 7, 125);
Weapon[30] = WEAPON(55.0,100, 1200, 1, 75);
Weapon[31] = WEAPON(5.1,100, 100, 500, 25);
Weapon[32] = WEAPON(75.0,119, 500, 100, 130);
Weapon[33] = WEAPON(75.0,30, 350, 500, 140);

/* Generated from server side code
function makecode()
{
for(local i=0; i< 34; i++)
{
    local string=format("Weapon[%d] = WEAPON(%0.1f,%d, %d, %d, %d);", i,
    GetWeaponDataValue( i, 2 ), GetWeaponDataValue( i, 3 ),
    GetWeaponDataValue( i, 4 ), GetWeaponDataValue( i, 5 ),
    GetWeaponDataValue( i, 6 ) );
    print(string);
}
}
*/
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Yyg on Dec 09, 2022, 11:57 AM
:)Hi habi, I would like to feedback a question

When I tried to use version 1.5, I found that any NPCS driving vehicles would not work
When I tried using the rec fix tool, he told me that the driving function did not need to be fixed
(Nothing to do for PLAYER_RECORDING_TYPE_DRIVER recordings)
(Even if you use the built-in taxi rec or nut, it doesn't work)

When I replaced npcclient.exe with the old version, everything worked fine
(cannot be played by this version of program)
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Sebastian on Dec 09, 2022, 01:10 PM
Alright,  will test it this weekend
Thank you!
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Sebastian on Dec 09, 2022, 09:06 PM
With your example code, I was finally able to make the npc shoot, which is satisfying!

though, I've realized that SetTimerEx doesn't work at all.
NPC Console opens and instantly closes.

PS: For who wants to see the NPC Console, use ShowNPCConsole() before connecting the npcs
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Dec 10, 2022, 02:12 PM
Quote from: Yyg on Dec 09, 2022, 11:57 AM:)Hi habi, I would like to feedback a question

When I tried to use version 1.5, I found that any NPCS driving vehicles would not work.




(cannot be played by this version of program)
Hi Yyg. It was a condition which escaped my notice.
The '. rec' files are binary files. The first byte of all of them was E8 in previous version.
Version 1.5 require it to be E9.
I request you to make this change in the first byte of driving recordings using a 'hex-editor', for the time being.
(https://i.imgur.com/MbWhxLx.jpg)
The first four bytes E8 03 = 1000 (decimal)
E9 03 = 1001
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Dec 10, 2022, 02:21 PM
Quote from: Sebastian on Dec 09, 2022, 09:06 PMWith your example code, I was finally able to make the npc shoot, which is satisfying!

though, I've realized that SetTimerEx doesn't work at all.
NPC Console opens and instantly closes.
Hi seby. nice to hear that npcs is shooting.

NPC Console opens and normally close only when disconnected from server.

I will check what is the problem with SetTimerEx
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Yyg on Dec 11, 2022, 02:57 AM
Quote from: habi on Dec 10, 2022, 02:12 PM
Quote from: Yyg on Dec 09, 2022, 11:57 AM:)Hi habi, I would like to feedback a question

When I tried to use version 1.5, I found that any NPCS driving vehicles would not work.




(cannot be played by this version of program)
Hi Yyg. It was a condition which escaped my notice.
The '. rec' files are binary files. The first byte of all of them was E8 in previous version.
Version 1.5 require it to be E9.
I request you to make this change in the first byte of driving recordings using a 'hex-editor', for the time being.
(https://i.imgur.com/MbWhxLx.jpg)
The first four bytes E8 03 = 1000 (decimal)
E9 03 = 1001

Thanks habi, it worked! The vehicle is moving again! :)
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Yyg on Dec 12, 2022, 08:07 AM
Hello Habi, the new NPC features are very interesting!

But I still have a few issues, I try to get the NPC to sit in my car (player.PutInVehicleSlot), it seems to work, but the NPC will no longer do a stream update (Pos locked) and when I drive the car a certain distance, the NPC will disappear and return to the point where it was boarded.

After my tests, when the NPC is PutInVehicleSlot, his player.Vehicle == null and player.Pos stays in the boarding Position
It seems impossible to do a "on-board" Update Vehicle Pos in NPCScript, and when I try something like SetMyPos(), the NPC just leaves the vehicle.

Maybe I'm getting something wrong, but are there any examples where an NPC can get in my car, no matter where I drive it?
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Sebastian on Dec 12, 2022, 06:02 PM
I have faced a similar behavior when setting a rolling animation to the npc.
Basically,  the npc doesn't update position if the animation actually features movement.

Just mentioning it here,  maybe there will be some fix for it.  In my case,  I am updating pos manually,  as a work around.

As for your case,  I think we need some state which will let server know when a npc is getting inside car,  to update it's position. But it's tricky,  because if (behind the scenes)  npc becomes the owner of vehicle,  and sync will be sent from it's point of view only,  there will actually never be syncs sent.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Dec 19, 2022, 08:15 AM
Quote from: Yyg on Dec 12, 2022, 08:07 AMHello Habi, the new NPC features are very interesting!

But I still have a few issues, I try to get the NPC to sit in my car (player.PutInVehicleSlot), it seems to work, but the NPC will no longer do a stream update (Pos locked) and when I drive the car a certain distance, the NPC will disappear and return to the point where it was boarded.d player.Pos stays in the boarding Position
It seems impossible to do a "on-board" Update Vehicle Pos in NPCScript, and when I try something like SetMyPos(), the NPC just leaves the vehicle.

Maybe I'm getting something wrong, but are there any examples where an NPC can get in my car, no matter where I drive it?
Thank you Yyg. I understand the problem with putting NPCs inside Vehicles.
We have not implemented this feature it. Syncing NPC in vehicle needs a new function as the existing function 'SendOnFootSyncData' can sync only On foot values.
I think VCMP automatically set player state and position from the last sync packet if new packets are not received for some time.
So syncing npc then require either 1. One vehicle sync packet or 2. Continous vehicle sync packets.

In current version as mentioned before, sending vehicle sync packets directly is not possible.

Server getting no vehicle sync packets from npc may be the reason of player.Vehicle value equal null.

SetMyPos function will fail too because it sends On-Foot update packets only.

This issue needs to be taken care in the next version.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Yyg on Dec 20, 2022, 04:04 AM
Quote from: habi on Dec 19, 2022, 08:15 AM
Quote from: Yyg on Dec 12, 2022, 08:07 AMHello Habi, the new NPC features are very interesting!

But I still have a few issues, I try to get the NPC to sit in my car (player.PutInVehicleSlot), it seems to work, but the NPC will no longer do a stream update (Pos locked) and when I drive the car a certain distance, the NPC will disappear and return to the point where it was boarded.d player.Pos stays in the boarding Position
It seems impossible to do a "on-board" Update Vehicle Pos in NPCScript, and when I try something like SetMyPos(), the NPC just leaves the vehicle.

Maybe I'm getting something wrong, but are there any examples where an NPC can get in my car, no matter where I drive it?
Thank you Yyg. I understand the problem with putting NPCs inside Vehicles.
We have not implemented this feature it. Syncing NPC in vehicle needs a new function as the existing function 'SendOnFootSyncData' can sync only On foot values.
I think VCMP automatically set player state and position from the last sync packet if new packets are not received for some time.
So syncing npc then require either 1. One vehicle sync packet or 2. Continous vehicle sync packets.

In current version as mentioned before, sending vehicle sync packets directly is not possible.

Server getting no vehicle sync packets from npc may be the reason of player.Vehicle value equal null.

SetMyPos function will fail too because it sends On-Foot update packets only.

This issue needs to be taken care in the next version.
Thanks Habi, great feat! This could be very interesting
Thanks also to Sebastian for his answer

Good Luck!
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Mikimon on Dec 20, 2022, 07:35 AM
Hello Habi. Im facing an issue when I start server with a recording which i made using a custom weapon. Seems when the NPCs receives the custom wep they got disconnected. Do you have any clue? :'(

https://imgbb.com/YNHCRf3
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Dec 20, 2022, 05:06 PM
Quote from: Mikimon on Dec 20, 2022, 07:35 AMHello Habi. Im facing an issue when I start server with a recording which i made using a custom weapon. Seems when the NPCs receives the custom wep they got disconnected. Do you have any clue? :'(
It is because npc is sending packets to server containing weapon which was not allocated to it by Server. You can add the custom weapon id 100 in the npc's class (server.conf or AddPlayerClass). Or try player.SetWeapon on onPlayerSpawn or onPlayerRequestSpawn.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Gulk on Dec 21, 2022, 02:02 AM
@Mikimon another option would be adding the line

anticheat 0

to server.cfg
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Dec 23, 2022, 10:18 AM
I have built a patch for npc's not remaining inside vehicle as passengers.
Now, the npc program will understand server's PutInVehicleSlot command and sends passenger sync. It also updates npc's position (locally so that it can be get inside npcscripts) (server will update npc's position to that of vehicle once the sync arrives).
(https://i.imgur.com/ZqpzK3h.png)
also it no more returns 'null' on player.Vehicle
(https://i.imgur.com/ZAUUQWq.png)

Now npc remain seated inside the vehicle as passenger and do not go back.

It took me to examine the passenger sync packets of server/client, the intervals in which they are send.

Once again, now passenger syncs are automatically send. However two new functions are added 'SendPassengerSyncData' and 'SetPSLimit' through which you can disable automatic passenger syncing and specify manual if necessary( for high accuracy maybe ).

Other changes
Better health and armour syncing
OnPlayerUpdate gets called for PLAYERUPDATE_PASSENGER
Team and SkinIds of players can be get.

Downloads links
Windows npcclient-v1.5-patch1-setup.exe (https://sourceforge.net/projects/npc-for-vcmp/files/npcclient-v1.5-patch1-setup.exe/download) (sourceforge.net 12.0 MB ) (includes VC_redist.x86.exe)
Linux x64 npc_vcmp_linux_x64_v1.5_patch1.tar.gz (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_linux_x64_v1.5_patch1.tar.gz/download) ( "
 802 KB)
Linux x86 npc_vcmp_linux_x86_v1.5_patch1.tar.gz (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_linux_x86_v1.5_patch1.tar.gz/download) ( " 876 KB)

If you have version 1.5, it is enough to download the new binary below:
npc_vcmp_binaries_v1.5_patch1.zip (https://dl.dropboxusercontent.com/s/i3hvz2sgkpv73am/npc_vcmp_binaries_v1.5_patch1.zip) (Contains npcclient.exe and recupdate.exe) (262 KB Dropbox)

npc_vcmp_binaries_v1.5_patch1_linux_x64.zip (https://dl.dropboxusercontent.com/s/uykhteszjf2zt16/npc_vcmp_binaries_v1.5_patch1_linux_x64.zip) (732 KB " )

npc_vcmp_binaries_v1.5_patch1_linux_x86.zip (https://dl.dropboxusercontent.com/s/4bj2jcvmsq0xw5m/npc_vcmp_binaries_v1.5_patch1_linux_x86.zip?dl=0) (806KB " )
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Yyg on Dec 23, 2022, 01:07 PM
Good release!
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Dec 24, 2022, 05:50 PM
A quick patch for getting console inputs.
(https://i.imgur.com/xiGb6Nk.png)

Note that the following functions have an additional parameter (true/false) to enable console input now.
ConnectNPC, ConnectNPCEx

The npcscripts have callback
function OnConsoleInput( text ){ }

Binaries (only) - npc-vcmp-1.5-patch2-all-binaries.zip (https://dl.dropboxusercontent.com/s/jd8qc0idyks3oob/npc-vcmp-1.5-patch2-all-binaries.zip) (linux, windows, x86, x64) (4MB Dropbox)
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Sebastian on Dec 25, 2022, 11:30 AM
Quick fix! Thank you habi!
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Jan 12, 2023, 03:57 AM
Another version has been released few days back. V 1.6 alpha( view release notes ) (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_6_alpha_release_notes)

QuoteWhat is new?
>Support for both rel004 and rel006 servers
>NPC now can send vehicle syncs (as driver)
>Introduced npc-plugins which can be loaded with the program.
>Added Vector, Quaternion classes and updated parameters of few functions which are using them.

chit-chat
My idea of plugins is to create three plugins- one of them will automatically reduce health of npc if a player shoots him, another will add function like ShootPlayer (or set_npc_kill_player ) to the npcscript or serverscript so that npc attacks player without the use of timers and all. However, all this needs another update since in this alpha version, squirrel vm (the famous, HSQUIRRELVM v was not exported.)
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Chicken on Jan 14, 2023, 10:55 AM
Good Plugins habi,but  It would be great if this plugin can be used without occupying Max player, and I think less than 100 NPCs is not enough to satisfy developers
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Jan 14, 2023, 12:44 PM
Thanks Chicken. However, there is no way to save player slots.

Npcs can be hidden from the VCMP Browser. see here (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/NPC_HIDE)

Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Sebastian on Jan 14, 2023, 07:21 PM
Quote from: habi on Jan 14, 2023, 12:44 PMThanks Chicken. However, there is no way to save player slots.

Npcs can be hidden from the VCMP Browser. see here (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/NPC_HIDE)

This is truly cool! Now server owners cannot be accused for faking players count anymore :o
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Chicken on Jan 14, 2023, 09:36 PM
Quote from: habi on Jan 14, 2023, 12:44 PMThanks Chicken. However, there is no way to save player slots.

Npcs can be hidden from the VCMP Browser. see here (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/NPC_HIDE)


I have tried, using the HideNPC plugin, NPC will not display it on the browser, but it will still be counted as a player in the server
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Jan 15, 2023, 02:00 AM
Quote from: Sebastian on Jan 14, 2023, 07:21 PMThis is truly cool! Now server owners cannot be accused for faking players count anymore :o
Thanks and in the next version of npc04relxx, it can set the max player in browser, to an integer.

Quote from: Chicken on Jan 14, 2023, 09:36 PMI have tried, using the HideNPC plugin, NPC will not display it on the browser, but it will still be counted as a player in the server
Mm. But if you are good at GUI, you can make your own GUI on F5. (Keybinding). Also, disabling nametags (and probably creating custom one for players). Death messages and connection messages also could be disabled and manual one used.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Jan 17, 2023, 02:58 PM
Small update..Introduction of a module
It is weird that when you hit an npc with fists, hammer, baseball bat, etc nothing happens to npc. So i made something - a dll that it automatically takes care of it.

Put the file npcmodule.dll in npcscripts/plugins folder ( Create plugins folder if not exists )

and

ConnectNPC("[npc]tk123", "", false, "", "npcmodule");
The module take care of attack to npc from other players. It also sends a command /iamunderattack pid where pid is the id of the player who attacked, to the server. 

If npc is attacked with a gun, still it sends the message(command), but i have decided to avoid decrease of health as it is very complicated. You can do it in server side if you wish.


Module and binary (You must have 'v1.6 alpha' beforehand): npc-vcmp-1.6-alpha-patch.zip (https://www.mediafire.com/file/f0yjmf940fste5z/npc-vcmp-1.6-alpha-patch.zip/file) (4.15 MB)

module source: npcmodule.zip (https://www.mediafire.com/file/ux8ko7n0gpilxng/npcmodule.zip/file)

Changelog v1.6-alpha-patch
There is no change, except in plugin header. It can be viewed from module source. Squirrel VM is now exported.
Note: In Linux, the command to connect changes to
ConnectNPC("[npc]some_guy", "", false, "", "npcmodule64.so");  //extension .so is required
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Mikimon on Mar 07, 2023, 04:09 PM
Habi bro, Im having an issue. This is pterodactyl panel

(https://i.ibb.co/jLzG2fy/habi.png)

Can you help me pls?  ::)
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Mar 08, 2023, 12:02 PM
Quote from: Mikimon on Mar 07, 2023, 04:09 PMHabi bro, Im having an issue. This is pterodactyl panel
...
The index 'ConnectNPC' does not exist.
Hi Mikimon, i think the so called plugin 'npc04relxx' is not loaded in your panel. Did you forget to add to plugins line in server.cfg?
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Mar 13, 2023, 09:50 AM
v.1.6 beta3 released on last month.
Link: Relase Notes and Downloads (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_6_beta3_release_notes)
Quote1.6 beta 2
*Now Vector.Length() and Vector.Normalized() functions to get magnitude and normalized copy of vector respectively.
*Added fields for SetLocalValue, GetLocalValue: V_ONFOOT_SPEED, V_AIMPOS, V_AIMDIR, V_POS, Q_CAR_ROTATION,
F_CAR_HEALTH, I_CAR_DAMAGE, V_CAR_SPEED, F_CAR_TURRETX, F_CAR_TURRETY.
*Bug fixed for function 'EnterVehicle'
*Bug fixed npc getting kicked for 'acquiring weapon' when exiting vehicle.
1.6 beta
*Supports reading and writing ServerData(Streams)
*LibRPC (Remote Procedure Calls) module available and included in npcscripts/plugins so that functions of NPC can be called from Server side( See RFC (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/RFC), F )
*Fixed a major bug while using ConsoleInput in linux( program would wait indefinitely unless Enter key is pressed )
*The functions of npc04relxx are exported.
*NPC dies if health set to zero from server
*NPC can attack player with guns with a single function ShootPlayer, added by the module LibAction (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/LibAction).

Example:
RFC(0, "QuitServer")()This code is in scripts/main.nut.  It will execute the function 'QuitServer' in npc with id 0. As a result,  that npc disconnect itself. This is Remote Call Procedure.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Mar 30, 2023, 07:43 AM
Linux plugin to connect npc's have an issue:
QuoteThe index 'ConnectNPC' does not exist.

This is fixed
Download npc04rel64.so (https://www.mediafire.com/file/i8paet4h68uixn2/npc04rel64.so/file)
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Kenneth Law on May 20, 2023, 09:24 AM
habi!! I'd like to say you really did a good job as you are more than making NPCs for VCMP. It contributes a lot to my plan of creating a completely new way for gameplay that has never existed in VCMP! What I mean is that does any of you still remember a mission in single-player in which Lance drives a helicopter towards Prawn Island with Tommy standing beside as a turret? Yeah that's the thing where habi's NPC system takes effect. I believe that with the help of NPC, the function can soon be made come true in my server (Extreme Racing). You guys may be curious about what the hell at all relation it has with NPC? But it's not the point. The point is that it'll soon be possible for players to experience the scene of smoothly firing from a flying helicopter regardless of any potential issues like lags, sync, etc. Thanks to habi again for his NPC system since it really plays a very important part in the process. It is expected that the project will be finished within 1 or 2 months. Hope you guys could join my server for a try the time when it's done.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Chicken on May 20, 2023, 07:26 PM
Hey habi, I used the SetMaxPlayersOut function, but I'm not sure what this function is for. Is it used to exceed the maxplayer slot? However,  I use this function, the server directly crashes.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on May 20, 2023, 08:22 PM
Quote from: Chicken on May 20, 2023, 07:26 PMHey habi, I used the SetMaxPlayersOut function, but I'm not sure what this function is for. Is it used to exceed the maxplayer slot? However,  I use this function, the server directly crashes.
This issue was fixed. You need to download NPCHide(v3) (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/NPC_HIDE) and latest npc04relxx (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_6_beta4_release_notes). Put both in plugins folder and then it will not crash.

SetMaxPlayersOut is not used to exceed the maxplayer slot, but to show it decreased in server browser.
"Suppose you have 10 npcs in server. When you hide npc from browser, it will show ( total players - 10 ) in browser. This later can create problem such as 20/30. Players cannot join because it is already 30 ( 20 + 10 npc ). To avoid these problem, we use SetMaxPlayersOut( 20 ). So 20 actual players can join 20/20.

Example:
SetMaxPlayersOut( 10 );
(https://i.imgur.com/OL4bSMG.png)
To change the maximum players 'as shown by the browser'.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on May 20, 2023, 08:28 PM
Quote from: Kenneth Law on May 20, 2023, 09:24 AMhabi!! I'd like to say you really did a good job as you are more than making NPCs for VCMP. It contributes a lot to my plan of creating a completely new way for gameplay that has never existed in VCMP! What I mean is that does any of you still remember a mission in single-player in which Lance drives a helicopter towards Prawn Island with Tommy standing beside as a turret? Yeah that's the thing where habi's NPC system takes effect. I believe that with the help of NPC, the function can soon be made come true in my server (Extreme Racing). You guys may be curious about what the hell at all relation it has with NPC? But it's not the point. The point is that it'll soon be possible for players to experience the scene of smoothly firing from a flying helicopter regardless of any potential issues like lags, sync, etc. Thanks to habi again for his NPC system since it really plays a very important part in the process. It is expected that the project will be finished within 1 or 2 months. Hope you guys could join my server for a try the time when it's done.
Thank you Kenneth Law. I wish you good luck with your project.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Chicken on May 22, 2023, 01:05 PM
Habi, I want to ask a question, if  NPC dies, I want to respawn it, but I add player.spwan(); in the event onPlayerRequestClass does not work, why? How to do?
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on May 23, 2023, 03:28 PM
Quote from: Chicken on May 22, 2023, 01:05 PMHabi, I want to ask a question, if  NPC dies, I want to respawn it, but I add player.spwan(); in the event onPlayerRequestClass does not work, why? How to do?

Chicken, currently they do not have the function to request class and spawn. I will add these functions so that when dead, they can spawn again.


Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: Chicken on May 23, 2023, 05:36 PM
Quote from: habi on May 23, 2023, 03:28 PM
Quote from: Chicken on May 22, 2023, 01:05 PMHabi, I want to ask a question, if  NPC dies, I want to respawn it, but I add player.spwan(); in the event onPlayerRequestClass does not work, why? How to do?

Chicken, currently they do not have the function to request class and spawn. I will add these functions so that when dead, they can spawn again.



OKay,You're great now. npc plugin is the best plugin,My friend
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on May 25, 2023, 07:34 PM
v1.6 beta4 patch2
-Now npc can select class and spawn.
Download
Windows npc_vcmp_rel006_windows_v1.6-beta5.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_windows_v1.6-beta5.zip/download) (Updated to beta 5)
Linux npc_vcmp_rel006_linux_x64_v1.6-beta5.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x64_v1.6-beta5.zip/download) (Updated to beta 5)

You can use player.Spawn() from serverside also.

After spawning him, if you see health not correct like this:
(https://i.imgur.com/9LkVkml.png)
Then do on server script:
//  scripts/main.nut
function onPlayerSpawn(player){if(IsPlayerNPC(player.ID))NewTimer("update",500,1,player.ID);}
function update(id){local p=FindPlayer(id);if(p)p.Pos=p.Pos;}

(https://i.imgur.com/YFSKRPZ.png)

More information on this patch: release notes of beta4 (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_6_beta4_release_notes)
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: PSL on Jun 01, 2023, 03:45 PM
My God, Habi brother, the NPC plugin you made is really powerful, I placed several NPCS in the city and recorded the action in advance, this effect is great, your plugin has more powerful functions, I will continue to study your plugin, to improve my server, in short, I think you are a talent.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: habi on Jun 25, 2023, 06:14 PM
i am making an installer-interface for windows:
(https://i.imgur.com/AySgKib.png) 
(https://i.imgur.com/jUglCJI.png)
(https://i.imgur.com/2fHtWK3.png)
so that newbies can go ahead without much trouble.

Will be available in next version.
Title: Re: NPC implementation in VCMP 0.4 Servers
Post by: vitovc on Jul 03, 2023, 11:52 AM
Thanks for making version for rel004. I were planned to buy ryzen PC to host bots for my project but with your plugin I can host bots directly on linux server with low usage of CPU and no GPU at all. You are awesome.

(https://i.imgur.com/xScd7O0.png)
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Aug 24, 2023, 10:23 AM
News: v1.7 beta released

Changelog

Downloads
Windowsnpc_vcmp_rel006_windows_v1.7-beta.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_windows_v1.7-beta.zip/download)
Linux x64npc_vcmp_rel006_linux_x64_v1.7-beta.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x64_v1.7-beta.zip/download)
Linux x86npc_vcmp_rel006_linux_x86_v1.7-beta.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x86_v1.7-beta.zip/download)
Windows/Linux (rel004)npc_vcmp_rel004_win_lin_v1.7-beta.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel004_win_lin_v1.7-beta.zip/download)
Windows Setupnpcclient-setup-v1.7-beta.exe (https://sourceforge.net/projects/npc-for-vcmp/files/npcclient-setup-v1.7-beta.exe/download)
Source CodeNPC-VCMP-master-v1.7-beta.zip (https://sourceforge.net/projects/npc-for-vcmp/files/NPC-VCMP-master-v1.7-beta.zip/download)
API Plugin (v1.5)npc_vcmp_plugin_API_1_5.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_plugin_API_1_5.zip/download)

New Functions
Callbacks/Events
*above documentation generated by cgpt.

Note: Ensure to report any bugs or issues you encounter during usage.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Aug 28, 2023, 07:14 AM
NPCClient v1.7 Beta 2 Released

We're excited to announce the release of NPCClient v1.7 Beta 2! This new version comes with various improvements and enhancements to make your experience even better.

You can check out the detailed release notes on the V1.7 Beta 2 Release Notes (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_7_beta2_release_notes) page for more information about the changes and new features.
Quote
  • New field I_ACTION added for GetLocalValue and SetLocalValue for getting/setting action of npc.
  • Fixed serious bug in RECORDING PLAYER ACTION i.e. in StartRecordingPlayerData, which showed error when playing .rec files (message version different). Now VERSION of .rec files is 4. Use recupdate to convert old playback recordings.
  • npc's can now exit vehicle properly (ExitVehicle, ExitVehicleEx).
  • In windows builds, pressing Ctrl+C will effect /q to server and npcclient client disconnect properly.
  • Changed KEY_ONFOOT_JUMP to 2048 from 2176, because of the latter not causing npc to jump.
  • The playback recordings (onfoot) now records player Action and will reproduce on playback with an npc.


Please give it a try and let us know your feedback. Your input is invaluable in making NPCClient even better. Thank you for your continued support!

The NPCClient Team
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Sep 26, 2023, 06:55 AM
I tried to delete the shot timer, after deleting it, the npc kept shooting but wouldn't aim at me, how do I get him to cancel the shot?
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Sep 26, 2023, 07:00 AM
This is my script code,It did remove the timer after 90 meters from the NPC, but it was still firing。
function OnNPCScriptLoad(params)
{
    shootwaittimer=SetTimer("ShootTimer",2000,1);
}
function ShootTimer()
{
    local x=0;
    while(x!=MAX_PLAYERS)
    {
        if(IsPlayerConnected(x))
        {
            if(IsPlayerStreamedIn(x))
            {
                local pos=GetPlayerPos(x);
                if(GetDistanceFromMeToPoint(pos)<=90.0)
                {
                    KillTimer(shootwaittimer);
                    shootwaittimer=null;

                    StartShoot(x);
                    break;
                }
            }
        }
        x+=1;
    }
}

function ShootPlayer(pid)
{
    if(IsPlayerStreamedIn(pid)&&GetPlayerState(pid)!=PLAYER_STATE_WASTED)
    {
        local pos=GetPlayerPos(pid),weapon=GetPlayerArmedWeapon(npcid);
        if(GetDistanceFromMeToPoint(pos)<90.0)
        {
            local now=GetTickCount();
            if(!isReloading||now-last_fired>=1000)
            {
                isReloading=false; //Checking interval between 2 bullets. In milliseconds.
                if(now-last_fired>=150) // 150ms is firing rate of rifle ruger
                {
                    //Decrease Ammo by One.
                    local NewAmmo=GetLocalValue(I_CURWEP_AMMO)-1;
                    if(NewAmmo<=0) NewAmmo=1; //fool the server
                       
                    SetLocalValue(I_CURWEP_AMMO,NewAmmo);
                    ShootAt(pos);
                    bullets_fired++;
                    if(bullets_fired%30==0) isReloading=true; //rifle has 30 bullets in one catridge
                    last_fired=now;    //Store tick
                }
                else SendOnFootSyncDataLV(); //Send a packet,same as last one. (for Sync Issues)
            }
            else ShootAt(pos,true); //still reloading... Call function 'ShootAt' with 'isReloading' as 'true'
        }
        else StopShoot();
    }
    else StopShoot();
}
function StartShoot(shootid)
{
    shottimer=SetTimerEx("ShootPlayer",60,0,shootid);
}
function StopShoot()
{
    KillTimer(shottimer);
    shottimer=null;
    shootwaittimer=SetTimer("ShootTimer",2000,1);
}
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Sep 26, 2023, 01:35 PM
I will check it evening.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Sep 26, 2023, 03:21 PM
Your code is working when i tested. When i am inside 90 meters, it shoots me. When i am outside 90 meters, it stops.
See when i moved away 90 meters, it stopped shooting.
(https://i.imgur.com/ses7e4W.jpg)
npcscripts/attack_psl.nut
local shootwaittimer;
local npcid;
local isReloading=false;
local last_fired=0;
local shottimer;
local bullets_fired=0;
//Shoot at a point. Most important function
function ShootAt(tPos, isReloading = false, isHeadShot=false)
{
if(isHeadShot)tPos.z+=0.627299;
local Pos= GetMyPos();
local angle= atan2(-(tPos.x-Pos.x), tPos.y-Pos.y);
local aimPos= Vector(tPos.x,tPos.y,tPos.z);
local aimDir = Vector( PI, PI, -angle );
local keys= KEY_ONFOOT_FIRE ;
SetLocalValue(I_KEYS, keys );
local ammo = GetLocalValue(I_CURWEP_AMMO );
SendOnFootSyncData( keys, Pos.x,Pos.y, Pos.z, angle, GetPlayerHealth( npcid ), GetPlayerArmour( npcid ), GetPlayerArmedWeapon( npcid ),ammo, 0.0, 0.0, 0.0, aimPos.x, aimPos.y, aimPos.z, PI, PI, -angle, false, isReloading );
}
function OnNPCConnect(myplayerid)
{
    npcid=myplayerid;
}
function OnNPCScriptLoad(params)
{
    shootwaittimer=SetTimer("ShootTimer",2000,1);
}
function ShootTimer()
{
    local x=0;
    while(x!=MAX_PLAYERS)
    {
        if(IsPlayerConnected(x))
        {
            if(IsPlayerStreamedIn(x))
            {
                local pos=GetPlayerPos(x);
                if(GetDistanceFromMeToPoint(pos)<=90.0)
                {
                    KillTimer(shootwaittimer);
                    shootwaittimer=null;

                    StartShoot(x);
                    break;
                }
            }
        }
        x+=1;
    }
}

function ShootPlayer(pid)
{
    if(IsPlayerStreamedIn(pid)&&GetPlayerState(pid)!=PLAYER_STATE_WASTED)
    {
        local pos=GetPlayerPos(pid),weapon=GetPlayerArmedWeapon(npcid);
        if(GetDistanceFromMeToPoint(pos)<90.0)
        {
            local now=GetTickCount();
            if(!isReloading||now-last_fired>=1000)
            {
                isReloading=false; //Checking interval between 2 bullets. In milliseconds.
                if(now-last_fired>=150) // 150ms is firing rate of rifle ruger
                {
                    //Decrease Ammo by One.
                    local NewAmmo=GetLocalValue(I_CURWEP_AMMO)-1;
                    if(NewAmmo<=0) NewAmmo=1; //fool the server
                       
                    SetLocalValue(I_CURWEP_AMMO,NewAmmo);
                    ShootAt(pos);
                    bullets_fired++;
                    if(bullets_fired%30==0) isReloading=true; //rifle has 30 bullets in one catridge
                    last_fired=now;    //Store tick
                }
                else SendOnFootSyncDataLV(); //Send a packet,same as last one. (for Sync Issues)
            }
            else ShootAt(pos,true); //still reloading... Call function 'ShootAt' with 'isReloading' as 'true'
        }
        else StopShoot();
    }
    else StopShoot();
}
function StartShoot(shootid)
{
    shottimer=SetTimerEx("ShootPlayer",60,0,shootid);
}
function StopShoot()
{
    KillTimer(shottimer);
    shottimer=null;
    shootwaittimer=SetTimer("ShootTimer",2000,1);
}
scripts/main.nut
ConnectNPC("habi","attack_psl.nut",true)
How i measured 90 meter distance:
npcconsole:
(https://i.imgur.com/BkhwAVD.png)
When npcid is 0 and my id is 1
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Sep 27, 2023, 08:25 AM
I used the above script, but as before, when I left the range, it always shot at the last point, when I entered the range, it still aimed at me normally, I tried to send a command to clear the weapon when I turned off the timer, but it still didn't work, I was using version 1.7, or maybe there was a problem with the system。

pic: https://img1.imgtp.com/2023/09/27/tjpLHgP4.png
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Sep 27, 2023, 03:20 PM
I think this will solve the problem:
local KEY_NONE=0;
function StopShoot()
{
    ...
    shootwaittimer=
    ...
    SetLocalValue(I_KEYS, KEY_NONE); //Set NPC to non-shooting mode
    SendOnFootSyncDataLV();
}
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Sep 27, 2023, 03:27 PM
Oh my God, this problem is solved, thank you so much, now npc can stop shooting normally, your plugin is great.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Sep 27, 2023, 03:51 PM
you are welcome.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Oct 01, 2023, 11:55 AM
Hi Habi. After I added armor to the NPC after respawn, the NPC got kicked. The probability of this phenomenon is relatively high.
Console display:
Kicking player 'NPC_pq' (0), armour increased from 0 to 50.
Player 'NPC_pq' ID 0 disconnected (kicked).
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Oct 01, 2023, 01:10 PM
Hi PSL, could you provide more info?
I tried four times killing npc by player.Health=0 then respawned by RequestSpawn() as well as player.Spawn(). Then i set player.Armour=50 and nothing happened except it got half  armour.

Are you using latest version v1.7 beta 2 ?

Was it after playback recording using .rec files ?

Thank you
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Oct 01, 2023, 03:43 PM
Hi Habi, This is the relevant code, in the main script. If you need any more information, please let me know.
When I opened the server, the npc joined, and the npc resurrected and got kicked for adding armor. NPC are kicked when they first enter the server and add armor after they spawn.
I'm sure I'm using v1.7 beta 2, I didn't add a recording to the npc.
Screenshot of console when error occurs:https://img1.imgtp.com/2023/10/01/r7y4Xra2.png
The npc's console sent a message that it had been resurrected before it was shut down.
function onScriptLoad()
{
     ConnectNPC("NPC_pq","npctest.nut",true,"127.0.0.1","rpclib z-finder");
}
function onPlayerJoin(player)
{
    if(IsPlayerNPC(player.ID)==true)  onNPCJoin(player.ID);
}

function onNPCJoin(i)
{
    local plr=FindPlayer(i);
    if(plr)
    {
        plr.IsAdmin=true;
        state[plr.ID].isnpc=true;
    }
}

function onPlayerRequestClass(player,classID,team,skin)
{
     if(state[player.ID].isnpc==true) player.Spawn();
}
function onPlayerSpawn(player)
{
    if(state[player.ID].isnpc==true) onNPCSpawn(player.ID);
}

function onNPCSpawn(i)
{
    local plr=FindPlayer(i);
    if(plr)
    {
        plr.Pos=NPCPos[plr.ID];
        plr.Skin=1;
        plr.Armour=50; //kick in here
        plr.Colour=RGB(255,255,0);
        plr.GiveWeapon(22,9999);
        NewTimer("update",500,1,plr.ID);
    }
}

function update(id)
{
    local p=FindPlayer(id);
    if(p)
    {
        if(p.IsSpawned==true)
        {
            p.Pos=p.Pos;
        }
    }
}
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Oct 01, 2023, 03:55 PM
I then found something useful, this is my cfg file, I have seen before in other server scripts to add the code anticheat 0, I also tried to add this code, I found that I started nearly 10 times without the NPC being kicked, and I deleted this line rule, Two out of five booting sessions an NPC gets kicked.
plugins announce04rel64 mmdb04rel64 httprequest04rel64 mysql04rel64 npc04rel64 logfile64 remexec04rel64 cmdinputrel64 miamiscale04rel64 squirrel04rel64
sqgamemode scripts/主脚本.nut
port 8192
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Oct 01, 2023, 04:40 PM
Hi, thank you for providing me the code.

I tried several times. But npc was not kicked each time. Same script except i created stats array with isnpc field and vector NPCPos.

Is it possible to take a screenshot of npcconsole when it gets kicked?

I will investigate the issue deeply tomorrow.

About anticheat, i did not add line in server. cfg

If armour is the problem the  you can put it in a timer
function onNPCSpawn(i)
{
..
NewTimer("shield", 500, 1, plr.ID, 50);
plr.Colour= .
..
}
function shield(id, amount)
{
local plr=FindPlayer(id);
if(plr && plr.IsNPC)plr.Armour=amount;
}
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Oct 01, 2023, 11:56 PM
Hi Habi, The npc console was shut down in less than 0.5 seconds, I have a screenshot of it before the shutdown, as well as some screenshots of the script。 https://postimg.cc/gallery/ygmpBbF
I didn't add armor before because the NPC had m4, now I added armor because the NPC had TEC-9, and then there was this problem, thanks for the idea, the timer is a good way to do it。
There is a NPCtimerEX timer in the NPC script, which controls the NPC's shooting and running, but it will not be executed without the player, I think there is no scripting error in this part of the script.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Oct 02, 2023, 01:06 PM
Hi PSL, i thought so much but still could not figure where is the problem.

Can you provide me dumpfile.pcap which i can analyse to findout the cause of the kick?

It is simple process. I will explain step by step. I hope it will not trouble you.
1. Download and install Loopback Adapter from https://npcap.com/ (Downloads-> Npcap 1.77 installer for Windows )
(while installing just click next, next and finish )
2. This great tool https://www.netresec.com/?page=RawCap which will capture traffic.
3. Now open command prompt and navigate to the folder containing rawcap.exe
rawcap 127.0.0.1 dumpfile.pcap-127.0.0.1 is always the address of Loopback adapter
-This will start sniffing
4. (https://i.imgur.com/85s3Q7L.png)
Do not press Ctrl+C yet
5. Start VCMP Server. NPC will connect and will get kicked.( if npc is not kicked, you can restart server again )
6. Now npc is kicked, close the server and comeback to rawcap console and press Ctrl+C
7. Hopefully you get a file dumpfile.pcap which contains cause of kicking npc.
Share dumpfile.pcap with me and i will examine the traffic towards npc to find out the problem.


Also could you check if this fixes the problem:
Quotefunction onPlayerRequestClass(player,classID,team,skin)
{
    if(state[player.ID].isnpc==true)return true;
}
function onPlayerRequestSpawn(player)
{
    if(state[player.ID].isnpc==true)return true;
}
function onPlayerSpawn(player)
{
    if(state[player.ID].isnpc==true) onNPCSpawn(player.ID);
}
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Oct 02, 2023, 02:55 PM
Hi Habi, I did what you told me to do, and I was lucky enough to catch a kick the first time. I hope this was helpful.
Not only armor, increasing health will also result in being kicked, because I set up, after killing people to increase health, NPC health increased from 94 to 100, the NPC was kicked, the increase in health is done in the server onPlayerKill event.
I will try to catch this health increase kicked error, if there is I will change this post.
File link: https://file.io/yomPhPTtRbob
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Oct 02, 2023, 03:09 PM
Thank you PSL, i am happy that you were able to record the traffic.
That will contain enough information. I will be working on it soon. thank you again
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Oct 03, 2023, 05:18 AM
Oh God, when i closely examined the file, the bug was before my eyes. It took me one minute only to fix it.

Here is a fixed version for you. Please replace the executable with the following one and tell me if the problem is fixed.
npcclient-fix.7z (https://www.mediafire.com/file/c9of3qgb87785c3/npcclient-fix.7z/file)

thank you.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Oct 03, 2023, 06:08 AM
HI Habi, Thank you very much, I used the version without timer, that is, I originally sent the code to be kicked, after using this did not happen to be kicked, the NPC was never kicked from the beginning to the end, the problem has been fixed.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Oct 03, 2023, 06:44 AM
You're welcome! I'm glad to hear that the issue has been resolved and that the NPC is no longer getting kicked.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Oct 08, 2023, 08:34 AM
NPC v1.7 Beta 3 Released - Changelog

QuoteFixed NPC getting kicked when setting armor/health/weapon from server-side

Download Links:
rel006
Windows:    Windows-installer (https://sourceforge.net/projects/npc-for-vcmp/files/npcclient-setup-v1.7-beta3.exe/download)           binary-zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_windows_v1.7-beta3.zip/download)

Linux x64 (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x64_v1.7-beta3.zip/download)    Linux x86 (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x86_v1.7-beta3.zip/download)    source (https://sourceforge.net/projects/npc-for-vcmp/files/NPC-VCMP-master-v1.7-beta3.zip/download)   

rel004
Windows+Linux: binaries (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel004_win_lin_v1.7-beta3.zip/download) 


Release Notes: V1.7 Beta 3 Release Notes (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_7_beta3_release_notes)

It's not a major release, but the significant bug has been fixed.
Title: Re: Npc playback file editor
Post by: habi on Oct 17, 2023, 12:14 PM
(https://i.imgur.com/TpI5R9M.png)



Introducing the 'NPC Playback File Editor' - Your Ultimate .REC File Tool!

Dear Community,

We are thrilled to present the 'NPC Playback File Editor,' your essential Windows tool for playback recording files (.rec files). This playback file are usually created by StartRecordingPlayerData. This software lets you effortlessly view, edit, modify, export to Excel, and import .rec files with a simple drag-and-drop feature.

Key Features:

Unlock the full potential of your recorded data with the 'NPC Playback File Editor.'

How to Get Started:


Download now (https://www.mediafire.com/file/bt7q3a6e8gs1m1e/recEdit.zip/file) and elevate your .rec file handling!

Best Regards,
habi
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Oct 21, 2023, 01:58 PM
Well done, Habi That'll be can see clearly.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Dec 18, 2023, 05:09 AM
Habi, NPC Wiki is 404 :C
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi on Dec 18, 2023, 08:55 AM
Thankyou PSL, it was database problem and is now solved.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 03, 2024, 05:39 AM
Hello, habi. Can you update the save location of the recording file?  I want to save it directly in the npcscripts/recordings folder, so that it can be played back directly, without manually copying the past.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 03, 2024, 09:48 AM
Oh, my God, this is not simple.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 05, 2024, 08:08 AM
This is very nice and just what I needed, thanks to habi, the author of the NPC plugin.I'm looking forward to the next update.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 12, 2024, 06:49 AM
HI, Habi, When I raced with the recorded car playback, the recorded car always accelerated slower than me in a straight line, even though I was accelerating at full speed while recording, is there a way to solve the problem of slow recording cars.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 14, 2024, 04:50 PM
Hi PSL thank you for reporting the issue.
This is a video of me racing with npc:
Video (https://www.dropbox.com/scl/fi/wr8zxq7ht7zvhfxgtwf6c/avc_gta-vc-2024-02-14-21-27-58-843.mp4?raw=1&e=1&rlkey=cg744xu7vg4l493n18v34qril)
As you can see, the npc car is racing ahead of me at full speed.

Was the server run on your pc or remote computer?
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 15, 2024, 04:01 AM
Hi Habi, I saw your video, In the video you catch up with your video playback, That means the vehicle speed of the replay is slower,   I made a server that can race against NPCS, I'll advertise the server elsewhere. I ran 1:30 in the driver legend myself, but my replay ran 1:40, I can always catch up with my replay, So you figure out a way to make the playback vehicle faster.

My server is running on a remote computer.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 16, 2024, 06:24 PM
Hi PSL, can you confirm if this release candidates of v1.8 beta solves the issue of car not accelerating.

windows (https://www.dropbox.com/scl/fi/2kct4pab81x2t6i70itg3/npc_vcmp_rel006_windows_v1.8-beta.zip?rlkey=gt9h1hrtwmx56ukcjmz0n8v4p&dl=0)
linux-x64 (https://www.dropbox.com/scl/fi/b27nh2016e1x2t3o8385h/npc_vcmp_rel006_linux_x64_v1.8-beta.zip?rlkey=cqiuec0tbbmcnpp6ed1nnbv21&dl=0)
linux-86 (https://www.dropbox.com/scl/fi/kwez5m09jhk2xa3ls439a/npc_vcmp_rel006_linux_x86_v1.8-beta.zip?rlkey=bvfh6e2qnva9nwi482jk1buqf&dl=0)
rel004 (https://www.dropbox.com/scl/fi/tggnaydvqdp1oj88w2yxv/npc_vcmp_rel004_win_lin_v1.8-beta.zip?rlkey=o8ncpsknaoa9unk94xnfc7dtx&dl=0)
source-1.8-beta-zip (https://www.dropbox.com/scl/fi/6ta03jsdj3845jflzazhu/NPC-VCMP-master-v1.8-beta.zip?rlkey=b81flkp67b7mzhs26bis53ony&dl=0)
setup (installer) (https://www.dropbox.com/scl/fi/ctn1pmter1gyrollqlc53/npcclient-setup-v1.8-beta.exe?rlkey=ew1tnjubbo1zd6mgbcoe0xkm5&dl=0)

Also thanks for confirming about location of server.

I decreased sleep time between cycles from 30 to 5 ms and found that cars are accelerating without lags. Also the time taken by npc to omplete the race now matches against the original time.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 17, 2024, 04:02 AM
HI Habi, I tried this version and the vehicle playback speed is almost exactly the same as the original speed, the vehicle playback speed issue has been fixed. Thank you for fixing this little bug. I really appreciate your update.
I found a problem in testing this version. When I hide an NPC's console, the NPC doesn't join the server.
ConnectNPC("[NPC]Jack","npcplayback.nut",false,"127.0.0.1","rpclib z-finder");  //Not Join
ConnectNPC("[NPC]Jack","npcplayback.nut",true,"127.0.0.1","rpclib z-finder");  //Join
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 17, 2024, 09:31 AM
Quote from: PSL on Feb 17, 2024, 04:02 AMI found a problem in testing this version. When I hide an NPC's console, the NPC doesn't join the server.
ConnectNPC("[NPC]Jack","npcplayback.nut",false,"127.0.0.1","rpclib z-finder");  //Not Join
ConnectNPC("[NPC]Jack","npcplayback.nut",true,"127.0.0.1","rpclib z-finder");  //Join
This issue has been fixed. It was related to npc creating logfiles. Logfiles can now be found in folder npcscripts/logs whenever ConnectNPC is called with console parameter false.
Also,
QuoteCorrected API version to 1.6
Windows (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_windows_v1.8-beta.zip/download)
Linux x64 (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x64_v1.8-beta.zip/download)
Linux x86 (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x86_v1.8-beta.zip/download)
rel004 (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel004_win_lin_v1.8-beta.zip/download)
Source-1.8-beta-zip (https://sourceforge.net/projects/npc-for-vcmp/files/NPC-VCMP-master-v1.8-beta.zip/download)
Setup (Installer) (https://sourceforge.net/projects/npc-for-vcmp/files/npcclient-setup-v1.8-beta.exe/download)

What's New in v1.8 Beta?

From Release Notes (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_8_beta_release_notes) on the wiki:

Quote
  • New Recording Type: Introducing PLAYER_RECORDING_TYPE_ALL for StartRecordingPlayerData, eliminating the need to specify whether the player is on foot or in a vehicle.

  • Captured Events: PLAYER_RECORDING_TYPE_ALL now supports capturing various events, including player updates, death, pickup events, checkpoint events, object touch/shot events, player chat, player command, private messages, and ClientScriptData.

  • StartRecordingAllPlayerData: A unified function to start recording on all players, including those who may join later.

  • Server Recording: Similar to StartRecordingAllPlayerData, but produces an hrec file with player join times and corresponding rec files for replay. Connected players act as NPCs, replicating player actions.

  • ConnectMultipleNpcs: Connects multiple NPCs from an hrec file produced by PutServerInRecordingMode.

  • recdir Configuration: Introduce recdir 2 in server.cfg to save playback recordings to npcscripts/recordings, with recdir 1 as the default.

  • Npcs with Strings: Npcs can now be called with strings, allowing for custom actions like "function OnNPCSpawn(){SendChat("I have spawned");}".

  • Logfiles: Each NPC now writes logfiles in the npcscripts folder.

  • New NPC Functions: Various new functions added for use by npcscripts, including Suicide, SetMyHealth, GetMyHealth, LookAtPos, LookAtPlayer, GetMyClass, RequestClassAbs, AmISpawned, GetMySkin, GetMyTeam, GetMyArmour, SendPrivMsg, SetConfig, GetPlayerColor, IsPlaybackRunning, IsPlaybackPaused, IsServerInRecordingMode.

  • Additional npc04relxx Plugin Functions: KickAllNPC, IsPlayerRecording, StartRecordingAllPlayerData, StopRecordingAllPlayerData, PutServerInRecordingMode, StopServerInRecordingMode, IsServerInRecordingMode.

  • Configurable max_npc: Added max_npc in server.cfg, optional and limits the number of NPCs in the server (values: 0 to 100, -1 for any number).

  • Console Notifications: Npcs now print their names in the console upon connection, e.g., "Connected. ID: 03 Name: John".

  • Bug Fixes: Fixed issues with NPC getting kicked, not holding weapons on spawn, and incorrect angles for newly streamed players.

  • Private Messages: NPCs can now send private messages.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 17, 2024, 11:35 AM
Hi Habi,  I tested the recording option, I captured myself getting on and getting off, it was very successful, recdir 2 was great, the log files were perfectly recorded, there were problems when I tested all the players.
This is the code I did to query the wiki. I will use this feature to record multiplayer races.I will continue to explore the features of this version.I may not be very good at using this feature yet, believe me, I just need a simple example and will learn the additional features in no time.
PutServerInRecordingMode("testfile",3,REC_ALLNAME);
StartRecordingPlayerData(PLAYER_RECORDING_TYPE_ALL,60,false); //error in here AN ERROR HAS OCCURED [The recname parameter must be string]
//Should the two codes be used together?
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 17, 2024, 02:35 PM
Hi PSL, the two codes should not be used together. The correct way is
PutServerInRecordingMode("testfile",PLAYER_RECORDING_TYPE_ALL,REC_ALLNAME)
and
StopServerInRecordingMode()
This will automatically start recording data of all players.
Now when you call stop, it finishes recording. You will get testfile.hrec and n rec files, where n is the number of players who was in the server in between PutServerInRecordingMode and StopServerInRecordingMode.
Next use the plugin npc04relxx to start playback. Use
ConnectMultipleNpcs(testfile, "127.0.0.1",7);
which will connect the same 'n' npcs.
Notes
1. Use PutServerInRecordingMode (with flags
REC_ALLNAME) when server is empty. If this function is called when a players are already spawned, the npc when connected will have spawning problem.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 17, 2024, 04:24 PM
Hi Habi, I'll try this tomorrow. Thank you for your teaching. I already understand.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 18, 2024, 06:06 AM
Hi Habi. I started recording perfectly fine, generating hrec and some rec files, and when I did ConnectMultipleNpcs, the main console just shut down.
Here is the link to the file: https://file.io/lWGmWVUgd8ea
function onScriptLoad()
{
PutServerInRecordingMode("testfile",PLAYER_RECORDING_TYPE_ALL,REC_ALLNAME); //This code will be commented when the file is generated
}
function onPlayerPart(player,reason)
{
StopServerInRecordingMode(); //This code will be commented when the file is generated
}

function onPlayerCommand(player,cmd,text)
{
    if(cmd=="test2")
    {
        ConnectMultipleNpcs("testfile","127.0.0.1",7); // Create a recording file and run this command
    }
}
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 19, 2024, 07:22 AM
Hi PSL, i understand your server console is shutting down once you call ConnectMultipleNpcs function.
Unfortunately, i am on a travel and could not look at the problem.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 19, 2024, 02:20 PM
Hi Habi, I am glad to know that you are traveling.  I wish you a fruitful journey and a pleasant and unforgettable trip.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 27, 2024, 02:32 PM
Hi Habi, There was an error playing back the recording, and the vehicle stood still.  Error. Vehicle id from rec file different. See flags for overriding.
When I open the rec file, field2 is 141, When the NPC comes back to life, immediately create the vehicle with model ID 141, then put the NPC in the driving position, then execute the recording file with the RFC, and the NPC stays still.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 28, 2024, 10:04 AM
Hi PSL,
I understand that you create a vehicle with model ID 141 and put npc inside it and using RFC executed the playback recording.
That is correct, field2 is indeed model ID of the vehicle.

Playback type PLAYER_RECORDING_TYPE_ALL checks  whether vehicle.ID is same as that of recfile. This is saved in field1.
You can avoid this vechicleID check by using
StartRecordingPlayback(3,"cartest",PLAY_IGNORE_VEHICLEID)
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 29, 2024, 07:07 AM
Quote from: PSL on Feb 18, 2024, 06:06 AMHi Habi. I started recording perfectly fine, generating hrec and some rec files, and when I did ConnectMultipleNpcs, the main console just shut down.
Here is the link to the file: https://file.io/lWGmWVUgd8ea
function onPlayerCommand(player,cmd,text)
{
    if(cmd=="test2")
    {
        ConnectMultipleNpcs("testfile","127.0.0.1",7); // Create a recording file and run this command
    }
}
By main console, i assume that you mean the console of npc which opens up was shutdown. The ConnectMultipleNpcs will connect npcs with same name as those players when hrec file was recorded. So from your file, the npc will have name pq. So if your game-name is also pq, those npcs fail to be connected.
QuoteKicking connecting player at ID 1, name already in use.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 29, 2024, 07:34 AM
Hi Habi, I add PLAY_IGNORE_VEHICLEID, you will be able to play back normally. thank you.
But I've noticed that NPCS don't seem to be able to get into ships, say with ID 176.
I simply execute ConnectMultipleNpcs("testfile","127.0.0.1",7); , The NPC console does not appear at all, My server simply shut down after executing this code.What's the reason?
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 29, 2024, 05:55 PM
Hi PSL, i have fixed the two bugs
QuoteFixed Npc not able to enter into ships
Fixed Server crashing when calling ConnectMultipleNpcs.
Now patch1 available for download:

NPC v1.8 Beta - Patch 1 - Updated Files

Released on: 29-02-2024

Downloads
npc_vcmp_rel006_windows_v1.8-beta-p1.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_windows_v1.8-beta-p1.zip/download) (Size: 1.00 MB)
npc_vcmp_rel006_linux_x86_v1.8-beta-p1.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x86_v1.8-beta-p1.zip/download) (Size: 3.10 MB)
npc_vcmp_rel006_linux_x64_v1.8-beta-p1.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x64_v1.8-beta-p1.zip/download) (Size: 1.03 MB)
npc_vcmp_rel004_win_lin_v1.8-beta-p1.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel004_win_lin_v1.8-beta-p1.zip/download) (Size: 2.23 MB)
npcclient-setup-v1.8-beta-p1.exe (https://sourceforge.net/projects/npc-for-vcmp/files/npcclient-setup-v1.8-beta-p1.exe/download) (Size: 2.19 MB)

source-code
NPC-VCMP-master-v1.8-beta-p1.zip (https://sourceforge.net/projects/npc-for-vcmp/files/NPC-VCMP-master-v1.8-beta-p1.zip/download) (Size: 10.10 MB)

Note: Please make sure to update to these latest files for an enhanced NPC experience!
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Mar 01, 2024, 11:34 AM
Hi Habi, Both of these bugs have been fixed in this new release, which is great. After my update, these two issues have also been fixed. Thank you.
I put the NPC in the vehicle and played it back. After my NPC got out of the car, he stood upright like a corpse, only the coordinates had changed. This was also the case in the previous version. I didn't record the entire server, so maybe that will happen here as well.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Mar 03, 2024, 09:09 AM
Hi PSL,
i have found that npc do not exist properly from vehicle. It does not exit via car door, but stands outside - only co-ordinates are changed.

Here is a temporary solution involving editing the rec file :
1. Open rec file and find the packet which corresponds to npc exit vehicle. It will have packet number =  3.
2. Optionally, Use Help->Show Legends to see all packet types.
3. Double click on 'Time' column and reduce the value by 1100 (ms)
4. Save or Save As new file.

My laptop is not with me. I will issue a patch as soon as possible.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Mar 03, 2024, 02:56 PM
Hi Habi, This operation can resume the action of getting out of the car, but the walking after getting out of the car cannot be resumed.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Mar 04, 2024, 03:08 PM
Hi Habi. I also have a small probability that when an NPC enters the vehicle and executes the playback file, the NPC will simply get out and walk, then stop, and there is no event triggering the NPC to leave the vehicle when getting out.
The npc console displays that Error. Vehicle is not acquired by NPCS.
This is the recording that triggered the error: https://file.io/rbteRVNXNxyh , Vehicle model is 226.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Mar 04, 2024, 04:40 PM
Hi PSL, i fixed the second issue. Now the error "vehicle not acquired by npc" is not shown. Also it drives vehicle good.
Here is a windows only patch of npcclient.exe
rel006
windows https://www.mediafire.com/file/yx1onimsqn8uq5e/npcclient-v1.8-beta-p1a.zip/file
linux-64 https://www.mediafire.com/file/p8z51uteldg6h9b/npcclient64-linux-v1.8-beta-p1a.zip/file
rel004
windows https://www.mediafire.com/file/wz00axkfzeid81d/npcclient_r004-v1.8-beta-p1a.zip/file
linux-64 https://www.mediafire.com/file/6nkxeepdkpbk37q/npcclient64_r004-linux-v1.8-beta-p1a.zip/file
I will release all editions soon. Please report any bugs you find like this.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Mar 05, 2024, 02:48 AM
This problem has been fixed perfectly, and I'm sorry to have caused you so much trouble.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Mar 06, 2024, 05:32 PM
No need to apologize! I'm glad that the problem is fixed.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Mar 09, 2024, 02:54 PM
I always find problems as soon as you release a new version. Now I have no more problems to report.
This plugin is very good, with it you can make a lot of gameplay.
Hi Habi. How can I tell if an ID is an NPC player in an NPC script. Recognize players and NPCS. I don't want to give NPCS a uniform name or skin.
function OnPlayerStreamIn(playerid)
{
    print("I see the "+GetPlayerName(playerid)+" enter my field of view, and his ID is: "+playerid+".");

    local r=RFC("IsPlayerNPC")(playerid);
    print(""+r+""); //Always return true
}
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Mar 11, 2024, 07:28 AM
Hi PSL, the remote function calls (RFC) in npcmodule unfortunately cannot return value from server. It can only execute code.
See RFC documentation https://npc-for-vcmp.sourceforge.io/wikiw/index.php/LibRPC_RFC for Return Values:
QuoteThis will return a function object which can be used as if it is the remote function itself.(except of return values)
So r will always be true.

I wrote a code to do this in two parts - serverscript and npcscript
//--npcscript
npclist<-array(100, false);
function RegisterNPC(playerid, isnpc)
{
npclist[playerid]=isnpc;
}
function OnPlayerStreamIn(playerid)
{
    print("I see the " GetPlayerName(playerid) " enter my field of view, and his ID is: " playerid ".");

    local r=npclist[playerid];

    if(r)print(" He is an npc\n");
}
//--server side
//when a new player joins inform all npcs if the player is PC(Playable Character) or NPC(Non Playable Character).

function onPlayerJoin(player)
{
local plr;
for(local i=0;i<GetMaxPlayers();i )
{
plr = FindPlayer(i);
if(plr && plr.IsNPC)
{
//Send information
RFC(i, "RegisterNPC")(player.ID, player.IsNPC);
}
}
//When an npc joins the server send information about all existing Characters (Playable or Non Playable) to it.
if(player.IsNPC)
{
for(local i=0;i<GetMaxPlayers();i++)
{
plr= FindPlayer(i);
if(plr)
RFC(player.ID, "RegisterNPC")(i, plr.IsNPC);
}
}
}


1. IsNPC or IsNPC()
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Mar 11, 2024, 10:41 AM
HI Habi, I understand your code and have successfully crafted the judgment NPCS. thank you very much.
When the NPC is in the vehicle and is the driver, the vehicle cannot pass the Vehicle.AddSpeed to add speed.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Mar 11, 2024, 11:20 AM
HI, Vitovc. I was working on controlling the vehicle in the passenger seat and stumbled upon this issue, which turns out not to be a bug.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Jul 07, 2024, 11:48 AM
Hi Habi, NPC cannot enter the new server version 0.4.7.0
Console: Error server version: 67700. Using REL006 = 67400
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Jul 09, 2024, 12:48 AM
Hi PSL, i will check what can be done.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: Ridwan Rz on Jul 14, 2024, 05:24 AM
Is this updated for 0.4.7?
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Jul 14, 2024, 05:41 AM
Hi Ridwan Rz, it is not yet updated to 0.4.7.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Jul 26, 2024, 08:52 AM
Hi Habi,What is the current status of NPC plugin updates :)  :)  :)
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Jul 26, 2024, 02:56 PM
Hi PSL, thank you for your interest in npc-plugin. I just reached home today and you can expect the update anytime during the next few days.

Edit: Found  that new server is using protocol version 47 related to 'raknet networking engine'. This protocol, i have no idea.
So next update of plugin might take longer than i expected.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: 2b2ttianxiu on Jul 28, 2024, 11:16 AM
Use a newer raknet?
(I mean client protocol base network raknet is update?)
(I can help u)
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Jul 29, 2024, 01:49 PM
Quote from: 2b2ttianxiu on Jul 28, 2024, 11:16 AMUse a newer raknet?
(I mean client protocol base network raknet is update?)
(I can help u)
they are using 'SLikeNet' - a modification of raknet, in new vcmp version.
The windows version of server crashes sometimes when npc connects to it.
And 2b2ttianxiu, thanks for your offer, but i will manage it myself.
 
Quote from: vitovc on Jul 28, 2024, 06:12 PMnew vcmp version is full of bugs, it will take a time before it will be popular to use, so don't hurry with that, just keep improve your server scripts, AI of npc has unlimited potential to code. let habi to relax a bit.
i agree ai of npc has unlimited potential. and I'm relaxing 😌
Quotehe did awesome things to vcmp.
me?  :)
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Jul 29, 2024, 02:02 PM
Quote from: habi2 on Jul 29, 2024, 01:49 PM
Quote from: 2b2ttianxiu on Jul 28, 2024, 11:16 AMUse a newer raknet?
(I mean client protocol base network raknet is update?)
(I can help u)
they are using 'SLikeNet' - a modification of raknet, in new vcmp version.
The windows version of server crashes sometimes when npc connects to it.
And 2b2ttianxiu, thanks for your offer, but i will manage it myself.
 
Quote from: vitovc on Jul 28, 2024, 06:12 PMnew vcmp version is full of bugs, it will take a time before it will be popular to use, so don't hurry with that, just keep improve your server scripts, AI of npc has unlimited potential to code. let habi to relax a bit.
i agree ai of npc has unlimited potential. and I'm relaxing 😌
Quotehe did awesome things to vcmp.
me?  :)
yeup totaly u 😅  ill msg an idea on discord soon..
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: Dieciseis on Aug 07, 2024, 07:13 PM
Here now it connects but it stays in spawnscreen position and is invisible
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Aug 08, 2024, 06:45 AM
Quote from: Dieciseis on Aug 07, 2024, 07:13 PMHere now it connects but it stays in spawnscreen position and is invisible
Are you using rel006 or 0.4.7 ?
2. Did you downloaded v1.8 version of npc .?
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: Dieciseis on Aug 08, 2024, 12:12 PM
It turned out that there was a login system so that it stayed at spawnscreen position.Do I need to ask him to enter the command to solve it?
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Aug 08, 2024, 01:13 PM
yes.
SendCommand("login password");
You can put this in a variety of places

My suggestion is use event OnClientMessage

function OnClientMessage(r,g,b,message)
{ if(message.find("login")!=null)
SendCommand ("login password_of_npc");
}

Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Aug 09, 2024, 09:15 AM
Quote from: PSL on Jul 26, 2024, 08:52 AMHi Habi,What is the current status of NPC plugin updates :)  :)  :)
The new npc can connect to windows server. I have fixed all version error, etc. New npc knows different messages send by server -join, death, etc.
I have found new vcmp client sends onfoot and onfoot-aim packets differently. Rest all(vehicle drive, passenger,..) is assumed to be same.
This foot sync packets have extra 9 float values 4 of them always zero, other in range -1 to 1. When player angle is special like 0, pi/2, pi etc, some become exactly equal to 1 while others are 0 or 0.3 etc.


Moreover, when the player shoots an extra vector apart from aimdir and aimpos is send. This extra vector close to aimdir and its magnitude is always 1.

Interesting, huh ?
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Aug 18, 2024, 07:08 AM
Hi Habi.
Thank you very much for your explanation.  I have understood the development situation you mentioned.  I am looking forward to receiving your plug-in as soon as possible.  I am looking forward to and excited about it!
Thanks again for your hard work and the development of this plugin!
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: StingRay_ on Aug 18, 2024, 05:15 PM
Hi habi.
I was running server on linux and when I used ConnectNPCEx, it just came:
sh: 1: /home/fidlar/vcmp/test: not found
Nothing else, and the npc was not connected. I found the path above to my server was truncated (originally 'test server'), it seemed spaces could not be included in the path, and with spaces removed it turned out fine. Trivial though, could this one be fixed? Thanks a lot for your continuous efforts.
Btw it worked fine with windows version plugin.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Sep 15, 2024, 03:27 PM
Quote from: StingRay_ on Aug 18, 2024, 05:15 PMHi habi.
I was running server on linux and when I used ConnectNPCEx, it just came:
sh: 1: /home/fidlar/vcmp/test: not found
Sorry i have not seen your message.
I will take care of this issue in next build.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Sep 29, 2024, 02:57 PM
sure. thanks for the link
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Oct 03, 2024, 07:30 AM
NPCClient v1.8 beta 3 Released - Now with 0.4.7.1 Support!

We're excited to announce the release of npcclient v1.8 beta 3! This release comes with several key updates and bug fixes that will improve compatibility and stability for VCMP servers.

What's New in v1.8 beta 3:
  • Added support for 0.4.7.1: Now fully compatible with the latest server version.
  • Fixed a possible bug in rel004 servers: Related to passenger updates, enhancing overall stability.
  • Fixed plugin truncating path to the server: When paths contain spaces using ConnectNPCEx/ConnectNPC.
  • New InPoly function: Added a function to check if a two-dimensional point is inside a polygon by providing the vertices of the polygon. This can help with advanced scripting and positioning logic.

For more details on the changes, please refer to the full release notes: Release Notes (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_8_beta3_release_notes)

Downloads:

Operating SystemVersionDownload Link
Windows0.4.7.1npc_vcmp_0471_windows_v1.8-beta-3.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_0471_windows_v1.8-beta-3.zip/download)
Linux x640.4.7.1npc_vcmp_0471_linux_x64_v1.8-beta-3.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_0471_linux_x64_v1.8-beta-3.zip/download)
Linux x860.4.7.1npc_vcmp_0471_linux_x86_v1.8-beta-3.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_0471_linux_x86_v1.8-beta-3.zip/download)
Windowsrel006npc_vcmp_rel006_windows_v1.8-beta-3.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_windows_v1.8-beta-3.zip/download)
Linux x64rel006npc_vcmp_rel006_linux_x64_v1.8-beta-3.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x64_v1.8-beta-3.zip/download)
Linux x86rel006npc_vcmp_rel006_linux_x86_v1.8-beta-3.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x86_v1.8-beta-3.zip/download)
Windows/Linuxrel004npc_vcmp_rel004_win_lin_v1.8-beta-3.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel004_win_lin_v1.8-beta-3.zip/download)
Source CodeAll versionsNPC-VCMP-master-v1.8-beta-3.zip (https://sourceforge.net/projects/npc-for-vcmp/files/NPC-VCMP-master-v1.8-beta-3.zip/download)
API Plugin1.6npc_vcmp_plugin_API_1_6.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_plugin_API_1_6.zip/download)

---

Thank you all for your continued support and for using npcclient! Your feedback and dedication help us keep improving. Please feel free to share your thoughts and report any issues.

Happy scripting!
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Oct 25, 2024, 05:01 PM
NPCClient v1.8 Beta 4 Released

We're releasing the latest beta for NPCClient, version 1.8 Beta 4, with several improvements and bug fixes:


Downloads:
Operating SystemVersionLink
Windows0.4.7.1npc_vcmp_0471_windows_v1.8-beta-4.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_0471_windows_v1.8-beta-4.zip/download)
Linux x640.4.7.1npc_vcmp_0471_linux_x64_v1.8-beta-4.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_0471_linux_x64_v1.8-beta-4.zip/download)
Linux x860.4.7.1npc_vcmp_0471_linux_x86_v1.8-beta-4.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_0471_linux_x86_v1.8-beta-4.zip/download)
Windowsrel006npc_vcmp_rel006_windows_v1.8-beta-4.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_windows_v1.8-beta-4.zip/download)
Linux x64rel006npc_vcmp_rel006_linux_x64_v1.8-beta-4.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x64_v1.8-beta-4.zip/download)
Linux x86rel006npc_vcmp_rel006_linux_x86_v1.8-beta-4.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel006_linux_x86_v1.8-beta-4.zip/download)
Windows/Linux (rel004)rel004npc_vcmp_rel004_win_lin_v1.8-beta-4.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_rel004_win_lin_v1.8-beta-4.zip/download)
Source CodeAllNPC-VCMP-master-v1.8-beta-4.zip (https://sourceforge.net/projects/npc-for-vcmp/files/NPC-VCMP-master-v1.8-beta-4.zip/download)
API Plugin1.8npc_vcmp_plugin_API_1_8.zip (https://sourceforge.net/projects/npc-for-vcmp/files/npc_vcmp_plugin_API_1_8.zip/download)
Windows (Setup)rel004, rel006, 0.4.7.1npcclient_v1.8_beta4_setup.exe (https://sourceforge.net/projects/npc-for-vcmp/files/npcclient_v1.8_beta4_setup.exe/download)

Thank you for testing and providing feedback!

Release Notes (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_8_beta4_release_notes)
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Oct 25, 2024, 11:40 PM
Hey, Habi! Congratulations on your successful launch of NPC plug-in 1.8p4 version ah, along the way watching you constantly update and improve this plug-in, really admire your persistence and efforts. I know that every update is not easy, and I must have paid a lot of effort behind it. I believe that this new version will be loved and recognized by more players, you can boldly go ahead, I will always support you!
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Oct 26, 2024, 07:26 AM
habi soon making npc.ai();

great work man.. keep vcmp alive..
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Oct 26, 2024, 08:03 AM
Hi PSL,
Thank you for such encouraging words. It is because of you and other friend's interest that the project is still alive.
I will see what can be done to make npc more better.

Hi Megamind,
Quote from: MEGAMIND on Oct 26, 2024, 07:26 AMhabi soon making npc.ai();

great work man.. keep vcmp alive..
Thank you
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 07, 2024, 09:17 AM
How does the npc gets a skin ?
npc_pos <- Vector(-1750.44, -277.178, 14.8683);
function OnNPCScriptLoad( params )
{

print("npcidle: running\n");
}


function OnNPCClassSelect()
{
    if(GetPlayerTeam(GetMyID())==210)
      RequestSpawn();
    else
      RequestClass(CLASS_NEXT);
    return 1
}

function OnNPCSpawn()
{


     SendChat("I have spawned");

SetTimerEx("SetMyPos",700, 1, npc_pos );
SetMyPos(npc_pos);

}

server side
function onPlayerRequestClass( player, classID, team, skin )
{
AddClass(28, RGB( 124, 121, 121 ),212,Vector(-923.882, 406.665, 11.247), 188.3568,25,320,21,320,102,450);
}
@habi2
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 07, 2024, 12:07 PM
Hi Megamind

The npc doesn't get skin. The npc04 plugin has code inside it for setting skin. It sets skin if any npc sends a setskin command. And when needed, our npc do send such commands.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 07, 2024, 12:26 PM
Quote from: habi2 on Nov 07, 2024, 12:07 PMHi Megamind

The npc doesn't get skin. The npc04 plugin has code inside it for setting skin. It sets skin if any npc sends a setskin command. And when needed, our npc do send such commands.
how do i set the skin to it

working on npcAI(text,player,tone);
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 07, 2024, 02:19 PM
Quote from: MEGAMIND on Nov 07, 2024, 12:26 PMhow do i set the skin to it
You can set the skin of npc when using ConnectNPCEx (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/ConnectNPCEx)
ConnectNPCEx("[npc]robin", Vector(-377.935, -536.472, 17.2828), 0.0, 0);
//Angle 0.0, Skin=0, Weapon  not specified

Also you can from npcscripts:
SendCommand("_npc_skin_request 0"); //if you need skin 0

Also from server, if player=npc, then
player.Skin=5; //medic
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 09, 2024, 09:05 AM
hi @habi2 lets say

function OnPlayerText(playerid, message)
{
    if(message=="come")
    {
    print("Going to player: "+playerid+"\n");
    SendCommand("goto "+playerid);
    }
   
    if(message=="lookatme")
    {
        if(GetDistanceFromMeToPoint(GetPlayerPos(playerid))<100.0)
        {
            LookAtPlayer(playerid);
        }
    }
}

how am i going to call these from serverside? either onplayercommandor playerchat ?

or if theres a way to get the checkpoint id and do it from serverside?

if ( checkpoint.ID == 100)
{
onPlayerChat(player, "lookatme");
}
}
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 09, 2024, 11:20 AM
I am very much happy you asked this question.

From server you can call npcscript functions like LookAtPlayer:
RFC(1,"LookAtPlayer")(player.ID);
//Let 1 be ID of npc


RFC (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/RFC) is available with npc04 plugin.
For this to work you have to load 'LibRPC' plugin of npc while connecting:
ConnectNPC("[npc]mike, "your_npc_script.nut", false, "", "rpclib");
//false = no console, hostname="" means 127.0.0.1
If you're using ConnectNPCEx instead of ConnectNPC then use following format:
Quote(name, Pos, angle, skinId, weaponId, classId, script="", enableconsoleinput=false, host="127.0.0.1", plugins="", ...)

If you want to use SendCommand it is same:
//From serverside only:
RFC(1, "SendCommand")("goto "+playerid);
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 09, 2024, 11:29 AM
Quote from: habi2 on Nov 09, 2024, 11:20 AMI am very much happy you asked this question.

From server you can call npcscript functions like LookAtPlayer:
RFC(1,"LookAtPlayer")(player.ID);
//Let 1 be ID of npc


RFC (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/RFC) is available with npc04 plugin.
For this to work you have to load 'LibRPC' plugin of npc while connecting:
ConnectNPC("[npc]mike, "your_npc_script.nut", false, "", "rpclib");
//false = no console, hostname="" means 127.0.0.1
If you're using ConnectNPCEx instead of ConnectNPC then use following format:
Quote(name, Pos, angle, skinId, weaponId, classId, script="", enableconsoleinput=false, host="127.0.0.1", plugins="", ...)

If you want to use SendCommand it is same:
//From serverside only:
RFC(1, "SendCommand")("goto "+playerid);

worked but crash, it  responded for 3 times but then crashed, what im doing is on npc side
function OnPlayerText(playerid, message)
{
if(message=="come")
{
print("Going to player: "+playerid+"\n");
SendCommand("goto "+playerid);
}

if(message=="lookatme")
{
if(GetDistanceFromMeToPoint(GetPlayerPos(playerid))<100.0)
{
LookAtPlayer(playerid);
}
}
}
and on serverside

if ( checkpoint.ID == 100)
{
local npc = FindPlayer(0);
RFC(0,"LookAtPlayer")(player.ID);
}
else
{
MessagePlayer("[#ffffff]Donot disturb npc",player);
}
}

though im using this ConnectNPCEx("[A.I]ChatGPT", Vector (-1735.81, -266.977, 14.8683),  -0.172573, 212, 24, 4,"npc.nut",true,"127.0.0.1","rpclib z-finder");
Edit: what i find out is that its fine until u give it a 2 or 3 sec break , if u enter checkpoint and leave and enter it crashes, like performing this move within a sec
 
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 09, 2024, 11:40 AM
what i did that i tried even placing this rfc command at on playermove the server started and clsoed immedialtely @habi2
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 09, 2024, 03:53 PM
function OnNPCSpawn()
{


     SendChat("I have spawned");

SetTimerEx("SetMyPos",700, 1, npc_pos );
SetMyPos(npc_pos);



}

function OnPlayerDeath(playerid)
{
OnNPCSpawn();
}
npc is dead how he gonna spawn back?, bcz i see a msg that i have spawned but not actully spawned, even though i get npc it says player not spawned
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 09, 2024, 04:11 PM
Hi @MEGAMIND, i see your messages and will fix it one by one.
Quotenpc is dead how he gonna spawn back?, bcz i see a msg that i have spawned but not actully spawned, even though i get npc it says player not spawned
Use RequestSpawn (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/RequestSpawn) to spawn the npc.when it is dead. It will spawn in the same class.
function OnPlayerDeath(playerid)
{
if(playerid==GetMyID())
              RequestSpawn();
}
About crashing of server (i hope it is server that is crashing), when you use RFC repetitiously there might be some bug which i will look now.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 09, 2024, 04:22 PM
Quote from: habi2 on Nov 09, 2024, 04:11 PMHi @MEGAMIND, i see your messages and will fix it one by one.
Quotenpc is dead how he gonna spawn back?, bcz i see a msg that i have spawned but not actully spawned, even though i get npc it says player not spawned
Use RequestSpawn (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/RequestSpawn) to spawn the npc.when it is dead. It will spawn in the same class.
function OnPlayerDeath(playerid)
{
if(playerid==GetMyID())
              RequestSpawn();
}
About crashing of server (i hope it is server that is crashing), when you use RFC repetitiously there might be some bug which i will look now.
why does it change skin? though i have a skin already in connect ConnectNPCEx("[A.I]ChatGPT", Vector (-1735.81, -266.977, 14.8683),  -0.172573, 212, 24, 4,"npc.nut",true,"wno-host.ddns.net","rpclib z-finder actionlib npcmodule");
its changing into lovefist skin
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 09, 2024, 04:23 PM
Quote from: habi2 on Nov 09, 2024, 04:11 PMAbout crashing of server (i hope it is server that is crashing), when you use RFC repetitiously there might be some bug which i will look now.
yes serverside.exe gets closed

Suggestion lookatplayer should be as syncd as whn npc is targetting and shooting player, add the same mechanics to lookatplayer too @habi2
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 12, 2024, 08:10 AM
Hi Megamind i was not well for two days and now recovering fast.
The mechanism of creating npc with skin was created when npc didn't die. Now it dies and gets skin of the class which in your case maybe lovefist. I will fix it in next update. But you can
SendCommand("_npc_skin_request 65");
to set npc skin anytime. The above code set it to 65, as we discussed before. OnNPCSpawn might be the right place.

About server crashing issue, it is the 64-bit version of windows (and perhaps linux too) that has bug when using RFC. I will correct it.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 12, 2024, 10:36 AM
Quote from: habi2 on Nov 12, 2024, 08:10 AMHi Megamind i was not well for two days and now recovering fast.
The mechanism of creating npc with skin was created when npc didn't die. Now it dies and gets skin of the class which in your case maybe lovefist. I will fix it in next update. But you can
SendCommand("_npc_skin_request 65");
to set npc skin anytime. The above code set it to 65, as we discussed before. OnNPCSpawn might be the right place.

About server crashing issue, it is the 64-bit version of windows (and perhaps linux too) that has bug when using RFC. I will correct it.
thanks habi i also found a work around from serverside for facing the npc towards me but it will be alot better if just single line of code can do the work easily instead of doing a full math, also get well soon
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 14, 2024, 02:59 PM
Hi Megamind,

Here is 64-bit version of plugin with RFC function fixed:
npc04rel64-windows.zip (https://www.mediafire.com/file/xvnkoe6743n4tjr/npc04rel64-windows.zip/file) (170.53 KB)

I was writing 8 bytes in allocated memory of 4 bytes for integer. Now casted the 8 byte integer to 4 byte and write in the 4 bytes memory.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 14, 2024, 03:32 PM
Quote from: habi2 on Nov 14, 2024, 02:59 PMHi Megamind,

Here is 64-bit version of plugin with RFC function fixed:
npc04rel64-windows.zip (https://www.mediafire.com/file/xvnkoe6743n4tjr/npc04rel64-windows.zip/file) (170.53 KB)

I was writing 8 bytes in allocated memory of 4 bytes for integer. Now casted the 8 byte integer to 4 byte and write in the 4 bytes memory.
thats graet habi i had stoped working on npc kindof paused but ill checkit out and resume my work, thanks for your time, ill get back to u with results/bugs
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 14, 2024, 05:36 PM
@habi2 Hi just tested it and i have did some crazy amount of testing on it and now its perfectly fine..! Thanks again
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 14, 2024, 10:01 PM
hey @habi2 sup man, ok so i was trying to give it a more like gta vc npc feeling but i saw in the plugin that only SendCommand("_npc_skin_request 211");
    SendCommand("_npc_weapon_request 24");
were available from npcscripts but what about if we want like anims or alot more can be asked like to send commands from npc side to server..

+ u know what people do at my server?

spawn me a car, fight me walk with me so i think i could comeup with those codes but can we have some more of these

SendCommand("_npc_anim_request someanim"); also access serverside commands from npcside, ik theres RFC but tahts from server side what im trying is to give npc a new feel also it would easily work with my chatgpt integration with it te npc will become more life like being..
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 15, 2024, 09:32 AM
Quote from: MEGAMIND on Nov 14, 2024, 10:01 PMhey @habi2 sup man, ok so i was trying to give it a more like gta vc npc feeling but i saw in the plugin that only SendCommand("_npc_skin_request 211");
    SendCommand("_npc_weapon_request 24");
were available from npcscripts but what about if we want like anims or alot more can be asked like to send commands from npc side to server..
Hi Megamind, there is an RFC (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/LibRPC) in npcscripts side also.
You can execute commands serverside. As you can read in link, npc.IsAdmin=true is required for this.

I will come up with examples later on.

It is nice to know people interacting with your chatgpt a.i.

Please read examples(under See Also)  in wiki like setting cash. There is also one about setting weapon. good luck.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 15, 2024, 12:16 PM
@habi2 hi i was testing some local npc running in server at different points randomnly where  i thought how about to hide it so looked at https://npc-for-vcmp.sourceforge.io/wikiw/index.php/NPCHide even downloaded the plugin i faced this Plugin error >> LoadLibrary() 'plugins/npc.dll' failed: Code 126
Failed to load plugin: npc

if the plugin istn the way out to hide can u make me a snippet where the playernames gets hidden from browser and from ingame server
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 15, 2024, 04:20 PM
Quote from: MEGAMIND on Nov 15, 2024, 12:16 PM@habi2 hi i was testing some local npc running in server at different points randomnly where  i thought how about to hide it so looked at https://npc-for-vcmp.sourceforge.io/wikiw/index.php/NPCHide even downloaded the plugin i faced this Plugin error >> LoadLibrary() 'plugins/npc.dll' failed: Code 126
Failed to load plugin: npc
Hi megamind, the name of the plugin associated for hiding npc in browser is npchide. For 64-bit, 64 is suffixed. Please verify that name of plugin in server.cfg is same as the name of dll in plugins directory.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 15, 2024, 04:39 PM
Quote from: habi2 on Nov 15, 2024, 04:20 PM
Quote from: MEGAMIND on Nov 15, 2024, 12:16 PM@habi2 hi i was testing some local npc running in server at different points randomnly where  i thought how about to hide it so looked at https://npc-for-vcmp.sourceforge.io/wikiw/index.php/NPCHide even downloaded the plugin i faced this Plugin error >> LoadLibrary() 'plugins/npc.dll' failed: Code 126
Failed to load plugin: npc
Hi megamind, the name of the plugin associated for hiding npc in browser is npchide. For 64-bit, 64 is suffixed. Please verify that name of plugin in server.cfg is same as the name of dll in plugins directory.

i use this in server.cfg npchide64
plugins squirrel04rel64 sqlatestfeatures04rel64 xmlconf04rel64 announce04rel64 ini04rel64 sqlite04rel64 sockets04rel64 hashing04rel64 mysql04rel64 rcon04rel64 vcmp-squirrel-mmdb-rel64 logfile64 webnet64 appchat04rel64 json04rel64 httprequest04rel64 npc04rel64 npchide64

and this is what i get
 Vice City Multiplayer Server
 -------------------------------
 v0.4, (c) 2007-2024 VC:MP Team

Loaded plugin: squirrel04rel64

Loaded plugin: sqlatestfeatures04rel64

Loaded plugin: xmlconf04rel64

Loaded plugin: announce04rel64

Loaded plugin: ini04rel64

Loaded plugin: sqlite04rel64

Loaded plugin: sockets04rel64

Loaded plugin: hashing04rel64

Loaded plugin: mysql04rel64

Loaded plugin: rcon04rel64

Loaded plugin: vcmp-squirrel-mmdb-rel64

Loaded plugin: logfile64

Loaded plugin: webnet64

Loaded plugin: appchat04rel64

Loaded plugin: json04rel64

Loaded plugin: httprequest04rel64

Loaded plugin: npc04rel64

Plugin error >> LoadLibrary() 'plugins/npc.dll' failed: Code 126
Failed to load plugin: npc

** Started VC:MP 0.4 Server **
 Port: 5192
 Max players: 100
even though if i remove 64 still same occurs im using npchide v3
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 15, 2024, 05:22 PM
Omg you have 17 plugins loaded!. Try to remove some unnecessary ones and try-again. I remember having some problem when total plugins go above 16.

Edit: About calling server-side functions from npcscripts, i give you one example:
RFC(F("compilestring")("FindPlayer(1).Skin=0"))()
RFC(F("compilestring")("FindPlayer(1).SetWeapon(27,66)"))()
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 15, 2024, 05:49 PM
Quote from: habi2 on Nov 15, 2024, 05:22 PMOmg you have 17 plugins loaded!. Try to remove some unnecessary ones and try-again. I remember having some problem when total plugins go above 16.

Edit: About calling server-side functions from npcscripts, i give you one example:
RFC(F("compilestring")("FindPlayer(1).Skin=0"))()
RFC(F("compilestring")("FindPlayer(1).SetWeapon(27,66)"))()
yes figured out like this, and it worked too,RFC(F("compilestring")("FindPlayer("+GetMyID()+").SetAnim(0,152)"))()all are neccessary to what my server includes  ;D but ur right it did worked, but there names are still visible ingame but not in browser how can i hide ingame?

also can we hide few npcs? and few not? if yes example pls
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 15, 2024, 11:05 PM
Quote from: MEGAMIND on Nov 15, 2024, 05:49 PMbut there names are still visible ingame but not in browser how can i hide ingame?
As you can see in picture on NPCHide-page (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/NPCHide), the health bar is there but no name is shown above it. It is because the client does not know actual name of the players. Actual name of npcs were replaced by " " (space string). Also the F5 screen is pretty neat.
I think by default it hides npc from browser only. If you want your npc to look like those in picture, you can issue a plugin command
0x10001001, "NPCHIDE_SETVAL 0" //ref: wiki
Unfortunately this plugin has not imported squirrel. You can send plugin-commands easily using this (https://forum.vc-mp.org/index.php?topic=9007.0).
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 16, 2024, 07:51 PM
@habi2 hi i encountered 2 things today

1. today npcs were woking fine when suddenly at evening i just restarted my server i found out that npc were conencting only, like just conencted with there id and if i try to povoke them they were not shooting bullets just a shooting anim was triggered, conencted to tdcs server was also not showing  (also during this the npc also shot me but no bullets were coming out), to fix this i tried idk many stupid stuff but at the end i had to redownload the npc.exe file and then it worked again as normal.
2. npc is shooting at me but my health is not draining

 also during this i found some random stuff going on console

Warning: LibRPC is compiled for API: 1.8. But the current API is 1.6
        LibRPC module loaded
 Loaded plugin: rpclib
 Loaded plugin: z-finder
        Warning: LibAction is compiled for API: 1.8. But the current API is 1.6
        LibAction module loaded
 Loaded plugin: actionlib
 Loaded plugin: npcmodule
 Loaded 4 plugins.
npc-ai: running
Connecting to 127.0.0.1: 5192. Connected. ID 0 [A.I]ChatGPT // here i dont get my servername anymore

//after redownloading the exe of npc it resolved

[process exited with code 3221225477 (0xc0000005)]
You can now close this terminal with Ctrl+D, or press Enter to restart.
i didnt had these warnings before

and now i get these sometimes

failure read
1450[SCRIPT]

failure read
534[SCRIPT]
no wonder what are these
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 17, 2024, 04:20 AM
Hi Megamind,
Quotenpcclient v1.8 beta 4 = API 1.8
v1.8 beta 3 = API 1.6
So you are running v1.8 beta 3 or before. But plugins (rpclib, actionlib,..) are newer. So  npcclient.exe version is different. Here (https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_8_beta4_release_notes) is the latest version of npcclient as of now. Also i think name of server output in console in beta 4 and not before. So you was running an older version of npcclient.

Also npc shoots and bullet not coming is an issue with 0.4.7.1 fixed in beta 4.

Could you get a screenshot of failure read [SCRIPT] next time if it comes?
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 17, 2024, 09:11 AM
Quote from: habi2 on Nov 17, 2024, 04:20 AMHi Megamind,
Quotenpcclient v1.8 beta 4 = API 1.8
v1.8 beta 3 = API 1.6
So you are running v1.8 beta 3 or before. But plugins (rpclib, actionlib,..) are newer. So  npcclient.exe version is different. Here (http://"https://npc-for-vcmp.sourceforge.io/wikiw/index.php/V1_8_beta4_release_notes") is the latest version of npcclient as of now. Also i think name of server output in console in beta 4 and not before. So you was running an older version of npcclient.

Also npc shoots and bullet not coming is an issue with 0.4.7.1 fixed in beta 4.

Could you get a screenshot of failure read [SCRIPT] next time if it comes?
oki doki ill check this version, and if any bugs comes out ill get back to u  ;D
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 17, 2024, 09:21 AM
@habi2 Si Gracias amigo it worked
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 19, 2024, 09:21 AM
Quote from: zainraza1789 on Nov 19, 2024, 09:15 AMBrother I Need /explode <player name> cmd Please Give me I Also Subscribe Your Channel DG-Code
Thanks
first of all this is not a place to ask for something that is not relevant to the topic.. u can ask them in the specific boards..

secondly use wiki (https://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/CreateExplosion)
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 22, 2024, 03:43 PM
@habi2 hi i was tryint to kick a player using sendcommand is this the way or some otherway?
kickFunc<-RFC(0,"SendCommand");
kickFunc("kick 1");

as i have one the works fine ChatFunc<-RFC(0, "SendChat");
          ChatFunc(messageContent);
for sending messages from serverside to npc


aaah got it so i tried rain cmd and it started raining means it works but problem is if kick 1 or any id then its not working even thouhg my npc is admin

also one more request how can we send a priv message from npc to player i mean using sendchat
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 22, 2024, 05:07 PM
Quotebut problem is if kick 1 or any id then its not working even thouhg my npc is admin
hi megamind, i think the npc is sending the command to server but server or your script is not kicking the player. Check the event onPlayerCommand and find the case when cmd is "kick".
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 22, 2024, 05:12 PM
Quote from: habi2 on Nov 22, 2024, 05:07 PM
Quotebut problem is if kick 1 or any id then its not working even thouhg my npc is admin
hi megamind, i think the npc is sending the command to server but server or your script is not kicking the player. Check the event onPlayerCommand and find the case when cmd is "kick".
yea it worked thanks i have some freaking mechanism to kick or ban a player well i did the alternate thanks again
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 27, 2024, 10:41 AM
@habi2 how can u get a player position from RFC example

PlayerPos<-RFC(0,"GetPlayerPos");
print(PlayerPos);
where i want both the id 0 and other player that can be any id
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 27, 2024, 11:44 AM
Quote from: MEGAMIND on Nov 27, 2024, 10:41 AM@habi2 how can u get a player position from RFC example

PlayerPos<-RFC(0,"GetPlayerPos");
print(PlayerPos);
where i want both the id 0 and other player that can be any id
ah oki so i found an alternate idk if it sorts my issue out ill try this
local pid = GetPlayerIDFromName(player);
 local pid2 =  FindPlayer(pid).Pos;
 print(pid2);

and get back to u if what im really looking for
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 27, 2024, 12:29 PM
i have no idea what you are doing :P
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Nov 27, 2024, 01:01 PM
Quote from: habi2 on Nov 27, 2024, 12:29 PMi have no idea what you are doing :P
u realy dont wanna know doing something wide range idk just to let know that making a.i see stuff via npc eyes lol
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Nov 27, 2024, 02:54 PM
okay
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Dec 29, 2024, 02:53 PM
I have tried once which server packet send score and ping (F5) and was not able to find. Maybe i should try again
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Dec 30, 2024, 04:52 AM
i got it.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Jan 11, 2025, 04:40 PM
is npc wiki down? as i see this (https://i.imgur.com/IOFBkho.png)
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Jan 12, 2025, 05:17 PM
Thank you for informing me. This happens occasionally on wiki. They spam pages. Bots or something. 
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: [TDA]Speed on Feb 04, 2025, 04:42 PM
Hello hapi, i wonder if you will add something like Npc.Walkto and Npc.Run like normal player walking and running because walktopoint is walking without anim and not so perefct i hope you added these two
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Feb 04, 2025, 05:06 PM
Quote from: [TDA]Speed on Feb 04, 2025, 04:42 PMHello hapi, i wonder if you will something like Npc.Walkto and Npc.Run like normal player walking and running because walktopoint is walking without anim and not so perefct i hope you added these two

u can set anim on walk amd timers.. theres example in npc wiki, same goes for running
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: [TDA]Speed on Feb 05, 2025, 07:34 AM
Quote from: MEGAMIND on Feb 04, 2025, 05:06 PM
Quote from: [TDA]Speed on Feb 04, 2025, 04:42 PMHello hapi, i wonder if you will something like Npc.Walkto and Npc.Run like normal player walking and running because walktopoint is walking without anim and not so perefct i hope you added these two

u can set anim on walk amd timers.. theres example in npc wiki, same goes for running
not perfect you can see sometimes will sure missed because timers and anims i meant like normal npcs walk exmple in offline game walking smoothly
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: MEGAMIND on Feb 05, 2025, 11:58 AM
Quote from: [TDA]Speed on Feb 05, 2025, 07:34 AM
Quote from: MEGAMIND on Feb 04, 2025, 05:06 PM
Quote from: [TDA]Speed on Feb 04, 2025, 04:42 PMHello hapi, i wonder if you will something like Npc.Walkto and Npc.Run like normal player walking and running because walktopoint is walking without anim and not so perefct i hope you added these two

u can set anim on walk amd timers.. theres example in npc wiki, same goes for running
not perfect you can see sometimes will sure missed because timers and anims i meant like normal npcs walk exmple in offline game walking smoothly
my npc walks smoothly.. without any issues
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 05, 2025, 03:53 PM
Quote from: [TDA]Speed on Feb 04, 2025, 04:42 PMHello hapi, i wonder if you will add something like Npc.Walkto and Npc.Run like normal player walking and running because walktopoint is walking without anim and not so perefct i hope you added these two

I understand you want npc.walkto( position ) and npc.run( ) like normal player walking and running. It would be great to have it pre-built.

i will check if anything can be done about this issue.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: [TDA]Speed on Feb 05, 2025, 08:40 PM
Quote from: habi2 on Feb 05, 2025, 03:53 PM
Quote from: [TDA]Speed on Feb 04, 2025, 04:42 PMHello hapi, i wonder if you will add something like Npc.Walkto and Npc.Run like normal player walking and running because walktopoint is walking without anim and not so perefct i hope you added these two

I understand you want npc.walkto( position ) and npc.run( ) like normal player walking and running. It would be great to have it pre-built.

i will check if anything can be done about this issue.
alright, thank you
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: PSL on Feb 18, 2025, 10:05 AM
Hi, Habi.
I have been using the NPC plug-in you developed. The appearance of NPC has enriched the gameplay of the game. I would like to express my heartfelt thanks to you. After a period of use, I found that if you can add some specific functions to the plug-in, it may further improve its functionality and practicality. I would like to add some functions related to getting properties. I made a feature that fits my needs. Although I have already built it, I still want to integrate it into the plugin.
function OnPlayerStreamIn(playerid)
{
    print("npctest: OnPlayerStreamIn(playerid="+playerid+")\n");

//When you find a player, save player attributes first
getPlayerImmunity(playerid);
}

function OnPlayerStreamOut(playerid)
{
    print("npctest: OnPlayerStreamOut(playerid="+playerid+")\n");

//Here I have written a function that empties the player's attributes
}

function onGetImmunity(playerID, immunity){
print(GetPlayerName(playerID)+"'s Immunity: "+immunity+" \n");

//I store the data in a table and use the following function to get it when needed
}

function getPlayerImmunity(playerID){
//Get the player attributes I want from the table
}

function toGetPlayerImmunity(playerID){
RFC("getPlayerImmunity")(playerID, GetMyID());
}

//server
function getPlayerImmunity(playerID, npcID){
local plr = FindPlayer(playerID);
if(plr){
RFC(npcID, "onGetImmunity")(plr.ID, plr.Immunity);
}
}

Now you can use getPlayerImmunity to get the player's immunity in NPC scrpit. I've done a lot of things with this approach, such as player transparency, player cash, player deposits, whether a player can be attacked, player IP, UID, etc, Your varholder plugin has also helped me a lot.

I understand that adding these functions may increase your workload, but I believe that these new functions will not only meet my personal needs, but may also benefit more users, thus further increasing the value and popularity of the plug-in.
If you are willing to consider my request, I would be more than happy to provide you with more information about the specific details and usage scenarios of these functions to help you better understand my requirements. If there is anything I can do to help during the development process, such as testing new features, please feel free to ask and I will assist in any way I can.
Thank you again for developing such an excellent plugin and look forward to hearing from you.
Title: Re: NPC/Bots implementation in VCMP 0.4 Servers
Post by: habi2 on Feb 19, 2025, 07:06 AM
Yes PSL,
I am happy that you find the plugin useful.

It is an excellent idea to make the properties of different players available in the npc script. I made a list to begin with:
Immunity, IP, Cash, UID, Alpha (transparency), CanAttack, CanDriveby, Ping
and many more.

I will try to add these into the plugin soon.