[FilterScript] MySQL Clan System
#21

Quote:
Originally Posted by Gammix
Посмотреть сообщение
You might have the latest version i.e. v4.7.*, in 4.7 those functions are removed and are integrated within ShowPlayerDialog. There is a detail about how to use it in include's thread.

If you want to modify it to the new version, i would update the thread with your pull request if you are willing to do that.

Otherwise, you can downgrade to v4.6 which has same functionality to the new version and is stable as well.
Man, this is even more intense than that time I forgot how to sit down.

I'll stick with v4.6, thank you.
Reply
#22

Another question. How i can restrict a command for just one clan? I mean, i wanna do /clanmute, and player must be in clan "Test" to use it, how to? Do i need to check clan database ID or name? How i can do it?

I see there is playerClanID, but i don't know how to use it, i mean really don't know how it works.

And, playerClanID is saved somewhere in database or is just a temporary variable?

Also i want to remove TEAMS datas, everything related to it. Will it work too without teams?
Reply
#23

@Gammix awesome system! keep made amazing systems
Reply
#24

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Another question. How i can restrict a command for just one clan? I mean, i wanna do /clanmute, and player must be in clan "Test" to use it, how to? Do i need to check clan database ID or name? How i can do it?

I see there is playerClanID, but i don't know how to use it, i mean really don't know how it works.

And, playerClanID is saved somewhere in database or is just a temporary variable?
playerClanID holds the clan ID player is in, it's saved and loaded everytime a player connects/disconnects.

You can use this variable to access clan data in your command, if have done a similar job in other clan commands.

Have a look:
Код:
clanData[clanid][property]
So if i want to get player's clan name: i'll do two checks:
pawn Код:
if (playerClanID[playerid] == -1) { // so we don't get any runtime error
    if (!strcmp("Test", clanData[playerClanID[playerid]][CLAN_NAME])) { // clan name matches to "Test"
        // do your code here
    }
}
For a list of properties you can get from a clanid:
pawn Код:
enum E_CLAN_DATA {
    CLAN_SQLID,
    CLAN_TAG[MAX_CLAN_TAG_NAME],
    CLAN_NAME[MAX_CLAN_NAME],
    CLAN_SKIN,
    CLAN_TEAM,
    CLAN_OWNER[MAX_PLAYER_NAME],
    Float:CLAN_SPAWN_POS[4],
    CLAN_SPAWN_INTERIORID,
    CLAN_SPAWN_WORLDID,
    CLAN_VAULT_MONEY,
    CLAN_VAULT_WEAPONS[MAX_CLAN_WEAPONS],
    CLAN_VAULT_WEAPONS_TIMESTAMP[MAX_CLAN_WEAPONS],
    CLAN_TOTAL_EXP,
    CLAN_WAR_WINS,
    CLAN_WAR_TOTAL,
    Text3D:CLAN_3D_TEXT_LABEL,
    CLAN_PICKUPID
};
^ Its like database but for runtime only!

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Also i want to remove TEAMS datas, everything related to it. Will it work too without teams?
Yes you can remove the array and code related to TEAMS, you have to remove the command related to setting clan team and also remove some code from OnPlayerSpawn.
Reply
#25

I have a problem with the command to create faction. I removed team skins and added the possibility to set faction skins directly with the /fcreatecommand. But faction doesn't create, i get the ownership message and everything but in database faction doesn't create. Here is whole command:

pawn Код:
CMD:fcreate(playerid, params[]) {
    if (!IsPlayerAdmin(playerid))
        return SendClientMessage(playerid, COLOR_TOMATO, "Error: Only admin level 5 and above can access to this command.");

    new factionName[MAX_FACTION_NAME], factionTag[MAX_FACTION_TAG_NAME], ownerid, skin;
    if (sscanf(params, "s["#MAX_FACTION_NAME"]s["#MAX_FACTION_TAG_NAME"]rd", factionName, factionTag, ownerid, skin)) {
        SendClientMessage(playerid, COLOR_LIGHT_AQUA, "Usage: /fcreate [name] [tag] [owner] [faction skin]");
        SendClientMessage(playerid, COLOR_LIGHT_AQUA, "Usage: To add spaces in [name], you can use '_' and it will be auto detected as a white space!");
        return 1;
    }
   
    if(skin < 0 || skin > 311) return SendClientMessage(playerid, -1, "* Invalid skin ID (1-311)");

    foreach_factions(i) {
        if (!strcmp(factionData[i][FACTION_NAME], factionName, true)) {
            return SendClientMessage(playerid, COLOR_TOMATO, "Error: The faction name already exist, try another one.");
        }
       
        if (!strcmp(factionData[i][FACTION_TAG], factionTag, true)) {
            return SendClientMessage(playerid, COLOR_TOMATO, "Error: The faction tag already exist, try another one.");
        }
    }
   
    if (!IsPlayerConnected(ownerid))
        return SendClientMessage(playerid, COLOR_TOMATO, "Error: The owner player isn't connected.");

    if (playerFactionID[ownerid] != -1)
        return SendClientMessage(playerid, COLOR_TOMATO, "Error: The owner player is in a faction.");

    new index = -1;
    for (new i = 0; i < MAX_FACTIONS; i++) {
        if (factionData[i][FACTION_NAME][0] == EOS) {
            index = i;
            break;
        }
    }
   
    if (index == -1)
        return SendClientMessage(playerid, COLOR_TOMATO, "Error: Looks like the server factions creation limit has been reached, please contact server developer about this.");

    for (new i = 0; factionName[i] != EOS; i++) {
        if (factionName[i] == '_') {
            factionName[i] = ' ';
        }
    }

    new pos = strfind(factionTag, "[");
    if (pos != -1)
        strdel(factionTag, pos, pos + 1);

    pos = strfind(factionTag, "]");
    if (pos != -1)
        strdel(factionTag, pos, pos + 1);

    format(factionData[index][FACTION_TAG], MAX_FACTION_TAG_NAME, factionTag);
    format(factionData[index][FACTION_NAME], MAX_FACTION_NAME, factionName);
    factionData[index][FACTION_SKIN] = skin;
    GetPlayerName(ownerid, factionData[index][FACTION_OWNER], MAX_PLAYER_NAME);
    factionData[index][FACTION_WAR_WINS] = 0;
    factionData[index][FACTION_WAR_TOTAL] = 0;
    factionData[index][FACTION_SPAWN_POS][0] = 0.0;
    factionData[index][FACTION_SPAWN_POS][1] = 0.0;
    factionData[index][FACTION_SPAWN_POS][2] = 0.0;
    factionData[index][FACTION_SPAWN_POS][3] = 0.0;
    factionData[index][FACTION_SPAWN_INTERIORID] = 0;
    factionData[index][FACTION_SPAWN_WORLDID] = 0;
    factionData[index][FACTION_VAULT_MONEY] = 0;
    for (new i = 0; i < MAX_FACTION_WEAPONS; i++) {
        factionData[index][FACTION_VAULT_WEAPONS][i] = -1;
        factionData[index][FACTION_VAULT_WEPS_TIMESTAMP][i] = -1;
    }
    factionData[index][FACTION_TOTAL_EXP] = 0;
    factionData[index][FACTION_3D_TEXT_LABEL] = Text3D:INVALID_STREAMER_ID;
    factionData[index][FACTION_PICKUPID] = INVALID_STREAMER_ID;

    playerFactionID[ownerid] = index;
    playerFactionRank[ownerid] = FACTION_RANK_OWNER;

    new vault_weapons[32];
    for (new i = 0; i < MAX_FACTION_WEAPONS; i++) {
        format(vault_weapons, sizeof(vault_weapons), "%s-1", vault_weapons);

        if (i != (MAX_FACTION_WEAPONS - 1)) {
            strcat(vault_weapons, " ");
        }
    }
   
    new query[512];
    mysql_format(database, query, sizeof(query),
        "INSERT INTO factions (\
            tag, name, skin, exp, team, factionwar_wins, factionwar_total, \
            spawn_x, spawn_y, spawn_z, spawn_angle, spawn_interiorid, spawn_worldid, \
            vault_money, vault_weapons, vault_weapons_timestamp\
        ) VALUES (\
            '%e', '%e', %d, 0, %i, 0, 0, \
            0.0, 0.0, 0.0, 0.0, 0, 0, \
            0, '%s'\
        )"
,
        factionTag, factionName, skin,
        vault_weapons, vault_weapons
    );

    mysql_format(database, query, sizeof(query),
        "INSERT INTO faction_members (\
            faction_name, name, rank\
        ) VALUES (\
            '%e', '%e', %i\
        )"
,
        factionName, factionData[index][FACTION_OWNER], FACTION_RANK_OWNER
    );
    mysql_tquery(database, query);

    for (new i = 0; i < MAX_FACTION_RANKS; i++) {
        format(factionRankNames[index][i], MAX_FACTION_RANK_NAME, DEFAULT_FACTION_RANKS[i]);

        mysql_format(database, query, sizeof(query),
            "INSERT INTO faction_ranks (\
                faction_name, name, level\
            ) VALUES (\
                '%e', '%e', %i\
            )"
,
            factionName, DEFAULT_FACTION_RANKS[i], i
        );
        mysql_tquery(database, query);
    }
   
    mysql_format(database, query, sizeof(query),
        "SELECT id FROM factions WHERE faction_name = '%e'",
        factionName
    );
    new Cache:cache = mysql_query(database, query);
    cache_get_value_int(0, "id", factionData[index][FACTION_SQLID]);
    cache_delete(cache);
   
    UpdateFactionsRank();

    new string[164];
    format(string, sizeof(string), "[%s] %s", factionData[index][FACTION_TAG], factionRankNames[index][MAX_FACTION_RANKS - 1]);
    playerFaction3DTextLabel[ownerid] = CreateDynamic3DTextLabel(string, -1, 0.0, 0.0, 0.0, 25.0, ownerid, .testlos = 1);

    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));

    SendClientMessage(ownerid, COLOR_GREEN, "_________________________________________");
    SendClientMessage(ownerid, COLOR_GREEN, "");
    SendClientMessage(ownerid, COLOR_GREEN, "                           FACTION OWNERSHIP");
    format(string, sizeof(string), "Admin "COL_DEFAULT"%s"COL_GREEN", have assgined you as owner of new faction: "COL_DEFAULT"%s", name, factionData[index][FACTION_NAME]);
    SendClientMessage(ownerid, COLOR_GREEN, string);
    SendClientMessage(ownerid, COLOR_GREEN, "Here are some tips to get a head start with your faction:");
    SendClientMessage(ownerid, COLOR_GREEN, "To start recruiting players to your faction, use "COL_DEFAULT"/finvite");
    SendClientMessage(ownerid, COLOR_GREEN, "For list of faction commands that you have access to all of them, type "COL_DEFAULT"/fhelp");
    SendClientMessage(ownerid, COLOR_GREEN, "_________________________________________");

    format(string, sizeof(string), "Admin: You have suceessfully assigned a new faction, "COL_DEFAULT"%s "COL_BLUE"to player "COL_DEFAULT"%s", factionData[index][FACTION_NAME], factionData[index][FACTION_OWNER]);
    SendClientMessage(playerid, COLOR_BLUE, string);
   
    PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
    PlayerPlaySound(ownerid, 1057, 0.0, 0.0, 0.0);

    format(string, sizeof(string), "(%s)", factionData[index][FACTION_TAG]);
    TextDrawSetString(factionAnnouncementTD[1], string);
    format(string, sizeof(string), "~w~Faction ~r~~h~%s ~w~is now recruiting new memebers. To request an invite, contact ~r~~h~%s ~w~(id: ~r~%i~w~)", factionData[index][FACTION_NAME], factionData[index][FACTION_OWNER], ownerid);
    TextDrawSetString(factionAnnouncementTD[2], string);

    foreach (new i : Player) {
        if (GetPlayerState(i) != PLAYER_STATE_WASTED || GetPlayerState(i) != PLAYER_STATE_SPECTATING) {
            for (new x = 0; x < sizeof(factionAnnouncementTD); x++) {
                TextDrawShowForPlayer(i, factionAnnouncementTD[x]);
            }
        }
    }

    factionAnnouncementTimer = SetTimer("OnAnnouncementExpire", (30 * 1000), false);
   
    format(string, sizeof(string), "[%s] %s", factionData[index][FACTION_TAG], factionRankNames[index][FACTION_RANK_OWNER]);
    playerFaction3DTextLabel[playerid] = CreateDynamic3DTextLabel(string, -1, 0.0, 0.0, 0.0, 25.0, playerid, .testlos = 1);

    format(string, sizeof(string), "~g~~h~~h~(%s) ~g~~h~%s ~w~(Rank: (%i)%s)", factionData[index][FACTION_TAG], factionData[index][FACTION_NAME], FACTION_RANK_OWNER + 1, factionRankNames[index][FACTION_RANK_OWNER]);
    PlayerTextDrawSetString(playerid, factionNamePTD[playerid], string);
    PlayerTextDrawShow(playerid, factionNamePTD[playerid]);

    return 1;
}
In mysql log i get "invalid passing parameter" referred to "INSERT INTO factions" query, maybe added one useless parameter?
Reply
#26

Facing to problems which do not allow the FS to run..

Код:
[18:02:45]   Loading filterscript 'clans.amx'...
[debug] Run time error 19: "File or function is not found"
[debug]  MEM_new
[debug]  MEM_delete
EDIT: Updated pawn-memory plugin, works!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)