Closed c0dz3r closed 2 months ago
I've test this, and everything looks good:
public FCNPC_OnInit()
{
npcs[0] = FCNPC_Create("test1");
FCNPC_Spawn(npcs[0], 1, 85.2381, -232.6194, 1.5781);
foreach (new npcid : FCNPC) {
FCNPC_SetVelocity(npcid, 0.1, 0.1, 0.2, true);
}
SetTimer("timer", 1000, 1);
return 1;
}
forward timer();
public timer()
{
foreach (new npcid : FCNPC) {
new Float:x, Float:y, Float:z;
FCNPC_GetPosition(npcid, x, y, z);
printf("npc %d: %.2f, %.2f, %.2f", npcid, x, y, z);
}
}
npc 999: 89.03, -228.81, 9.17
npc 999: 92.73, -225.11, 16.57
npc 999: 96.53, -221.31, 24.17
npc 999: 100.33, -217.51, 31.77
npc 999: 104.13, -213.71, 39.37
npc 999: 107.93, -209.91, 46.97
Set a position that throws the NPC into the air or raises them into the air and they will return to their previous position
Show me your code and video.
error 017: undefined symbol "FCNPC_InitMapAndreas"
CMD:bt(playerid, params[])
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
npppcid = FCNPC_Create("BOT");
FCNPC_Spawn(npppcid, 100, x, y, z);
SetTimer("timerdebug", 1000, 1);
return 1;
}
CMD:btvelo(playerod, params[])
{
new Float:X, Float:Y, Float:Z;
FCNPC_GetVelocity(npppcid, Float:X, Float:Y, Float:Z);
/* repeat pos infinite */
FCNPC_SetVelocity(npppcid, Float:X, Float:Y, Float:Z + 0.00050, true);
return 1;
}
/* NPC bug doesn't fall in the air */
CMD:btstop(playerod, params[])
return FCNPC_SetVelocity(npppcid, Float:0.0, Float:0.0, Float:0.0, true);
Logs
npc 99: 2734.02, 1252.56, 106.53
npc 99: 2734.02, 1252.56, 106.53
npc 99: 2734.02, 1252.56, 106.53
npc 99: 2734.02, 1252.56, 106.53
npc 99: 2734.02, 1252.56, 106.53
npc 99: 2734.02, 1252.56, 106.53
[CMD] [HashHatake]: /btvelo
npc 99: 2734.02, 1252.56, 106.55
npc 99: 2734.02, 1252.56, 106.62
npc 99: 2734.02, 1252.56, 106.68
npc 99: 2734.02, 1252.56, 106.75
npc 99: 2734.02, 1252.56, 106.81
npc 99: 2734.02, 1252.56, 106.87
npc 99: 2734.02, 1252.56, 106.94
npc 99: 2734.02, 1252.56, 107.01
npc 99: 2734.02, 1252.56, 107.08
npc 99: 2734.02, 1252.56, 107.15
npc 99: 2734.02, 1252.56, 107.22
npc 99: 2734.02, 1252.56, 107.29
npc 99: 2734.02, 1252.56, 107.36
npc 99: 2734.02, 1252.56, 107.43
Inpc 99: 2734.02, 1252.56, 107.49
npc 99: 2734.02, 1252.56, 107.56
npc 99: 2734.02, 1252.56, 107.63
npc 99: 2734.02, 1252.56, 107.70
npc 99: 2734.02, 1252.56, 107.76
npc 99: 2734.02, 1252.56, 107.82
[CMD] [HashHatake]: /btstop
npc 99: 2734.02, 1252.56, 107.89
npc 99: 2734.02, 1252.56, 107.89
npc 99: 2734.02, 1252.56, 107.89
npc 99: 2734.02, 1252.56, 107.89
npc 99: 2734.02, 1252.56, 107.89
npc 99: 2734.02, 1252.56, 107.89
npc 99: 2734.02, 1252.56, 107.89
npc 99: 2734.02, 1252.56, 107.89
I can see the position changing, but slowly.
https://www.youtube.com/watch?v=UuhjiW-PsJ4
#include <a_samp>
#include "foreach"
#include "FCNPC"
new npcs[2];
main() {
}
public OnGameModeInit() {
AddPlayerClass(1, 85.0, -232.0, 1.6, 0.0, 31, 999, 0, 0, 0, 0);
return 1;
}
public FCNPC_OnInit()
{
npcs[0] = FCNPC_Create("test1");
FCNPC_Spawn(npcs[0], 1, 85.2381, -232.6194, 1.5781);
npcs[1] = FCNPC_Create("test2");
FCNPC_Spawn(npcs[1], 1, 84.2381, -231.6194, 1.5781);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/velocity", true) == 0) {
foreach (new npcid : FCNPC) {
FCNPC_SetVelocity(npcid, 0, 0, 0.02, true);
}
return 1;
}
return 0;
}
Up they go well, the problem is making them fall to the ground
Set negative velocity and reset to 0 when they reach ground
Set negative speed and reset to 0 when they hit the ground
How to detect soil?
You can use MapAndreas or ColAndreas
The function is running well, moving the axes but the last position is not saved and it always returns to the starting position Code: FCNPC SetVelocity(extraid, 0.1, 0.1, 0.2, 1);