NPC/Bots implementation in VCMP 0.4 Servers

Started by habi, Apr 01, 2022, 05:37 PM

Previous topic - Next topic

habi2

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.

PSL

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?

habi2

#107
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 (Size: 1.00 MB)
npc_vcmp_rel006_linux_x86_v1.8-beta-p1.zip (Size: 3.10 MB)
npc_vcmp_rel006_linux_x64_v1.8-beta-p1.zip (Size: 1.03 MB)
npc_vcmp_rel004_win_lin_v1.8-beta-p1.zip (Size: 2.23 MB)
npcclient-setup-v1.8-beta-p1.exe (Size: 2.19 MB)

source-code
NPC-VCMP-master-v1.8-beta-p1.zip (Size: 10.10 MB)

Note: Please make sure to update to these latest files for an enhanced NPC experience!

PSL

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.

habi2

#109
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.

PSL

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.

PSL

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.

habi2

#112
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.

PSL

This problem has been fixed perfectly, and I'm sorry to have caused you so much trouble.

habi2

No need to apologize! I'm glad that the problem is fixed.

PSL

#115
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
}

habi2

#116
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()

PSL

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.

vitovc

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.
...::: vice city :::...

PSL

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.