Whats The Efficient Way?
#1

Hello,
I want to create an "Clan Tag Checker" which checks that the [TAG] player is wearing has been given to him or not.
i've tried to create one myself but it was not working.
So, tell me how to create one with most efficient way of checking player's tag.
Thank you!
Reply
#2

-Bump.
Reply
#3

Well, you should not be asking for a script itself, but provide your current ideas and have them fixed.

Anyways, I would recommend a script to check the player's entire name and if it equals [TAG] check the user's save database and if it was not given, have him kicked.
Reply
#4

I did not asked for your recommendations,
Thank you for your comment!
can anyone teach me how to create one?
Reply
#5

Have you got a saving system for the players? If you don't you will need one. And how much experience do you have scripting. (Need to know so I am aware of how far in depth I will need to go to try to assist you.)
Reply
#6

I do have saving system for players,
take a look into my releases, if you want to know how experienced i am.
Thank you.
Reply
#7

Alright, so when a player registers, you have to set the tags granted to 0, then afterwards when logging in, that it checks the user's name and see if a tag is found and if it is permitted for that user. When an administrator has granted a tag, have it save it to the user in which the tag was granted to's file.
Reply
#8

You would use strfind to check their name for the desired clan tag. I wrote a mini-tutorial. It hasn't been tested, but should work.
pawn Код:
public OnPlayerConnect(playerid)
{
    new name[24]; // Makes a new string for the name
    GetPlayerName(playerid,name,sizeof(name)); // Assigns it to the name
    // Using strfind, this searches their name for the clan tag and what not.
    if(strfind(name,"[TAG]",true) != -1) // The != is if it was found.
    {
        // If it was found then we follow that if with an other if to check if they are
        // part of the clan that they have in front of their name.
        if(PlayerInfo[playerid][pClan] != 1) // In this case the clan they need to be in is 1
        {
            // If they are not in the clan then it kicks them.
            SendClientMessage(playerid,-1,"You are not in the [TAG] clan, you have been kicked as a result.");
            Kick(playerid);
        }
        else
        {
            // If they are then send them a nice welcome message. :)
            SendClientMessage(playerid,-1,"Welcome back to clan [TAG]");
            return 1;
        }
    }
    return 1;
}
Hope I helped.
Reply
#9

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
You would use strfind to check their name for the desired clan tag. I wrote a mini-tutorial. It hasn't been tested, but should work.
pawn Код:
public OnPlayerConnect(playerid)
{
    new name[24]; // Makes a new string for the name
    GetPlayerName(playerid,name,sizeof(name)); // Assigns it to the name
    // Using strfind, this searches their name for the clan tag and what not.
    if(strfind(name,"[TAG]",true) != -1) // The != is if it was found.
    {
        // If it was found then we follow that if with an other if to check if they are
        // part of the clan that they have in front of their name.
        if(PlayerInfo[playerid][pClan] != 1) // In this case the clan they need to be in is 1
        {
            // If they are not in the clan then it kicks them.
            SendClientMessage(playerid,-1,"You are not in the [TAG] clan, you have been kicked as a result.");
            Kick(playerid);
        }
        else
        {
            // If they are then send them a nice welcome message. :)
            SendClientMessage(playerid,-1,"Welcome back to clan [TAG]");
            return 1;
        }
    }
    return 1;
}
Hope I helped.
Sweet!
thanks for this,
i created /setclanmember, it saves right but it does not set clan member to 1 it just stays = 0 and also i want it the way when i /Setclanmember someone, [DU] will be attached to their name and then the name will be saved.
Thank you.
Here's the code.
pawn Код:
CMD :setclanmember ( playerid , params [ ] )
{
    if ( IsPlayerConnected ( playerid ) )
    {
        if ( IsPlayerAdmin ( playerid ) )
        {
            new
                nom [ MAX_PLAYER_NAME ] ,
                str [ 79 ] ,
                pid
            ;
            if ( sscanf ( params, "u" , pid ) ) return SendClientMessage ( playerid , 0xBEBEBEAA , "[ERROR]: /Setclanmember [playerid]" ) ;
            {
                pClan [ pid ] = pid ;
                GetPlayerName ( playerid , nom , sizeof ( nom ) ) ;
                GetPlayerName ( pid , nom , sizeof ( nom ) ) ;
                format ( str , sizeof ( str ) , "*You Have Successfuly Set %s As An Clan Member!" , pid  ) ;
                SendClientMessage ( playerid , 0x00FF00AA , str ) ;
                format ( str , sizeof ( str ) , "*%s Has Made You A [Du] Clan Member! Now You Are Allowed To Use [DU] Tag in Your Name!" , nom ) ;
                SendClientMessage ( playerid , 0x00FF00AA , str ) ;
            }
        }
        else
            SendClientMessage ( playerid, 0x8B1A1AAA , "[ERROR] Only RCON Administrators Can Use This Command!" ) ;
    }
    else
        SendClientMessage ( playerid , 0x8B1A1AAA , "[ERROR] Player Not Connected!" ) ;
    return 1;
}
Reply
#10

Firstly, sscanf checks if a command was not typed correctly. You need to add an else statement to check if it was typed correctly.
Secondly, you are making the player's clan equal to their playerid which is not what you want. Don't put so many spaces in your command lol.
Another min-tutorial.
pawn Код:
CMD:setclanmember(playerid,params[])
{
    new pid; // Your playerid variable.
   // If they are not an admin then return a message saying their not. Take note that returning stops processing
   // the command. The ! is if IsPlayerAdmin returns false, in other words he is not an admin.
   if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xBEBEBEAA,"[ERROR]: You are not an admin!"):
   // If the player is an admin, then it continues and checks if they typed the command correctly.
   // sscanf automatically says if they didn't type it correctly, so if they they didn't then tell em how to use
   // the command and stop processing it
   if(sscanf(params,"u",pid)) return SendClientMessage(playerid,0xBEBEBEAA,"[USAGE]: /setclanmember [playerid]");
   // Now, if they are an admin, and they typed the command correctly, then we will see if the player that they
   // want to add to the clan is connected. If the pid they typed is not online then it sends them a message telling them so
   if(pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,0xBEBEBEAA,"[ERROR]: Player not found.");
   // Now if everything is correct the 'else' says if everything else has passed, then continue.
   else
   {
        new nom[MAX_PLAYER_NAME],str[79];
        // If everything else has passed then set their clan to 1.
        pClan[pid] = 1;
        GetPlayerName ( playerid , nom , sizeof ( nom ) ) ;
        GetPlayerName ( pid , nom , sizeof ( nom ) ) ;
        format ( str , sizeof ( str ) , "*You Have Successfuly Set %s As An Clan Member!" , pid  ) ;
        SendClientMessage ( playerid , 0x00FF00AA , str ) ;
        format ( str , sizeof ( str ) , "*%s Has Made You A [Du] Clan Member! Now You Are Allowed To Use [DU] Tag in Your Name!" , nom ) ;
        SendClientMessage ( playerid , 0x00FF00AA , str ) ;
       
        // Using strins (string insert) it gets the name string, and adds [DU]
        // the 0 is the position where to insert [DU] which is 0 because you
        // want it at the beginning of the name.
        strins(nom,"[DU]",0,sizeof(nom));
        // Now that we inserted the clan tag into their name using strins, we
        // set their name with the clan tag.
        SetPlayerName(pid,nom);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)