Set/Get-PVarInt problem.
#1

I have a weapon-saving system:

OnPlayerConnect: (I've created the PlayerWeapons.)
pawn Код:
for(new i = 0; i < 4; i++) {
        new which[20];
        format(which,sizeof(which),"SW%i",i);
        if(GetPVarInt(playerid,which) == 0) {
            PlayerWeapons[playerid][i] = -1;
        } else {
            PlayerWeapons[playerid][i] = GetPVarInt(playerid,which);
        }
    }
OnPlayerSpawn:
pawn Код:
new WeapsEmpty;
    for(new i = 1; i < 4; i++) {
        if(PlayerWeapons[playerid][i] != -1) {
            GivePlayerWeapon(playerid,PlayerWeapons[playerid][i],90);
        } else {
            WeapsEmpty++;
        }
    }
    if(WeapsEmpty == 3) {
        format(dia,sizeof(dia),"Desert Eagle {36FF00} $50[much more here..]");
        ShowPlayerDialog(playerid,32,DIALOG_STYLE_LIST,"Starter Weapons",dia,"OK","Cancel");
    } else {
        PayMoney(playerid,PlayerWeapons[playerid][0]);
    }
And OnPlayerDisconnect:
pawn Код:
SetPVarInt(playerid,"SW0",PlayerWeapons[playerid][0]);
    SetPVarInt(playerid,"SW1",PlayerWeapons[playerid][1]);
    SetPVarInt(playerid,"SW2",PlayerWeapons[playerid][2]);
    SetPVarInt(playerid,"SW3",PlayerWeapons[playerid][3]);
And if you want to see, the dialog-setting:
pawn Код:
PlayerWeapons[playerid][1] = 24;
                PlayerWeapons[playerid][2] = 31;
                PlayerWeapons[playerid][0] = 100;
So, when I connect, I get that dialog, choose what I want, OK. When I kill myself, it's working, I get those weaps again.

The problem is: When I reconnect, I get the dialog again.

Why is that happening?
Reply
#2

Wrong, i.e.

Код:
SetPVarInt( playeird , "VARNAME" , VALUE );
Reply
#3

What?
It's not wrong.
When the player connects > checks not weapons saved (from PVarInt) > dialog
dialog response > save into variables
on player disconnect > save from variables to PVarInts.
on player connects again > load from PVarInts to the variables.

Easy as hell. So what is wrong now?
Reply
#4

When someone disconnects, PVars automatically get destroyed.
Reply
#5

OH LOL I forgot that.
Now, I use only the variables...
Thx, anyways :]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)