Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Mohamed Boubekri on Mar 26, 2021, 03:37 PM

Title: Same UID for players
Post by: Mohamed Boubekri on Mar 26, 2021, 03:37 PM
I have made this function:-
function Check(player)
{
for (local i = 0; i < GetMaxPlayers(); ++i)
{
local plr = FindPlayer(i);
if (plr.UID == player.UID )
{
MessagePlayer("Ok we kicking you out.",plr); //rani hna w last pos nzid nriglha
}
}
}
The function is not working, When i enter the server he is kick me out
The idea is, if the player was in server he is can't enter again, The server will catch him UID and kick him out.
Title: Re: Same UID for players
Post by: Xmair on Mar 27, 2021, 05:29 AM
You forgot to add plr.Kick();
Title: Re: Same UID for players
Post by: EnForcer on Mar 27, 2021, 06:06 AM
Here you go
Untested code.

function Check(player)
{
for (local i = 0; i < GetMaxPlayers(); i++)
{
local plr = FindPlayer(i);
if ( (plr.UID == player.UID) && ( plr.ID != player.ID) )
{
MessagePlayer("Multi Clienting not allowed.",player); //rani hna w last pos nzid nriglha
player.Kick();
}
}
}
Title: Re: Same UID for players
Post by: Mohamed Boubekri on Mar 27, 2021, 10:46 AM
Quote from: EnForcer on Mar 27, 2021, 06:06 AMHere you go
Untested code.

function Check(player)
{
for (local i = 0; i < GetMaxPlayers(); i++)
{
local plr = FindPlayer(i);
if ( (plr.UID == player.UID) && ( plr.ID != player.ID) )
{
MessagePlayer("Multi Clienting not allowed.",player); //rani hna w last pos nzid nriglha
player.Kick();
}
}
}

Thank you. But there is a small problem, when in the server a single player, the console throw an error like
plr ID does not found. This function below working great:
function Check(player) //when player in server, he can't enter again
{
for (local i = 0; i < GetMaxPlayers(); i++)
{
local plr = FindPlayer(i);
if ( player.ID != plr.ID && player.UID == plr.UID )
{
MessagePlayer("Multi Clienting not allowed.",player);
player.Kick();
}
else return;
}
}