[HELP]/setchan
#1

pawn Код:
CMD:setchan(playerid, params[])
{
    new SChannel;
    if(sscanf(params, "d", SChannel)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /setchan [1-99999]");
    else if (SChannel > 99999 || SChannel == 0) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: Your channel needs to be between 1 and 99999");
    else
    {
        new string[128];
        format(string, sizeof(string), "You've succesfully set your channel number to: '%d'.", SChannel);
        SendClientMessage(playerid, 0x81CFAB00, string);
        PSChannel[playerid] = SChannel;
    }
    return 1;
}
that is my code to set player channel but the problem is when i quit then i am get back to server channel is resetting
can someone save it?
help....
Reply
#2

Do you have an admin system or register/login system already?

EDIT: If not, try this.

pawn Код:
#include <dini>

#define CHANSAV "channels.ini"

public OnGameModeInit() //OnFilterScriptInit if using an FS
{
    if(!dini_Exists(CHANSAV)) dini_Create(CHANSAV);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    PSChannel[playerid] = dini_Int(CHANSAV, pName);
    return 1;
}

CMD:setchan(playerid, params[])
{
    new SChannel;
    if(sscanf(params, "d", SChannel)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /setchan [1-99999]");
    else if(SChannel > 99999 || SChannel < 1) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: Your channel needs to be between 1 and 99999");
    else
    {
        new string[120];
        format(string, sizeof(string), "You've succesfully set your channel number to: '%d'.", SChannel);
        SendClientMessage(playerid, 0x81CFAB00, string);
        PSChannel[playerid] = SChannel;
       
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        dini_IntSet(CHANSAV, pName, SChannel);
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by PotH3Ad
Посмотреть сообщение
Do you have an admin system or register/login system already?

EDIT: If not, try this.

pawn Код:
#include <dini>

#define CHANSAV "channels.ini"

public OnGameModeInit() //OnFilterScriptInit if using an FS
{
    if(!dini_Exists(CHANSAV)) dini_Create(CHANSAV);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    PSChannel[playerid] = dini_Int(CHANSAV, pName);
    return 1;
}

CMD:setchan(playerid, params[])
{
    new SChannel;
    if(sscanf(params, "d", SChannel)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /setchan [1-99999]");
    else if(SChannel > 99999 || SChannel < 1) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: Your channel needs to be between 1 and 99999");
    else
    {
        new string[120];
        format(string, sizeof(string), "You've succesfully set your channel number to: '%d'.", SChannel);
        SendClientMessage(playerid, 0x81CFAB00, string);
        PSChannel[playerid] = SChannel;
       
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        dini_IntSet(CHANSAV, pName, SChannel);
    }
    return 1;
}
i already have so what code i must input?
Reply
#4

Just post your login code or register code.
Reply
#5

Quote:
Originally Posted by PotH3Ad
Посмотреть сообщение
Just post your login code or register code.
why must?
it secret

pawn Код:
CMD:setchan(playerid, params[])
{
    new SChannel;
    if(sscanf(params, "d", SChannel)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /setchan [1-99999]");
    else if (SChannel > 99999 || SChannel == 0) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: Your channel needs to be between 1 and 99999");
    else
    {
        new string[128];
        format(string, sizeof(string), "You've succesfully set your channel number to: '%d'.", SChannel);
        SendClientMessage(playerid, 0x81CFAB00, string);
        PSChannel[playerid] = SChannel;
    }
    return 1;
}

CMD:wt(playerid, params[])
{
    new Sstring[128],
        pName[MAX_PLAYER_NAME];
    if(sscanf(params, "s[128]", Sstring)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /wt [text]");
    else if (PSChannel[playerid] == 0) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: You are not in a wt channel! Use /setchan.");
    else
    {
        new string[128];
        GetPlayerName(playerid, pName, sizeof(pName));
        for(new i; i < MAX_PLAYERS; i++)
        {
            if(PSChannel[i] == PSChannel[playerid])
            {
                format(string, sizeof(string), "* %d %s: %s", PSChannel[playerid], pName, Sstring);
                SendClientMessage(playerid, 0xFFFF00AA, string);
            }
            else
            {
            }
        }
    }
    return 1;
}

CMD:resetchan(playerid, params[])
{
    PSChannel[playerid] = 0;
    SendClientMessage(playerid, 0x81CFAB00, "You've successfully set your walkie talkie channel to none.");
    #pragma unused params
    return 1;
}
that is my full code
Reply
#6

That code doesn't help at all. I need to know how the user files are saved so I can save the channel in the user file.
Reply
#7

Quote:
Originally Posted by PotH3Ad
Посмотреть сообщение
That code doesn't help at all. I need to know how the user files are saved so I can save the channel in the user file.
i forgot the code can u help me foun that code?where is the place?(i am noob)
Reply
#8

Well just post your /login or /register command. I'm sure you can find that.
Reply
#9

Quote:
Originally Posted by PotH3Ad
Посмотреть сообщение
Well just post your /login or /register command. I'm sure you can find that.
i already search on my GM and no result
maybe i use some FS
Reply
#10

Well I can't help you unless you find that code. You can just use the code I posted I guess.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)