SA-MP Forums Archive
udb saving rank, tiny error. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: udb saving rank, tiny error. (/showthread.php?tid=270937)



udb saving rank, tiny error. - Facepunch - 22.07.2011

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.


Re: udb saving rank, tiny error. - MadeMan - 22.07.2011

Show the code near

pawn Код:
new TeamRank



Re: udb saving rank, tiny error. - Facepunch - 22.07.2011

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__];



Re: udb saving rank, tiny error. - MadeMan - 22.07.2011

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;
}



Re: udb saving rank, tiny error. - Facepunch - 22.07.2011

Thank you worked perfectly!

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


Re: udb saving rank, tiny error. - MadeMan - 22.07.2011

Delete them, you don't use them.


Re: udb saving rank, tiny error. - Facepunch - 22.07.2011

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?


Re: udb saving rank, tiny error. - MadeMan - 22.07.2011

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