Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: umar4911 on Jan 04, 2018, 03:37 PM

Title: Check the player's clan
Post by: umar4911 on Jan 04, 2018, 03:37 PM
I am making a clan system. When player join's game, if player is not in clan and wearing the clan tag, kick him. What will the function of it.
Title: Re: Check the player's clan
Post by: =RK=MarineForce on Jan 05, 2018, 08:30 AM
Its hard !:
Title: Re: Check the player's clan
Post by: ! on Jan 05, 2018, 08:47 AM
Quote from: =RK=MarineForce on Jan 05, 2018, 08:30 AMIts hard !:
Why? How?
Title: Re: Check the player's clan
Post by: Escobabe on Jan 05, 2018, 11:27 AM
Well this is an example of how should it look like if im not wrong, basically you need to check if the players name contains your clan tag, and check the players stats ( 0 - Not in the clan / 1 - In the clan). And you would surely need a command like '/setclan [playerid]' where you would set the players 'InClan' to 1 and 'kickclan[playerid]' to 0, and of course save the stats.

I'm not yet familiar with VC:MP documentation, so if my code is wrong in any way, feel free to edit my mistakes.
function onPlayerJoin( player )
{
if((player.Name=="[VU]") && (stats[player.ID]InClan != 1))
{
KickPlayer(player);
}
else
{
MessagePlayer("Welcome back",player);
}
return 1;
}
Title: Re: Check the player's clan
Post by: umar4911 on Jan 05, 2018, 11:32 AM
Quote from: Escobabe on Jan 05, 2018, 11:27 AMWell this is an example of how should it look like if im not wrong, basically you need to check if the players name contains your clan tag, and check the players stats ( 0 - Not in the clan / 1 - In the clan). And you would surely need a command like '/setclan [playerid]' where you would set the players 'InClan' to 1 and 'kickclan[playerid]' to 0, and of course save the stats.

I'm not yet familiar with VC:MP documentation, so if my code is wrong in any way, feel free to edit my mistakes.
function onPlayerJoin( player )
{
if((player.Name=="[VU]") && (stats[player.ID]InClan != 1))
{
KickPlayer(player);
}
else
{
MessagePlayer("Welcome back",player);
}
return 1;
}
I know that it should check the player name but the code player.Name == "[VU]" is wrong. There must be something else here
Title: Re: Check the player's clan
Post by: Escobabe on Jan 05, 2018, 11:38 AM
I think the player.Name == "[VU]" is ok?
Look in this function for example: http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/KickPlayer

if ( player.Name == "Noob69" || player.Name == "Antonio_Morales" ) //This players can execute the command.
Edit: Actually im wrong, the code only check if the players name is '[VU]', not if a player has a '[VU]' tag on his name.
Title: Re: Check the player's clan
Post by: Xmair on Jan 05, 2018, 12:02 PM
Quote from: Escobabe on Jan 05, 2018, 11:38 AMI think the player.Name == "[VU]" is ok?
Look in this function for example: http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/KickPlayer

if ( player.Name == "Noob69" || player.Name == "Antonio_Morales" ) //This players can execute the command.
Edit: Actually im wrong, the code only check if the players name is '[VU]', not if a player has a '[VU]' tag on his name.
function FindClanTag(strPlayer)
{
   
    local
          D_DELIM = regexp(@"([\[(=^<]+\w+[\])=^>]+)").capture(strPlayer),
              S_DELIM = regexp(@"(\w.+[*=]+)").capture(strPlayer);

    if ( D_DELIM != null )
    {
        return strPlayer.slice( D_DELIM[ 0 ].begin, D_DELIM[ 0 ].end );
    }
    else if ( S_DELIM != null )
    {
        return strPlayer.slice( S_DELIM[ 0 ].begin, S_DELIM[ 0 ].end );
    }
}
Taken from somewhere in the old unofficial VCMP forums.
And to check you basically do:
local clanTag = FindClanTag( player );
if( clanTag && !playerIsInClan( clanTag, player ) ) player.Kick();
You should get an idea.
Title: Re: Check the player's clan
Post by: umar4911 on Jan 05, 2018, 01:19 PM
Quote from: Xmair on Jan 05, 2018, 12:02 PM
Quote from: Escobabe on Jan 05, 2018, 11:38 AMI think the player.Name == "[VU]" is ok?
Look in this function for example: http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/KickPlayer

if ( player.Name == "Noob69" || player.Name == "Antonio_Morales" ) //This players can execute the command.
Edit: Actually im wrong, the code only check if the players name is '[VU]', not if a player has a '[VU]' tag on his name.
function FindClanTag(strPlayer)
{
   
    local
          D_DELIM = regexp(@"([\[(=^<]+\w+[\])=^>]+)").capture(strPlayer),
              S_DELIM = regexp(@"(\w.+[*=]+)").capture(strPlayer);

    if ( D_DELIM != null )
    {
        return strPlayer.slice( D_DELIM[ 0 ].begin, D_DELIM[ 0 ].end );
    }
    else if ( S_DELIM != null )
    {
        return strPlayer.slice( S_DELIM[ 0 ].begin, S_DELIM[ 0 ].end );
    }
}
Taken from somewhere in the old unofficial VCMP forums.
And to check you basically do:
local clanTag = FindClanTag( player );
if( clanTag && !playerIsInClan( clanTag, player ) ) player.Kick();
You should get an idea.
What is regexp? Heard first time
Title: Re: Check the player's clan
Post by: =RK=MarineForce on Jan 05, 2018, 04:53 PM
its want

cmd /set player clan

/set umar4911 NK
Title: Re: Check the player's clan
Post by: umar4911 on Apr 10, 2018, 03:29 PM
Bump*

Made myself.
Solved.