Every next player who register different VW -
Saddin - 22.09.2015
I want to set different Virtual World for each player who register, so...
1. player who register - vw 1
2. player who register - vw 2
3. player who register - vw 3
etc...
and than later, after each of them do some condition to set that player to vw 0 - default
Re: Every next player who register different VW -
Jastak - 22.09.2015
when a player registers adds this.
Код:
SetPlayerVirtualWorld(playerid, playerid+1);
Re: Every next player who register different VW -
Saddin - 22.09.2015
what if, for example
Name_Surname1 - VW 1
Name_Surname2 - VW 2
Name_Surname3 - VW 3 ... and so on
and player Name_Surname2 leave, Name_Surname4 enter server and get ID 2, his VW will be the same as player Name_Surname2 who left the server, right?
Re: Every next player who register different VW -
OllieSimons - 22.09.2015
Yes, that's what'll happen.
Re: Every next player who register different VW -
Saddin - 22.09.2015
I know that will happen...
Can we make it throught array somehow? or.. idk what is the best possible way to make it?
Re: Every next player who register different VW -
OllieSimons - 22.09.2015
Just add a global variable and increment it each time a player registers. Every new player will get a new VW and you just have to store the VW for each player in your register system. When they login they'll have to spawn in the stored VW.
Re: Every next player who register different VW -
Sew_Sumi - 22.09.2015
Quote:
Originally Posted by Saddin
I know that will happen...
|
It'll happen, but does it really matter?
They're not in the same VW as anyone else.
Quote:
Originally Posted by OllieSimons
Just add a global variable and increment it each time a player registers. Every new player will get a new VW and you just have to store the VW for each player in your register system. When they login they'll have to spawn in the stored VW.
|
And then what will happen, is when 2 players are "in" and they have the same VW "stored" then they'll encounter each other.
By staying on the playerid+1, you avoid that entirely.
Re: Every next player who register different VW -
rappy93 - 22.09.2015
Quote:
Originally Posted by Sew_Sumi
It'll happen, but does it really matter?
They're not in the same VW as anyone else.
And then what will happen, is when 2 players are "in" and they have the same VW "stored" then they'll encounter each other.
By staying on the playerid+1, you avoid that entirely.
|
If you don't want players to encounter each other this is the best way since two players with the same ID can't be connected at the same time.
Re: Every next player who register different VW -
OllieSimons - 23.09.2015
Quote:
Originally Posted by Sew_Sumi
And then what will happen, is when 2 players are "in" and they have the same VW "stored" then they'll encounter each other.
By staying on the playerid+1, you avoid that entirely.
|
Every new player will recieve an entirely new VW, they won't encounter. You have a limit of VWs, 2,147,483,647, but good luck reaching so many players.
Re: Every next player who register different VW -
Sew_Sumi - 23.09.2015
Quote:
Originally Posted by Jastak
when a player registers adds this.
Код:
SetPlayerVirtualWorld(playerid, playerid+1);
|
Quote:
Originally Posted by Saddin
I dont want two players in same VW, what should i use than, global variable? can you give an example?
|
Use what Jastak put.
No-one will code it for you, but this would be the better plan, to simply have them set to a VW a few higher than the playerid, not stored, simply used until login/register.
If you do need someone to code for you
https://sampforum.blast.hk/showthread.php?tid=447813
Quote:
Originally Posted by OllieSimons
Every new player will recieve an entirely new VW, they won't encounter. You have a limit of VWs, 2,147,483,647, but good luck reaching so many players.
|
No need to even go above the number of players on. As stated, the playerids, will never match. Could even go +4 if you wanted to have the first few VWs reserved.
Or would you rather have redundant, non-relevant data, stored in inis, to make everything a bit more clogged though...
Re: Every next player who register different VW -
Saddin - 23.09.2015
I was thinking making it in way that i know who is first who registered, who is second, who is 10. and so on... something like array?
Re: Every next player who register different VW -
karemmahmed22 - 23.09.2015
For the VWs question:
OnPlayerConnect:-
PHP код:
SetPlayerVirtualWorld(playerid,playerid);
Done? :/
Re: Every next player who register different VW -
Dokins - 23.09.2015
Are you storing the VW or just doing it when they connect? All you would need to do, as Karem said is make the VW the same as playerid and it will never be the same as another.
Re: Every next player who register different VW -
Saddin - 23.09.2015
i think that will work, how do i know who is for example 1. player who registered, who is 5. and who is 10. player?
Re: Every next player who register different VW -
Sew_Sumi - 24.09.2015
Quote:
Originally Posted by Saddin
i think that will work, how do i know who is for example 1. player who registered, who is 5. and who is 10. player?
|
You are better off simply doing playerid+1 for the VW, and if you want to know who registered in what order, make a variable in thier user files.
There is no need to keep assigning them the VW after they have registered, so there's no use storing/reusing that VW.
Quote:
Originally Posted by karemmahmed22
For the VWs question:
OnPlayerConnect:-
PHP код:
SetPlayerVirtualWorld(playerid,playerid);
Done? :/
|
I'm sure that'll have an issue being that the first playerid, is 0...
Quote:
Originally Posted by Dokins
Are you storing the VW or just doing it when they connect? All you would need to do, as Karem said is make the VW the same as playerid and it will never be the same as another.
|
You also want to note what is above.
Re: Every next player who register different VW -
karemmahmed22 - 24.09.2015
He just needs every player in different virtual world so, it doesn't matter about 0 or 1 or even 2.
Re: Every next player who register different VW -
Sew_Sumi - 24.09.2015
Quote:
Originally Posted by karemmahmed22
He just needs every player in different virtual world so, it doesn't matter about 0 or 1 or even 2.
|
If you read what he wanted, World 0 would be the logical choice for the after registration phase.
So really, it does matter.
Re: Every next player who register different VW -
Denying - 24.09.2015
Код:
GetNextVirtualWorld()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i))
continue;
if(GetPlayerVirtualWorld(i) == i)
continue;
return i;
}
return -1;
}
public OnPlayerConnect(playerid)
{
new vID = GetNextVirtualWorld();
if(vID == -1)
return 1;
SetPlayerVirtualWorld(playerid, vID);
}
Just wrote it in the chat, haven't tested it and I don't even know if it will work, but it's worth a shot.
AW: Re: Every next player who register different VW -
Kaliber - 24.09.2015
Quote:
Originally Posted by Denying
Just wrote it in the chat, haven't tested it and I don't even know if it will work, but it's worth a shot.
|
You're Code is wrong.
Just do it like this (it was posted already):
PHP код:
SetPlayerVirtualWorld(playerid, playerid+1);
Re: Every next player who register different VW -
rymax99 - 24.09.2015
Quote:
Originally Posted by Denying
Код:
GetNextVirtualWorld()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i))
continue;
if(GetPlayerVirtualWorld(i) == i)
continue;
return i;
}
return -1;
}
public OnPlayerConnect(playerid)
{
new vID = GetNextVirtualWorld();
if(vID == -1)
return 1;
SetPlayerVirtualWorld(playerid, vID);
}
Just wrote it in the chat, haven't tested it and I don't even know if it will work, but it's worth a shot.
|
Unnecessary loop/function.
As said 10 times already, just add 1 to the players ID for the vworld. 2 players will never have the same vworld that way unless you specifically set their vworld to another players.
SetPlayerVirtualWorld(playerid, playerid + 1);