SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 25/04/2016, 12:43 PM   #1001
Mauzen
Godfather
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 5,118
Reputation: 1535
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

A slow or stressed HDD maybe, usually creating 20 short movements shouldnt be that slow.
(Edit 2: just noticed you move the NPCs to 0.0 0.0 0.0 from their current position. This can be a long distance, resulting in a really big recording file, thus explaining why its that slow. Is this really what you want to do? The function name suggests something else.)

Are you running the server on linux, and do you have root ssh access to it? Im experimenting with a way to greatly speed it up for people who have that, you could try it then if you like (its just a series of a few bash commands) The same principle also works on Windows, but its much more complicated there.

Edit: Finally I did some testing (first time I launched a samp server for almost a year, according to logfiles), it all works as expected (except for the need for sudo, I didnt think of that before. So only root users can use this improvement yet. Thats bad, but no catastrophe, maybe there are ways around this that I didnt think of yet)

On my server build-generation worked about 20 times(!) faster, theres even room for more on other servers, as my server's hdd is quite fast.
(Measured the time for creating 500 medium-sized recordings: 1100ms on normal HDD, 55ms with the new method)

For those who didnt get what Im talking about yet: its a short bash script for mounting a ramdisk in place of the recordings folder, so rec files are handled in RAM instead of taking the physical detour. Its a logical step to do that, as the HDD access is by far the slowest part of RNPC.
If someone wants to try it, send me a PM.

Last edited by Mauzen; 25/04/2016 at 11:37 PM.
Mauzen is offline   Reply With Quote
Old 02/05/2016, 03:46 AM   #1002
Swedky
Banned
 
Join Date: Jun 2013
Location: Argentina.
Posts: 2,100
Reputation: 827
Default Respuesta: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

I don't know why, but still I'm having same problem (maybe is my computer?). So I have to move the NPC to a short distance?

Speed test:
Code:
[23:44:24] 390
[23:44:25] 696
[23:44:25] 280
[23:44:26] 402
[23:44:26] 340
[23:44:27] 751
[23:44:28] 249
[23:44:28] 403
[23:44:29] 405
[23:44:29] 324
[23:44:30] 590
[23:44:32] 1450
[23:44:32] 247
[23:44:32] 287
[23:44:33] 286
[23:44:34] 302

EDIT: Yes, moving the NPCs at a distance of 2.0mtrs was the way (now I'm a little happy):
Code:
[23:48:32] 60
[23:48:32] 96
[23:48:33] 60
[23:48:33] 91
[23:48:34] 60
[23:48:34] 59
[23:48:35] 104
[23:48:35] 90
[23:48:36] 77
[23:48:36] 57
[23:48:37] 88
[23:48:38] 58
[23:48:38] 58
[23:48:39] 60
[23:48:39] 66
[23:48:40] 58
[23:48:40] 104
[23:48:41] 59
[23:48:41] 59
[23:48:42] 59
Swedky is offline   Reply With Quote
Old 07/05/2016, 05:07 PM   #1003
Xolokos
Little Clucker
 
Xolokos's Avatar
 
Join Date: Dec 2010
Posts: 23
Reputation: 0
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

The plugin works for the 0.3.7 R2 ? Or only for the 0.3.7 ?
Moreover if it's not that my server crash when I use RNPC functions : the bot connect perfectly but when I'm in its range he should follow me but instead the server crash.

HTML Code:
forward RFollowPlayer(npcid);
public RFollowPlayer(npcid)
{
	new Float:zx, Float:zy, Float:zz,Float:x, Float:y, Float:z;
	for(new i = 0 ;i<MAX_PLAYERS;i++)
	{
	    if(!IsPlayerNPC(i))
	    {
			if (IsPlayerConnected(i))
			{
				GetPlayerPos(npcid, zx, zy, zz);
				if(IsPlayerInRangeOfPoint(i,RangeZ[i],zx,zy,zz))
				{
					GetPlayerPos(i,x,y,z);
					RNPC_SetUDKeys(KEY_UP);
					MoveRNPC(npcid,x,y,z,RNPC_SPEED_RUN,1);
				}
				else
				{
				    Range[i] = 20;
				}
			}
		}
	}
	return 1;
}
Xolokos is offline   Reply With Quote
Old 28/10/2016, 01:29 AM   #1004
NealPeteros
Gangsta
 
NealPeteros's Avatar
 
Join Date: Dec 2015
Location: GetPlayerCountry(playerid);
Posts: 523
Reputation: 41
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

Is there any function or callback that removes all the NPCs upon unloading a filterscript or a gamemode?
__________________
Quote:
IRL Description:
  • Neal Andrew Peteros
  • 13 years old
  • Philippines
  • C, C++, Java, Javascript, PAWN, Python Programmer
Leaving SA-MP for a while. SCHOOL! ♥
NealPeteros is offline   Reply With Quote
Old 29/10/2016, 02:00 PM   #1005
Mauzen
Godfather
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 5,118
Reputation: 1535
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

Quote:
Originally Posted by NealPeteros View Post
Is there any function or callback that removes all the NPCs upon unloading a filterscript or a gamemode?
No, but you can easily do that:
Code:
for (new i = 0; i < MAX_PLAYERS; i++) {
    if (IsPlayerRNPC(i)) Kick(i);
}
Mauzen is offline   Reply With Quote
Old 06/12/2016, 09:46 AM   #1006
PrettyDiamond
Big Clucker
 
Join Date: Jun 2015
Location: Germany
Posts: 66
Reputation: 5
Question Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

I use this script for testing because i want load zombies on my server. I trying a lot of days, but for me nothing works...

Code:
// ------------- NPC zombie test and example script
// RNPC 0.4 (26.6.2014) - Mauzen

// Use ConnectZombieBots(playerid, amount)
// to create <amount> zombie bots that keep following <playerid>
// They wont attack but can be killed for tests and stuff
// Either initialize MapAndreas properly, or go to line 78
// and change the last 1 in MoveRNPC to a 0
#define FILTERSCRIPT

#include <a_samp>
#include <rnpc>//Credits: Mauzen

new rnpcZombie[MAX_PLAYERS];
new rnpcZTimer[MAX_PLAYERS];

stock ConnectZombieBots(playerid, amount)
{
    new name[24];
    new id;
    // spawn the given amount of NPCs
    while(amount-- > 0)
	{
        format(name, 24, "Zombie_%d", 500-amount);
        id = ConnectRNPC(name);
        // Store their target player
        rnpcZombie[id] = playerid;
    }
}

public OnPlayerSpawn(playerid)
{
	if(IsPlayerNPC(playerid))
    {
		if (rnpcZombie[playerid] > 0)
		{
	        // Enable RNPC damage management
	        RNPC_SetShootable(playerid, 1);
	        RNPC_ToggleVehicleCollisionCheck(playerid, 1);

	        // Random skin for datz fun
	        SetPlayerSkin(playerid, random(299));

	        // Change name to avoid name collisions
	        new name[24];
	        format(name, 24, "Zombie_%d", playerid);
	        SetPlayerName(playerid, name);

	        // Spawn zombie somewhere in area around player
	        new Float:x, Float:y, Float:z;
	        GetPlayerPos(rnpcZombie[playerid], x, y, z);
	        x = x - 30.0 + random(60);
	        y = y - 30.0 + random(60);
	        // Set to position on ground
	        MapAndreas_FindZ_For2DCoord(x, y, z);
	        SetPlayerPos(playerid, x, y, z+0.7);

	        // If it was a respawn, kill the old timer
	        if (rnpcZTimer[playerid] > 0) KillTimer(rnpcZTimer[playerid]);
	        // Make him follow the player
	        rnpcZTimer[playerid] = SetTimerEx("RFollowPlayer", 5000, 1, "i", playerid);
	    }
    }
    #if defined RNPC_OnPlayerSpawn
            return RNPC_OnPlayerSpawn(playerid);
    #else
            return 1;
    #endif
}
#if defined _ALS_OnPlayerSpawn
        #undef OnPlayerSpawn
#else
        #define _ALS_OnPlayerSpawn
#endif
#define OnPlayerSpawn RNPCZ_OnPlayerSpawn
forward RNPCZ_OnPlayerSpawn(playerid);

forward RFollowPlayer(npcid);
public RFollowPlayer(npcid)
{
    if (IsPlayerConnected(rnpcZombie[npcid]))
	{
        new Float:x, Float:y, Float:z;
        GetPlayerPos(rnpcZombie[npcid], x, y, z);
        // Move RNPC to random point in area around target player
        MoveRNPC(npcid, x - 3.0 + random(600) / 100.0, y - 3.0 + random(600) / 100.0, z, RNPC_SPEED_RUN, 1);
    }
}
Anyone can help me with this please?

Plugin Loaded:
Quote:
[10:28:40] Loaded.
[10:28:40] Loading plugin: RNPC.so
[10:28:40] RNPC V0.4.1 by Mauzen (03.12.2014)
But then this:

Code:
[10:30:56] [debug] Run time error 3: "Stack/heap collision (insufficient stack size)"
[10:30:56] [debug]  Stack pointer (STK) is 0xB758, heap pointer (HEA) is 0xB71C
[10:30:56] [debug] AMX backtrace:
[10:30:56] [debug] #0 00002ccc in public RNPC_OnPlayerSpawn (0) from zombie.amx
I have 200 NPCs und 300maxplayers in server.cfg

After i searching about:
Code:
Run time error 3: "Stack/heap collision (insufficient stack size)
i remove this from script:

Code:
    #if defined RNPC_OnPlayerSpawn
            return RNPC_OnPlayerSpawn(playerid);
    #else
            return 1;
    #endif
}
#if defined _ALS_OnPlayerSpawn
        #undef OnPlayerSpawn
#else
        #define _ALS_OnPlayerSpawn
#endif

#define OnPlayerSpawn RNPCZ_OnPlayerSpawn
forward RNPCZ_OnPlayerSpawn(playerid);
and put in:
Code:
public OnPlayerSpawn(playerid)
this:

Code:
public OnPlayerSpawn(playerid)
{
	if(IsPlayerNPC(playerid))
    {
but now npcs doesnt join??
__________________

Last edited by PrettyDiamond; 06/12/2016 at 10:17 AM.
PrettyDiamond is offline   Reply With Quote
Old 20/03/2017, 06:56 PM   #1007
WildWave
Big Clucker
 
WildWave's Avatar
 
Join Date: May 2014
Posts: 73
Reputation: 12
Default Re: RNPC - Recordfree NPCs | Control NPCs without recording | DEV

When im trying to upload my zombies to windows sever they connected successfully but when im trying to upload the zombies on linux server, they wont go up.

http://pastebin.com/Zhpgzd4u
__________________
My Scripts : (2)

Basic Admin System
SavedSkin System
WildWave is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control NPCs using Paths? Programie Scripting Help 2 16/06/2012 03:49 PM
Help with recording two npcs at once marharth Help Archive 3 13/08/2010 04:14 AM
Recording NPCs animation with new version (0.3b) Hernaner28 Help Archive 0 12/08/2010 02:17 AM
No NPCs regdude Server Support 5 08/07/2010 06:54 PM
[HELP] Npcs armyoftwo Help Archive 3 05/12/2009 09:43 AM


All times are GMT. The time now is 08:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.