/invite help
#1

Hello there.What I want is, when a leader of faction /invite's someone, his name goes to a file and when leader does /foff it shows the members offline.Is it possible to be done?If yes, how?Here is my /invite CMD:

pawn Код:
CMD:invite(playerid, params[])
{
    if (PlayerInfo[playerid][pLeader] >= 1)
    {
        new string[128], ftext[50], giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /invite [playerid]");

        if(IsPlayerConnected(giveplayerid))
        {
            if (PlayerInfo[giveplayerid][pLeader] == 0 && PlayerInfo[giveplayerid][pMember] == 0 && PlayerInfo[giveplayerid][pFMember] == 255)
            {
                if(PlayerInfo[playerid][pLeader] == 1) { ftext = "LSPD"; }
                else if(PlayerInfo[playerid][pLeader] == 2) { ftext = "FBI"; }
                else if(PlayerInfo[playerid][pLeader] == 3) { ftext = "SFPD"; }
                else if(PlayerInfo[playerid][pLeader] == 4) { ftext = "FDSA"; }
                else if(PlayerInfo[playerid][pLeader] == 5) { ftext = "Judicial System"; }
                else if(PlayerInfo[playerid][pLeader] == 6) { ftext = "The Government"; }
                else if(PlayerInfo[playerid][pLeader] == 7) { ftext = "SASD"; }
                else if(PlayerInfo[playerid][pLeader] == 8) { ftext = "Hitman Agency"; }
                else if(PlayerInfo[playerid][pLeader] == 9) { ftext = "SANews"; }
                else if(PlayerInfo[playerid][pLeader] == 10) { ftext = "Arriva"; }
                else if(PlayerInfo[playerid][pLeader] == 11) { ftext = "US Marine Corps"; }
                else if(PlayerInfo[playerid][pLeader] == 12) { ftext = "SU"; }
                else if(PlayerInfo[playerid][pLeader] == 13) { ftext = "NOOSE"; }
                else { return 1; }
                InviteOffer[giveplayerid] = playerid;
                InviteFamily[giveplayerid] = 255;
                InviteFaction[giveplayerid] = PlayerInfo[playerid][pLeader];
                format(string, sizeof(string), "You have been invited to join the %s by %s - type /accept faction.", ftext, GetPlayerNameEx(playerid));
                SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
                format(string, sizeof(string), "You have invited %s to join the %s.", GetPlayerNameEx(giveplayerid),ftext);
                SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
            }
            else
            {
                SendClientMessageEx(playerid, COLOR_GREY, "The player you're trying to invite is already in another faction or family.");
                return 1;
            }

        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command - only leaders can do this.");
    }
    return 1;
}
Reply
#2

Hi,
you must write names invited players to file and load from this file their names .. )

Do you understand?
Reply
#3

You don't say?I need help with the coding...
Reply
#4

He wants it that if you do /foff it loads from the .txt file but he needs help scripting it, plus he wants it that the existing members(If possible, not sure) also get saved directly to .txt file now.
Reply
#5

He wants that /foff will list every offline member.
He needs that /invite will save the names and when they go offline, it'll set them to 0, that they're offline and "let" them be in /foff list.
Reply
#6

Exactly, anyone help him?
Reply
#7

He can use .ini, and use y_ini to do it.
Reply
#8

He needs someone to write it for him, can you?
Reply
#9

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
He needs someone to write it for him, can you?
No, I am no professional in saving/loading, or PAWN at general.
I am a beginner.
Reply
#10

Код:
CMD:invite(playerid, params[])
{
    if (PlayerInfo[playerid][pLeader] >= 1)
    {
        new string[128], ftext[50], giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /invite [playerid]");

        if(IsPlayerConnected(giveplayerid))
        {
            if (PlayerInfo[giveplayerid][pLeader] == 0 && PlayerInfo[giveplayerid][pMember] == 0 && PlayerInfo[giveplayerid][pFMember] == 255)
            {
                if(PlayerInfo[playerid][pLeader] == 1) { ftext = "LSPD"; }
                else if(PlayerInfo[playerid][pLeader] == 2) { ftext = "FBI"; }
                else if(PlayerInfo[playerid][pLeader] == 3) { ftext = "SFPD"; }
                else if(PlayerInfo[playerid][pLeader] == 4) { ftext = "FDSA"; }
                else if(PlayerInfo[playerid][pLeader] == 5) { ftext = "Judicial System"; }
                else if(PlayerInfo[playerid][pLeader] == 6) { ftext = "The Government"; }
                else if(PlayerInfo[playerid][pLeader] == 7) { ftext = "SASD"; }
                else if(PlayerInfo[playerid][pLeader] == 8) { ftext = "Hitman Agency"; }
                else if(PlayerInfo[playerid][pLeader] == 9) { ftext = "SANews"; }
                else if(PlayerInfo[playerid][pLeader] == 10) { ftext = "Arriva"; }
                else if(PlayerInfo[playerid][pLeader] == 11) { ftext = "US Marine Corps"; }
                else if(PlayerInfo[playerid][pLeader] == 12) { ftext = "SU"; }
                else if(PlayerInfo[playerid][pLeader] == 13) { ftext = "NOOSE"; }
                else { return 1; }
                InviteOffer[giveplayerid] = playerid;
                InviteFamily[giveplayerid] = 255;
                InviteFaction[giveplayerid] = PlayerInfo[playerid][pLeader];
                format(string, sizeof(string), "You have been invited to join the %s by %s - type /accept faction.", ftext, GetPlayerNameEx(playerid));
                SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
                format(string, sizeof(string), "You have invited %s to join the %s.", GetPlayerNameEx(giveplayerid),ftext);
                SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
                format(string, sizeof string, "%s.txt", ftext);
                new File:f = fopen (string, io_append);// open or create a file with the name of the faction (?) ftext ( https://sampwiki.blast.hk/wiki/Fopen )
                format(string, sizeof string, "%s\r\n", GetPlayerNameEx(giveplayerid));
                fwrite(f, string);// write in the file the name of giveplayerid ( https://sampwiki.blast.hk/wiki/Fwrite )
                fclose(f);// close the file ( https://sampwiki.blast.hk/wiki/Fclose )
            }
            else
            {
                SendClientMessageEx(playerid, COLOR_GREY, "The player you're trying to invite is already in another faction or family.");
                return 1;
            }

        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command - only leaders can do this.");
    }
    return 1;
}
for the /foff

Код:
CMD:foff(playerid, params[]) {
// ...
// factions checks etc.
// ...
new ftext[50];

                if(PlayerInfo[playerid][pLeader] == 1) { ftext = "LSPD"; }
                else if(PlayerInfo[playerid][pLeader] == 2) { ftext = "FBI"; }
                else if(PlayerInfo[playerid][pLeader] == 3) { ftext = "SFPD"; }
                else if(PlayerInfo[playerid][pLeader] == 4) { ftext = "FDSA"; }
                else if(PlayerInfo[playerid][pLeader] == 5) { ftext = "Judicial System"; }
                else if(PlayerInfo[playerid][pLeader] == 6) { ftext = "The Government"; }
                else if(PlayerInfo[playerid][pLeader] == 7) { ftext = "SASD"; }
                else if(PlayerInfo[playerid][pLeader] == 8) { ftext = "Hitman Agency"; }
                else if(PlayerInfo[playerid][pLeader] == 9) { ftext = "SANews"; }
                else if(PlayerInfo[playerid][pLeader] == 10) { ftext = "Arriva"; }
                else if(PlayerInfo[playerid][pLeader] == 11) { ftext = "US Marine Corps"; }
                else if(PlayerInfo[playerid][pLeader] == 12) { ftext = "SU"; }
                else if(PlayerInfo[playerid][pLeader] == 13) { ftext = "NOOSE"; }
                else { return 1; }

new string [90];
format (string, sizeof string, "%s.txt", ftext);
new File:f = fopen(string, io_readwrite); //
new name [24];
while(fread(f, string)) {
// Now, this part is more hard w/o info about your code
// I can provide you a code but is very inefficient
// or maybe i get better ideas later
// anyway inside "string" you will have the name of every members written inside faction file
// readed line-for-line
}
fclose(f);

}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)