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
Nice work!
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!
A long wait came to reality, thanks
@habi + a video tutorial about implementing and creating an npc would be appreciated
Impressive :o
This looks amazing!
(Though I'm not sure if I'll go through the pain of working with the squirrel plugin again)
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.
The older plugin "actor" is very similar to this? Why rewrite it?
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 " )
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]
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.
Amazing work, bringing life to the world!
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!
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
https://forum.vc-mp.org/?topic=8952
here is a short video I made while testing out the server
Pure Awesome!
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...
bro, u always improving something and surprising us a lot, thanks ;D ;D
ok, i will look into it.
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);
}
}
*/
:)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)
Alright, will test it this weekend
Thank you!
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
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
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
Quote from: habi on Dec 10, 2022, 02:12 PMQuote 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! :)
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?
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.
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.
Quote from: habi on Dec 19, 2022, 08:15 AMQuote 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!
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
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.
@Mikimon another option would be adding the line
anticheat 0
to server.cfg
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 " )
Good release!
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)
Quick fix! Thank you habi!
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.)
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
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)
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
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
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.
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
Habi bro, Im having an issue. This is pterodactyl panel
(https://i.ibb.co/jLzG2fy/habi.png)
Can you help me pls? ::)
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?
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.
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)
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.
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.
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'.
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.
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?
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.
Quote from: habi on May 23, 2023, 03:28 PMQuote 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
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)
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.
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.
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)
News: v1.7 beta releasedChangelog- NPC can now use pickups, checkpoints, and objects.
- Fixed disconnection/crash issue when using Vector._tostring method.
- Fixed bugs related to crouching, reloading, and checking player actions.
- Set console foreground intensity for windows console. It looks better now.
DownloadsWindows | npc_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 x64 | npc_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 x86 | npc_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 Setup | npcclient-setup-v1.7-beta.exe (https://sourceforge.net/projects/npc-for-vcmp/files/npcclient-setup-v1.7-beta.exe/download) |
Source Code | NPC-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- IsPickupStreamedIn(pickupid);
Description: Checks if a pickup is streamed in for NPCs.
Parameters:
- pickupid: ID of the pickup to check.
Returns: Whether the pickup is streamed in (true) or not (false).
- GetPickupModel(pickupid);
Description: Gets the model of a pickup.
Parameters:
- pickupid: ID of the pickup to query.
Returns: Model ID of the pickup.
- GetPickupAlpha(pickupid);
Description: Gets the alpha value of a pickup.
Parameters:
- pickupid: ID of the pickup to query.
Returns: Alpha value of the pickup.
- GetPickupQuantity(pickupid);
Description: Gets the quantity of items in a pickup.
Parameters:
- pickupid: ID of the pickup to query.
Returns: Quantity of items in the pickup.
- GetPickupPos(pickupid);
Description: Gets the position of a pickup.
Parameters:
- pickupid: ID of the pickup to query.
Returns: Position of the pickup as a vector.
- GetPickupCount();
Description: Gets the total count of pickups.
Returns: Total count of pickups.
- ClaimPickup(pickupid);
Description: Claims a pickup for a player.
Parameters:
- pickupid: ID of the pickup to claim.
Returns: Whether the pickup was successfully claimed (true) or not (false).
- GetVehicleDriver(vehicleid);
Description: Gets the driver of a vehicle.
Parameters:
- vehicleid: ID of the vehicle to query.
Returns: ID of the driver player or NPC.
- GetVehicleModel(vehicleid);
Description: Gets the model of a vehicle.
Parameters:
- vehicleid: ID of the vehicle to query.
Returns: Model ID of the vehicle.
- GetVehicleTurretRot(vehicleid);
Description: Gets the turret rotation of a vehicle.
Parameters:
- vehicleid: ID of the vehicle to query.
Returns: Turret rotation as a vector.
- GetVehicleRotation(vehicleid);
Description: Gets the rotation of a vehicle.
Parameters:
- vehicleid: ID of the vehicle to query.
Returns: Rotation as a quaternion.
- GetVehiclePos(vehicleid);
Description: Gets the position of a vehicle.
Parameters:
- vehicleid: ID of the vehicle to query.
Returns: Position as a vector.
- GetVehicleSpeed(vehicleid);
Description: Gets the speed of a vehicle.
Parameters:
- vehicleid: ID of the vehicle to query.
Returns: Speed of the vehicle.
- GetVehicleHealth(vehicleid);
Description: Gets the health of a vehicle.
Parameters:
- vehicleid: ID of the vehicle to query.
Returns: Health of the vehicle.
- GetVehicleDamage(vehicleid);
Description: Gets the damage of a vehicle.
Parameters:
- vehicleid: ID of the vehicle to query.
Returns: Damage of the vehicle.
- GetPlayerSpeed(playerid);
Description: Gets the speed of a player.
Parameters:
- playerid: ID of the player to query.
Returns: Speed of the player.
- IsCheckpointStreamedIn(checkpointid);
Description: Checks if a checkpoint is streamed in for NPCs.
Parameters:
- checkpointid: ID of the checkpoint to check.
Returns: Whether the checkpoint is streamed in (true) or not (false).
- GetCheckpointRadius(checkpointid);
Description: Gets the radius of a checkpoint.
Parameters:
- checkpointid: ID of the checkpoint to query.
Returns: Radius of the checkpoint.
- GetCheckpointPos(checkpointid);
Description: Gets the position of a checkpoint.
Parameters:
- checkpointid: ID of the checkpoint to query.
Returns: Position of the checkpoint as a vector.
- GetCheckpointColor(checkpointid);
Description: Gets the color of a checkpoint.
Parameters:
- checkpointid: ID of the checkpoint to query.
Returns: Color of the checkpoint in a table.
- IsCheckpointSphere(checkpointid);
Description: Checks if a checkpoint is a sphere.
Parameters:
- checkpointid: ID of the checkpoint to query.
Returns: Whether the checkpoint is a sphere (true) or not (false).
- ClaimEnterCheckpoint(checkpointid);
Description: Claims entering a checkpoint.
Parameters:
- checkpointid: ID of the checkpoint to claim.
Returns: Whether entering the checkpoint was successful (true) or not (false).
- ClaimExitCheckpoint(checkpointid);
Description: Claims exiting a checkpoint.
Parameters:
- checkpointid: ID of the checkpoint to claim.
Returns: Whether exiting the checkpoint was successful (true) or not (false).
- IsObjectStreamedIn(objectid);
Description: Checks if an object is streamed in for NPCs.
Parameters:
- objectid: ID of the object to check.
Returns: Whether the object is streamed in (true) or not (false).
- GetObjectModel(objectid);
Description: Gets the model of an object.
Parameters:
- objectid: ID of the object to query.
Returns: Model ID of the object.
- GetObjectPos(objectid);
Description: Gets the position of an object.
Parameters:
- objectid: ID of the object to query.
Returns: Position of the object as a vector.
- GetObjectRotation(objectid);
Description: Gets the rotation of an object.
Parameters:
- objectid: ID of the object to query.
Returns: Rotation of the object as a quaternion.
- GetObjectAlpha(objectid);
Description: Gets the alpha value of an object.
Parameters:
- objectid: ID of the object to query.
Returns: Alpha value of the object.
- IsObjectTouchReportEnabled(objectid);
Description: Checks if touch reporting is enabled for an object.
Parameters:
- objectid: ID of the object to check.
Returns: Whether touch reporting is enabled (true) or not (false).
- IsObjectShotReportEnabled(objectid);
Description: Checks if shot reporting is enabled for an object.
Parameters:
- objectid: ID of the object to check.
Returns: Whether shot reporting is enabled (true) or not (false).
- ClaimObjectTouch(objectid);
Description: Claims touching an object.
Parameters:
- objectid: ID of the object to claim.
Returns: Whether touching the object was successful (true) or not (false).
- ClaimObjectShot(objectid, weaponid);
Description: Claims shooting an object.
Parameters:
- objectid: ID of the object to claim.
- weaponid: ID of the weapon used for shooting.
Returns: Whether shooting the object was successful (true) or not (false).
- GetCheckpointCount();
Description: Gets the total count of checkpoints.
Returns: Total count of checkpoints.
- GetObjectCount();
Description: Gets the total count of objects.
Returns: Total count of objects.
Callbacks/Events- OnPickupStreamIn(pickupid);
Description: Triggered when a pickup is streamed in.
Parameters:
- pickupid: ID of the streamed-in pickup.
- OnPickupDestroyed(pickupid);
Description: Triggered when a pickup is destroyed.
Parameters:
- pickupid: ID of the destroyed pickup.
- OnPickupUpdate(pickupid, updateType);
Description: Triggered when a pickup is updated.
Parameters:
- pickupid: ID of the updated pickup.
- updateType: Type of update.
- OnCheckpointStreamIn(checkpointId);
Description: Triggered when a checkpoint is streamed in.
Parameters:
- checkpointId: ID of the streamed-in checkpoint.
- OnCheckpointDestroyed(checkpointId);
Description: Triggered when a checkpoint is destroyed.
Parameters:
- checkpointId: ID of the destroyed checkpoint.
- OnCheckpointUpdate(checkpointId, updateType);
Description: Triggered when a checkpoint is updated.
Parameters:
- checkpointId: ID of the updated checkpoint.
- updateType: Type of update.
- OnObjectStreamIn(objectid);
Description: Triggered when an object is streamed in.
Parameters:
- objectid: ID of the streamed-in object.
- OnObjectDestroyed(objectid);
Description: Triggered when an object is destroyed.
Parameters:
- objectid: ID of the destroyed object.
- OnObjectUpdate(objectid, updateType);
Description: Triggered when an object is updated.
Parameters:
- objectid: ID of the updated object.
- updateType: Type of update.
- OnTimeWeatherSync(timerate, minute, hour, weather);
Description: Triggered when time and weather details are send by server.
Parameters:
- timerate: Timerate value.
- minute: Current minute.
- hour: Current hour.
- weather: Weather value.
*above documentation generated by cgpt.
Note: Ensure to report any bugs or issues you encounter during usage.
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
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?
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);
}
I will check it evening.
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
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
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();
}
Oh my God, this problem is solved, thank you so much, now npc can stop shooting normally, your plugin is great.
you are welcome.
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).
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
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;
}
}
}
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
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;
}
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.
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.exerawcap 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);
}
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
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
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.
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.
You're welcome! I'm glad to hear that the issue has been resolved and that the NPC is no longer getting kicked.
NPC v1.7 Beta 3 Released - Changelog
QuoteFixed NPC getting kicked when setting armor/health/weapon from server-side
Download Links:rel006Windows: 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)
rel004Windows+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.
(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:- View Recordings: Seamlessly view .rec files and gain insights into your recorded data.
- Edit and Modify: Easily fine-tune and adjust your recordings.
- Export to Excel: Analyze your data with precision using Excel.
- Drag and Drop: Simplify your workflow by dragging and dropping .rec files into the editor.
Unlock the full potential of your recorded data with the 'NPC Playback File Editor.'
How to Get Started:- Download the 'NPC Playback File Editor' from our
- Launch the program and start editing, modifying, exporting, and importing your .rec files with ease.
Download now (https://www.mediafire.com/file/bt7q3a6e8gs1m1e/recEdit.zip/file) and elevate your .rec file handling!
Best Regards,
habi
Well done, Habi That'll be can see clearly.
Habi, NPC Wiki is 404 :C
Thankyou PSL, it was database problem and is now solved.
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.
Quote from: PSL on Feb 03, 2024, 05:39 AMHello, 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.
Simple create a link https://en.wikipedia.org/wiki/Ln_(Unix)
Oh, my God, this is not simple.
Quote from: PSL on Feb 03, 2024, 09:48 AMOh, my God, this is not simple.
https://npc-for-vcmp.sourceforge.io/wikiw/index.php/Server.cfg
in future version it will be possible
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.
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.
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?
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.
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.
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
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.
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?
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.
Hi Habi, I'll try this tomorrow. Thank you for your teaching. I already understand.
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
}
}
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.
Hi Habi, I am glad to know that you are traveling. I wish you a fruitful journey and a pleasant and unforgettable trip.
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.
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)
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.
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?
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 FilesReleased on: 29-02-2024Downloadsnpc_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!
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.
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.
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.
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.
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.
This problem has been fixed perfectly, and I'm sorry to have caused you so much trouble.
No need to apologize! I'm glad that the problem is fixed.
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
}
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()
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.
Quote from: PSL on Mar 11, 2024, 10:41 AMWhen the NPC is in the vehicle and is the driver, the vehicle cannot pass the Vehicle.AddSpeed to add speed.
its not a bug, same with idle (afk/away) player. addspeed works only when vehicle's syncer (player) is not away. you need to hande vehicle speed/pos by NPC's code, the driver of a car. its only correct method.
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.