udb saving rank, tiny error.
#1

So here's the deal.

I want to save my players ranks', by using udb. I've got a login system as filterscript, but I decided to save this one thing on my gamemode:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new player, rank;
    if (udb_Exists(PlayerName(playerid))){
    if (!PLAYERLIST_authed[playerid]) {
    dUserSetINT(PlayerName(playerid)).("rank",TeamRank[5][GetPlayerTeam(player)][rank]);
    }
    PLAYERLIST_authed[playerid]=false;
    return 1;
}
    return 1;
}
Here's my error:


pawn Код:
C:\Users\reha5\Desktop\samp server\gamemodes\quebradosrp.pwn(348) : error 032: array index out of bounds (variable "TeamRank")
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

Thanks.
Reply
#2

Show the code near

pawn Код:
new TeamRank
Reply
#3

Here you go:

pawn Код:
new TeamName[5][64] =   {  
                            "Citizen",//0
                            "El Quebrados Police Department",//1
                            "Trucker",//2
                            "Sweeper",//3
                            "El Quebrados Medical Center"//4
                        };
                   
#define MAX_RANKS 5
new TeamRank[5][MAX_RANKS][16] =    {
                                        {"","","","",""},//o
                                        {"Cadet","Officer","Sergeant","Lieutenant","Captain"},//1
                                        {"","","","",""},//2
                                        {"","","","",""},//3
                                        {"Paramedic","Head Paramedic","Surgeon","Head Surgeon","Director"}//4
                                    };
enum __PINFO__
{
    pRank,
}
new pInfo[MAX_PLAYERS][__PINFO__];
Reply
#4

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new player, rank;
    if (udb_Exists(PlayerName(playerid)))
    {
        if (PLAYERLIST_authed[playerid])
        {
            dUserSetINT(PlayerName(playerid)).("rank",pInfo[playerid][pRank]);
        }
        PLAYERLIST_authed[playerid]=false;
        return 1;
    }
    return 1;
}
Reply
#5

Thank you worked perfectly!

Can you tell me how I am going forward with this when he spawns?
Reply
#6

Delete them, you don't use them.
Reply
#7

I want to do the same with login, so I thought I could just reverse the cmd you gave me. But then I screwed it all up, can I send you my login filterscript?
Reply
#8

pawn Код:
pInfo[playerid][pRank] = dUserINT(PlayerName(playerid)).("rank");
If you mean this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)