Special Tag [TAG]
#1

Hey Guys!
=> I want in my server (GM) that if player come with my official server [TAG] then he will Kicked saying That You don't have Server Official [TAG]....
And only that player can get whom i set name from data Base.. Can Any One Help Me With This??
Reply
#2

pawn Code:
public OnPlayerConnect(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    if(strfind(Name, "[TAG]", true) != -1)
    {
        if(!IsPlayerInOfficialClan(playerid))
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "You are not a member of the [TAG] clan. Please remove the clantag.");
            Kick(playerid);
        }
    }
}
pawn Code:
stock IsPlayerInOfficialClan(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    //Here you place the code for checking the player's name against the database.
}
Have you already got a database setup? Or not yet. If no, I'll write you up a simple SQLite system to store their names
Reply
#3

I don't have Data Base setup Bro How to Do it??

EDIT:
It is saying This Error..

pawn Code:
D:\Game\SA-MP Files\UnderWars\gamemodes\Wars.pwn(560) : error 017: undefined symbol "IsPlayerInOfficialClan"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

You need a check in the stock which will see that the player's name contains the official TAG you're talking about!

I wish i knew how to code it? Ima try to do so , ill post up if i do. Else i hope someone else has a code to check for the tag in the Player's name Or someone has a solution for it.
Reply
#5

Right - I whipped up a small SQLite system for you. This will store member names and levels. I have omitted the commands/registration as I feel it would be beneficial for you to code this yourself.

If you get stuck let me know.

The titles of each function explain in good detail what they actually do.

pawn Code:
/*
    This script stores member names and levels. I've provided you
    With this framework so you may build your own commands based around
    Them. All stock names are self explanitory. I have written what each returns
    Next to the functions themselves.
   
    Rob Butler (RobThugz/Rob_Maate)
*/


new DB:ClanDB;

stock IsPlayerInOfficialClan(playerid) //Returns TRUE if yes, FALSE if no
{
    new Query[128];
    new Name[MAX_PLAYER_NAME];
    new DBResult:Result;
    GetPlayerName(playerid, Name, sizeof(Name));
    format(Query, sizeof(Query), "SELECT * FROM `MEMBERS` WHERE `NAME` = '%s'", Name);
    Result = db_query(ClanDB, Query);
    if(db_num_rows(Result)) return true;
    return false;
}

stock AddPlayerToOfficialClan(playerid, level)
{
    new Query[128];
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(Query, sizeof(Query), "INSERT INTO `MEMBERS` (`NAME`, `LEVEL`) VALUES ('%s', '%d')", Name, level);
    db_query(ClanDB, Query);
    return 1;
}

stock RemovePlayerFromOfficialClan(playerid)
{
    new Query[128];
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(Query, sizeof(Query), "DELETE FROM `MEMBERS` WHERE `NAME` = '%s'", Name);
    db_query(ClanDB, Query);
    return 1;
}

stock UpdatePlayerOfficialClanInfo(playerid, level)
{
    new Query[128];
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(Query, sizeof(Query), "UPDATE `MEMBERS` SET (`NAME`, `LEVEL`) VALUES ('%s', '%d') WHERE `NAME` = '%s'", Name, level, Name);
    db_query(ClanDB, Query);
    return 1;
}

stock GetPlayerOfficialClanLevel(playerid) //There are easier ways to do this, but for the sake of education i'll use db_get_field_assoc
{ //This returns the player's clan level
    new Query[128];
    new Name[MAX_PLAYER_NAME];
    new DBResult:Result;
    new Field[30];
    new Level = 0;
    GetPlayerName(playerid, Name, sizeof(Name));
    format(Query, sizeof(Query), "SELECT * FROM `MEMBERS` WHERE `NAME` = '%s'", Name);
    if(db_num_rows(Result))
    {
        db_get_field_assoc(Result, "LEVEL", Field, sizeof(Field));
        Level = strval(Field);
    }
    return Level;
}

public OnGameModeInit()
{
    ClanDB = db_open("ClanDatabase.db");
    db_query(ClanDB, "CREATE TABLE IF NOT EXISTS `MEMBERS` (`NAME`, `LEVEL`)");
    return 1;
}

public OnGameModeExit()
{
    db_close(ClanDB);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    if(strfind(Name, "[TAG]", true) != -1)
    {
        if(!IsPlayerInOfficialClan(playerid))
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "You are not a member of the [TAG] clan. Please remove the clantag.");
            Kick(playerid);
        }
    }
    return 1;
}
EDIT: This is untested as balls, I literally just wrote this down. If it doesn't compile after you've integrated it with your gamemode just lemme know and i'll fix it for you
Reply
#6

Do you have any kind of database where you store player's information? Like Player's Name , IP ,Kills , Deaths , etc?

If yes , Post up the enum which contains the two dimensional array declared.

Example: (From my Game Mode)
pawn Code:
enum pInfo
{
    pKey[256],
    pAdmin,
    pBanned,
    pDonateRank,
    pClan,
    pClanRank
};
new PlayerInfo[MAX_PLAYERS][pInfo];
The information is stored by y_ini (Credits:Y_Less) into a directory called users in the scriptfiles folder of the server.

If you dont have any kind of database i can tell you how to make one using y_ini according to your needs.
Which will even have this feature to check the player's TAG
Reply
#7

Thnk you All. It help me Very Much. REP Added..
And only Last request:
=> How to get random messages in server.
Like. " Like This Server?? Add To Favourite"
"Respect All Admins"
"Don't Kill Admins On-Duty
I want that these messages come after equal intervals...
Reply
#8

Set a recurring timer.

https://sampwiki.blast.hk/wiki/SetTimerEx

Inside your function, have a list of random messages.

Here's an example script (untested):

pawn Code:
new RandomMessages[5][128];
new MsgIDX;

forward DisplayRandomMessage();

public OnGameModeInit()
{
    SetTimer("DisplayRandomMessage", 60000, 1);
    RandomMessages[0] = "Add to favorites!";
    RandomMessages[1] = "sdf";
    RandomMessages[2] = "sd";
    RandomMessages[3] = "fdsf";
    RandomMessages[4] = "sdfdsf";
    MsgIDX = 0;
    return 1;
}

public DisplayRandomMessage()
{
    SendClientMessageToAll(0xFFFF00FF, RandomMessages[MsgIDX]);
    MsgIDX++;
    if(MsgIDX >= 5) MsgIDX = 0;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)