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.
Its hard !:
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;
}
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
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.
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.
Quote from: Xmair on Jan 05, 2018, 12:02 PMQuote 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
its want
cmd /set player clan
/set umar4911 NK
Bump*
Made myself.
Solved.