SA-MP Forums Archive
Increasing PVar - 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: Increasing PVar (/showthread.php?tid=254328)



Increasing PVar - Seven_of_Nine - 10.05.2011

Hey

I've got a Spawn Weapons dialog, which has a PVar what is 1 on connection, then when the player choose the weapon, I want it increasing. (when 3, then return "Must reset lammer!!11")

I made a lil' stock for it but it isn't working. I tried the easier way too like SetPVarInt(playerid,"SpawnCount",GetPVarInt(player id,"SpawnCount")+1); but it's not working. Here is the stock:
pawn Код:
stock IncreasePVarInt(playerid,PvarInt[]) {
    new inc;
    inc = GetPVarInt(playerid,PvarInt);
    inc++;
    SetPVarInt(playerid,PvarInt,inc);
    return 1;
}
Still the same result :\


Re: Increasing PVar - black_dota - 10.05.2011

pawn Код:
#define SetPVarIntEx(%0,%1,%2,%3) SetPVarInt(%0,%1, GetPVarInt(%0,%1) %2 %3)
Usage:

pawn Код:
SetPVarIntEx(playerid, "NameOfPVar", +, 1); //+ can be +, -, / and *, and 1 is increase rate



Re: Increasing PVar - Seven_of_Nine - 10.05.2011

Well, not working.
Here is mah code:
pawn Код:
if(dialogid == 7) {
        if(strcmp(inputtext,"reset",true) == 0) {
            for(new i = 0; i < 4; i++) {
                if(PlayerWeapons[playerid][i] != -1) {
                    PlayerWeapons[playerid][i] = -1;
                }
            }
            SetPVarInt(playerid,"SpawnCount",1);
            SendClientMessage(playerid,white,"Your spawn weapons have been resetted.");
            return SpawnDialog(playerid);
        }
        if(GetPVarInt(playerid,"SpawnCount") == 3) { SpawnDialog(playerid); return SendClientMessage(playerid,white,"You must reset your spawn weapons to choose new ones."); }
        if(strcmp(inputtext,"1",true) == 0) {
            PlayerWeapons[playerid][GetPVarInt(playerid,"SpawnCount")] = 24;
            PlayerWeapons[playerid][0] += 50;
            format(text,sizeof(text),"%i.: Desert Eagle",GetPVarInt(playerid,"SpawnCount"));
            SendClientMessage(playerid,white,text);
            SetPVarIntEx(playerid, "NameOfPVar", +, 1);
            return SpawnDialog(playerid);
        }else if(strcmp(inputtext,"2",true) == 0) {
            PlayerWeapons[playerid][GetPVarInt(playerid,"SpawnCount")] = 25;
            PlayerWeapons[playerid][0] += 80;
            format(text,sizeof(text),"%i.: Shotgun",GetPVarInt(playerid,"SpawnCount"));
            SendClientMessage(playerid,white,text);
            SetPVarIntEx(playerid, "NameOfPVar", +, 1);
            return SpawnDialog(playerid);
        } else if(strcmp(inputtext,"3",true) == 0) {
            PlayerWeapons[playerid][GetPVarInt(playerid,"SpawnCount")] = 27;
            PlayerWeapons[playerid][0] += 100;
            format(text,sizeof(text),"%i.: Combat Shotgun",GetPVarInt(playerid,"SpawnCount"));
            SendClientMessage(playerid,white,text);
            SetPVarIntEx(playerid, "NameOfPVar", +, 1);
            return SpawnDialog(playerid);
        } else if(strcmp(inputtext,"4",true) == 0) {
            PlayerWeapons[playerid][GetPVarInt(playerid,"SpawnCount")] = 29;
            PlayerWeapons[playerid][0] += 120;
            format(text,sizeof(text),"%i.: MP5",GetPVarInt(playerid,"SpawnCount"));
            SendClientMessage(playerid,white,text);
            SetPVarIntEx(playerid, "NameOfPVar", +, 1);
            return SpawnDialog(playerid);
        } else if(strcmp(inputtext,"5",true) == 0) {
            PlayerWeapons[playerid][GetPVarInt(playerid,"SpawnCount")] = 30;
            PlayerWeapons[playerid][0] += 140;
            format(text,sizeof(text),"%i.: AK-47",GetPVarInt(playerid,"SpawnCount"));
            SendClientMessage(playerid,white,text);
            SetPVarIntEx(playerid, "NameOfPVar", +, 1);
            return SpawnDialog(playerid);
        } else if(strcmp(inputtext,"6",true) == 0) {
            PlayerWeapons[playerid][GetPVarInt(playerid,"SpawnCount")] = 31;
            PlayerWeapons[playerid][0] += 180;
            format(text,sizeof(text),"%i.: M4",GetPVarInt(playerid,"SpawnCount"));
            SendClientMessage(playerid,white,text);
            SetPVarIntEx(playerid, "NameOfPVar", +, 1);
            return SpawnDialog(playerid);
        } else if(strcmp(inputtext,"7",true) == 0) {
            PlayerWeapons[playerid][GetPVarInt(playerid,"SpawnCount")] = 33;
            PlayerWeapons[playerid][0] += 150;
            format(text,sizeof(text),"%i.: Country Rifle",GetPVarInt(playerid,"SpawnCount"));
            SendClientMessage(playerid,white,text);
            SetPVarIntEx(playerid, "NameOfPVar", +, 1);
            return SpawnDialog(playerid);
        } else if(strcmp(inputtext,"8",true) == 0) {
            PlayerWeapons[playerid][GetPVarInt(playerid,"SpawnCount")] = 34;
            PlayerWeapons[playerid][0] += 250;
            format(text,sizeof(text),"%i.: AK-47",GetPVarInt(playerid,"SpawnCount"));
            SendClientMessage(playerid,white,text);
            SetPVarIntEx(playerid, "NameOfPVar", +, 1);
            return SpawnDialog(playerid);
        } else if(strcmp(inputtext,"9",true) == 0 || strcmp(inputtext,"back",true) == 0) {
            format(text,sizeof(text),"Total Payment on spawn: %i",PlayerWeapons[playerid][0]);
            SendClientMessage(playerid,white,text);
            return Dialog(playerid,"ammu");
        } else if(strcmp(inputtext,"release",true) == 0) {
            return release(playerid);
        } else {
            return SpawnDialog(playerid);
        }
    }



Re: Increasing PVar - cessil - 10.05.2011

untested but this should work too

pawn Код:
#define PVarInt(%1,%2)++; SetPVarInt(%1,%2,GetPVarInt(%1,%2) + 1);
then you should be able to use in the script

pawn Код:
PVarInt(playerid,"variable")++;



Re: Increasing PVar - Seven_of_Nine - 10.05.2011

No, it won't. Same as black_dota's. Maybe there's something in the code what sets that PVar to 1 :\

EDIT: LOLWUT. I forgot to set the PvarName thingy in black_dota's XD

EDIT02: Still not working -.-


Re: Increasing PVar - Seven_of_Nine - 10.05.2011

*Sorry for DB*

omgf wtf ftw lmao: I found a SetPVarInt(playerid,"SpawnCount",1); right under OnDialogResponse.
I'm disappointed. xD