[Help] Clan Tag
#1

Well I can't get it to add the [Clan] tag before the player's name, which is saved in the userfiles.
It most of time ended up with crashing the server or giving me empty "[]Name" tags.

That's my enum so far.
Код:
enum pInfo
{
	pLogged,
	pAdmin,
	pClanTag,
	pMoney,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
That's my login command.
Код:
CMD:login(playerid, params[])
{
	if(IsPlayerConnected(playerid))
	{
	    new file[128];
	    new password[256];
	    new message[128];
	    new spassword[256];
	    format(file, sizeof(file), "%s.ini", ReturnPlayerName(playerid));
	    if(sscanf(params, "s", password)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /login [password]");
	    if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You need to register first, type /register");
	    if(PlayerInfo[playerid][pLogged]) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You're already logged in");
	    spassword = dini_Get(file, "hashPW");
	    if(udb_hash(password) != strval(spassword))
	    {
	        format(message, sizeof(message), "SERVER: Invalid password");
	        SendClientMessage(playerid, COLOR_WHITE, message);
	    }
	    else
	    {
	 		PlayerInfo[playerid][pLogged] = 1;
	        PlayerInfo[playerid][pAdmin] = dini_Int(file, "admlvl");
		    PlayerInfo[playerid][pMoney] = dini_Int(file, "money");
		    PlayerInfo[playerid][pClanTag] = dini_Int(file, "clantag");
 	    	GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
	        format(message, sizeof(message), "SERVER: Welcome back, %s.", ReturnPlayerName(playerid));
	        SendClientMessage(playerid, COLOR_WHITE, message);
		}
 	}
	return 1;
}
And that's the command I made for creating a clan tag
Код:
CMD:createclan(playerid, params[])
{
	if(IsPlayerConnected(playerid))
	{
	    new clantag[128];
	    new message[128];
	    new file[128];
	    format(file, sizeof(file), "%s.ini", ReturnPlayerName(playerid));
	    if(sscanf(params, "s", clantag)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createclan [tag]");
	    dini_Set(file, "clantag", clantag);
	    format(message, sizeof(message), "You have successfully created the [%s] clan. Relog to use it.", clantag);
	    SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
	}
	return 1;
}
Any suggestions?
Reply
#2

pawn Код:
CMD:createclan(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new clantag[128];
        new message[128];
        new file[128];
        if(sscanf(params, "s", clantag)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createclan [tag]");
        format(file, sizeof(file), "[%s]%s.ini", clantag, ReturnPlayerName(playerid));
        dini_Set(file, "clantag", clantag);
        format(message, sizeof(message), "You have successfully created the [%s] clan. Relog to use it.", clantag);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
    }
    return 1;
}
Reply
#3

Well my problem isn't in saving the clan tag, it's in making it actually appear.
Do I need to place the format under sscanf anyways?
Reply
#4

Yes you do unless you will get the [].
Reply
#5

I can't really figure out what to put in the login command so it would change the player's name.
I can't get it to load the tag and put it inside the [] tag.

This is what I tried. I've put it in the login command after "GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);" line.
pawn Код:
format(nTag, sizeof(nTag), "[%s]%s", PlayerInfo[playerid][pClanTag], ReturnPlayerName);
SetPlayerName(playerid, nTag);
IG it gives me: []Name.
Reply
#6

pawn Код:
enum pInfo
{
    pLogged,
    pAdmin,
    pClanTag[5],
    pMoney,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
CMD:login(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new file[128];
        new password[256];
        new message[128];
        new spassword[256];
        format(file, sizeof(file), "%s.ini", ReturnPlayerName(playerid));
        if(sscanf(params, "s", password)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /login [password]");
        if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You need to register first, type /register");
        if(PlayerInfo[playerid][pLogged]) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You're already logged in");
        spassword = dini_Get(file, "hashPW");
        if(udb_hash(password) != strval(spassword))
        {
            format(message, sizeof(message), "SERVER: Invalid password");
            SendClientMessage(playerid, COLOR_WHITE, message);
        }
        else
        {
            PlayerInfo[playerid][pLogged] = 1;
            PlayerInfo[playerid][pAdmin] = dini_Int(file, "admlvl");
            PlayerInfo[playerid][pMoney] = dini_Int(file, "money");
                strmid(PlayerInfo[playerid][pClanTag], dini_Get(file, "clantag"), 0, strlen(dini_Get(file, "clantag")), 255);
            GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
            format(message, sizeof(message), "SERVER: Welcome back, %s.", ReturnPlayerName(playerid));
            SendClientMessage(playerid, COLOR_WHITE, message);
        }
    }
    return 1;
}
Reply
#7

That doesn't set the name....
Reply
#8

Hm, I thought you were going to do that yourself.

pawn Код:
CMD:login(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new file[128];
        new password[256];
        new message[128];
        new spassword[256];
        format(file, sizeof(file), "%s.ini", ReturnPlayerName(playerid));
        if(sscanf(params, "s", password)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /login [password]");
        if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You need to register first, type /register");
        if(PlayerInfo[playerid][pLogged]) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You're already logged in");
        spassword = dini_Get(file, "hashPW");
        if(udb_hash(password) != strval(spassword))
        {
            format(message, sizeof(message), "SERVER: Invalid password");
            SendClientMessage(playerid, COLOR_WHITE, message);
        }
        else
        {
            PlayerInfo[playerid][pLogged] = 1;
            PlayerInfo[playerid][pAdmin] = dini_Int(file, "admlvl");
            PlayerInfo[playerid][pMoney] = dini_Int(file, "money");
                strmid(PlayerInfo[playerid][pClanTag], dini_Get(file, "clantag"), 0, strlen(dini_Get(file, "clantag")), 255);
            GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
            format(message, 128, "[%s]%s", PlayerInfo[playerid][pClanTag], ReturnPlayerName(playerid));
            SetPlayerName(playerid, message);
            format(message, sizeof(message), "SERVER: Welcome back, %s.", ReturnPlayerName(playerid));
            SendClientMessage(playerid, COLOR_WHITE, message);
        }
    }
    return 1;
}
Reply
#9

Yup that worked, but why can't I use this?
pawn Код:
PlayerInfo[playerid][pClanTag] = dini_Get(file, "clantag");
Reply
#10

dini_Get returns a string.
Reply
#11

Isn't the tag a string?
Reply
#12

Of course it's that's why I used dini_Get
Reply
#13

I tried this alone
pawn Код:
PlayerInfo[playerid][pClanTag] = dini_Get(file, "clantag");
and it gave me this error
Код:
C:\Users\Cheetos\Desktop\samp03asvr_R7_win32\filterscripts\Register.pwn(162) : error 006: must be assigned to an array
I tried putting [256] besides the pClanTag then it gave me this.
Код:
C:\Users\Cheetos\Desktop\samp03asvr_R7_win32\filterscripts\Register.pwn(162) : error 047: array sizes do not match, or destination array is too small
Can't I just use a single "dini_Get" instead of that long line I don't understand :P?
Reply
#14

Why are you changing the code to something wrong when I just fixed it for you? Nevermind, do whatever you want.
Reply
#15

I'm just wondering...
I'm trying to use something I can fully understand

Thanks anyways.
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)