Set/Get-PVarInt problem. - 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: Set/Get-PVarInt problem. (
/showthread.php?tid=253424)
Set/Get-PVarInt problem. -
Seven_of_Nine - 06.05.2011
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?
Re: Set/Get-PVarInt problem. -
steki. - 06.05.2011
Wrong, i.e.
Код:
SetPVarInt( playeird , "VARNAME" , VALUE );
Re: Set/Get-PVarInt problem. -
Seven_of_Nine - 06.05.2011
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?
Re: Set/Get-PVarInt problem. -
steki. - 06.05.2011
When someone disconnects, PVars automatically get destroyed.
Re: Set/Get-PVarInt problem. -
Seven_of_Nine - 06.05.2011
OH LOL I forgot that.
Now, I use only the variables...
Thx, anyways :]