Drift NPC Tutorial please help.. -
audifan00 - 10.11.2010
hey all, i made a bot (npc) which drift on bigear road to the bottom.
Once it reaches the bottom it stays there because i removed auto start all the time.
Now i was wondering is it possible to make like if player type "/drift1tut" bot will show up and drift it and he will stay at the bottom until someone else calls him "/drift1tut" and he respawn..
i did this too:
Quote:
if (strcmp(cmdtext, "/drift1tut", true)==0)
{
ConnectNPC("drifter1","drifter1");
return 1;
}
|
This spawns the bot and he drives to the bottom and stops, thats was kinda what i want, but if i type /drift1tut again nothing happens ofc because he is already connected..
I wonder maybe there is a way that he will reach the bottom and disconnect automaticaly then people type that command and connect him again or something?..
I spent figuring it out 3 hrs trying all diff ways but i still cant get it to respawn..
id be really happy if someone could help me out here
thank you
Re: Drift NPC Tutorial please help.. -
Kwarde - 10.11.2010
I've heard that you only can connect an NPC one time.
Try to kick the NPC and then reconnect? (That won't work, probaly)
So I know a GREAT plugin for you, so you don't need to record ANYTHING
Here it is:
https://sampforum.blast.hk/showthread.php?tid=174671
Then you can Create a NPC:
CreateNPC(npcid, name[]) note that the 'npcid' is really a kind of a 'playerid', if you give it a ID of a player that already exists, the player will crash
But whatever, after that, you can 'SetNPCPos' 'PutNPCInVehicle' etc...
And to let it drive: 'NPC_DriveTo'
And you can let the walk the NPC to the vehicle, and then use the 'NPCSetKeys' to let him enter the vehicle
Good luck
Re: Drift NPC Tutorial please help.. -
audifan00 - 10.11.2010
thanks for reply.
But i have no idea how to use this, i mean i installed plugin and what now O_o
Re: Drift NPC Tutorial please help.. -
audifan00 - 10.11.2010
i tried putting this in my gamemode:
if (strcmp(cmdtext, "/drift1tut", true)==0)
{
native CreateNPC(0,drifter1[]);
return 1;
}
but i get errors
D:\Server\server\gamemodes\1337.pwn(8311) : error 029: invalid expression, assumed zero
D:\Server\server\gamemodes\1337.pwn(8311) : error 017: undefined symbol "CreateNPC"
Re: Drift NPC Tutorial please help.. -
audifan00 - 10.11.2010
where do i place CreateNPC and all that? could you show me example?
please as much info a possible cuz im not as good
thanks
Re: Drift NPC Tutorial please help.. -
Kwarde - 10.11.2010
pawn Код:
if (strcmp(cmdtext, "/drift1tut", true)==0)
{
CreateNPC(0, "Drifter 1");
return 1;
}
This will only connect the NPC.
Re: Drift NPC Tutorial please help.. -
Rainbow_Six - 10.11.2010
//Nvm...
Re: Drift NPC Tutorial please help.. -
TyreXel - 10.11.2010
pawn Код:
forward KickNPCOnPoint();
new npcdrifttimer;
public OnFilterScriptInit() // or OnGameModeInit
{
npcdrifttimer = SetTimer("KickNPCOnPoint", 1000, 1);
return 1;
}
public OnFilterScriptExit() // or OnGameModeExit
{
KillTimer(npcdrifttimer);
}
public KickNPCOnPoint()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerToPoint(5.0,i,coordonates)) // Change with your coordonates where you want the NPC to be kicked
{
if(IsPlayerNPC(i))
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(i, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "npc_name", true)) //Checking if the NPC's name is ....
{
Kick(i);
}
}
}
}
}
return 1;
}
I didn't test it ...
Re: Drift NPC Tutorial please help.. -
audifan00 - 10.11.2010
that is very nice what you made but..
Thats how i have it with co-ords and so on:
Quote:
public KickNPCOnPoint()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerToPoint(5.0,i,-429.1989,1412.5939,31)) // Change with your coordonates where you want the NPC to be kicked
{
if(IsPlayerNPC(i))
{
new drifter1[MAX_PLAYER_NAME];
GetPlayerName(i, drifter1, sizeof(drifter1)); //Getting the NPC's name.
if(!strcmp(drifter1, "drifter1", true)) //Checking if the NPC's name is ....
{
Kick(i);
}
}
}
}
}
return 1;
}
|
but when npc joins he gets kicked same second not even reaching the point :/
and i got 3 warnings too:
D:\Server\server\gamemodes\1337.pwn(13346) : warning 206: redundant test: constant expression is non-zero
D:\Server\server\gamemodes\1337.pwn(13350) : warning 219: local variable "drifter1" shadows a variable at a preceding level
D:\Server\server\gamemodes\1337.pwn(134) : warning 204: symbol is assigned a value that is never used: "npcdrifttimer"
Re: Drift NPC Tutorial please help.. -
audifan00 - 10.11.2010
never mind i just made timer a bit longer
thanks a lot REALLY HELPED!!!
(since i spent 5 hrs trying to do, and it is that simple..)
officially: I am noob