Player vs NPC's VW, rep+ -
cdoubleoper - 19.07.2016
Okay, so basically I have no idea how to set the npc's virtual world the same as the player's one.
Код:
public OnPlayerSpawn(playerid)
{
new worldid = playerid+1;
if(!IsPlayerNPC(playerid))
{
SetPlayerVirtualWorld(playerid, worldid);
//then
if(IsPlayerNPC(playerid))
{
SetPlayerVirtualWorld(playerid, worldid);
In this case NPC's vw will be its playerid+1, but I need to set it to the spawned player's one.
Any idea?
Re: Player vs NPC's VW, rep+ -
GuyB790 - 19.07.2016
By "// then" you mean another callback in the code?
If so save a global variable with that information.
Re: Player vs NPC's VW, rep+ -
cdoubleoper - 19.07.2016
nah it is still the same callback, but you know the thing is - when I spawn with the ID 4, then my virtual world is supposed to be 5. NPC has the ID 5 for example, then its virtual world will be set at number 6 - but I need it to be the same as player's one. This is so messed up.
Re: Player vs NPC's VW, rep+ -
Dayrion - 19.07.2016
Quote:
Originally Posted by cdoubleoper
Okay, so basically I have no idea how to set the npc's virtual world the same as the player's one.
Код:
public OnPlayerSpawn(playerid)
{
new worldid = playerid+1;
if(!IsPlayerNPC(playerid))
{
SetPlayerVirtualWorld(playerid, worldid);
//then
if(IsPlayerNPC(playerid))
{
SetPlayerVirtualWorld(playerid, worldid);
In this case NPC's vw will be its playerid+1, but I need to set it to the spawned player's one.
Any idea?
|
For the first player only ? If yes, something like this ?
PHP код:
public OnPlayerSpawn(playerid)
{
new worldid = playerid+1;
if(!IsPlayerNPC(playerid))
{
SetPlayerVirtualWorld(playerid, worldid);
//then
if(IsPlayerNPC(playerid) && playerid + 1 = 1)
{
SetPlayerVirtualWorld(playerid, worldid);
Re: Player vs NPC's VW, rep+ -
GuyB790 - 19.07.2016
Does the NPC connect & spawn necessarily after each playerm? If so you can just decrease the ID.
Otherwise save a player's VW in a variable and once looking for the playerid of the NPC then put it according to the stored virtual world (in like, pVirtualWorld[MAX_PLAYERS]).
Re: Player vs NPC's VW, rep+ -
PrO.GameR - 19.07.2016
PHP код:
if(IsPlayerNPC(playerid))
{
SetPlayerVirtualWorld(playerid, playerid);
}
Like that? I don't know how you spawn NPCs but I'm assuming when 1 player connects you connect a NPC for them, right?
if not you should make an array keeping a list of which NPC is in which player's world, when a player connects assign one of the NPCs to the player.
Re: Player vs NPC's VW, rep+ -
cdoubleoper - 19.07.2016
Quote:
Originally Posted by GuyB790
Does the NPC connect & spawn necessarily after each playerm? If so you can just decrease the ID.
Otherwise save a player's VW in a variable and once looking for the playerid of the NPC then put it according to the stored virtual world (in like, pVirtualWorld[MAX_PLAYERS]).
|
Okay. I got 3 NPCs and each has divided worldid (first one -1, the second one -2, third -3).
Seems like it is working with 2 players, but I'm kind of afraid how it is going to react while many players are spawning at the same time.
Re: Player vs NPC's VW, rep+ -
GuyB790 - 19.07.2016
Quote:
Originally Posted by cdoubleoper
Okay. I got 3 NPCs and each has divided worldid (first one -1, the second one -2, third -3).
Seems like it is working with 2 players, but I'm kind of afraid how it is going to react while many players are spawning at the same time.
|
If you're planning to have an NPC for each player's virtual world you should read this:
https://sampforum.blast.hk/showthread.php?tid=102196 .
It's about the idea of the same NPC for multiple VWs (tl;dr - it's impossible as far as I understood)