Check the player's clan

Started by umar4911, Jan 04, 2018, 03:37 PM

Previous topic - Next topic

umar4911

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.

=RK=MarineForce


!


Discord: zeus#5155

Escobabe

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;
}
Currently working on a new VC-MP project

umar4911

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

Escobabe

#5
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.
Currently working on a new VC-MP project

Xmair

#6
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.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

umar4911

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

=RK=MarineForce

its want

cmd /set player clan

/set umar4911 NK

umar4911