SA-MP Forums Archive
i don't understand anything of PVar code here - 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)
+--- Thread: i don't understand anything of PVar code here (/showthread.php?tid=335574)



i don't understand anything of PVar code here - Andy_McKinley - 18.04.2012

I need to use PVar because of anti-cheat. But I never used or have worked with pvar before. I need to put the pvar code directly after the weapon has given but I have no idea how to do this or if I did it right. Here is the code:

pawn Код:
else if(pickupid == tec)
    {
        weapon[playerid] = 32;
        weaponcost[playerid] = 6000;
        ammo2[playerid] = 60;
        SetPVarInt(playerid,"tec", GetPVarInt(playerid,"tec")+100);
        TextDrawShowForPlayer(playerid, background);
        #if defined ALT
        TextDrawSetString(text2, "Use 'ALT' to buy. Cost $6000.");
        #else
        TextDrawSetString(text2, "Use 'ALT' to buy. Cost $6000.");
        #endif
        TextDrawShowForPlayer(playerid, text2);
        wpicked[playerid] = 1;
        SetTimerEx("HideText", 2000, false, "d", playerid);
    }
If a player buys a weapon, then set thier PVars with the correct weapon name to whatever ammo they buy. For example, if they buy 3 clips of the desert eagle, then set the Pvar "DesertEagle" to 21 (7 ammo per clip). how will i do this? if someone tells me i will just do the rest. i think it's really simple but i just don't understand pvar...


Re: i don't understand anything of PVar code here - ViniBorn - 18.04.2012

This?

pawn Код:
SetPVarInt(playerid, "Eagle",3*7);



Re: i don't understand anything of PVar code here - Andy_McKinley - 18.04.2012

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
This?

pawn Код:
SetPVarInt(playerid, "Eagle",3*7);
can you please do it with the code i posted above? then i'll understand it easier


Re: i don't understand anything of PVar code here - ViniBorn - 18.04.2012

I do not know if that's what you want, but :

pawn Код:
else if(pickupid == tec)
{
    weapon[playerid] = 32;
    weaponcost[playerid] = 6000;
    ammo2[playerid] = 60;
    SetPVarInt(playerid,"tec", weaponcost[playerid]*ammo2[playerid]); // Total of $360.000 for 60 bullets of Tec9
    TextDrawShowForPlayer(playerid, background);
    #if defined ALT
    TextDrawSetString(text2, "Use 'ALT' to buy. Cost $6000.");
    #else
    TextDrawSetString(text2, "Use 'ALT' to buy. Cost $6000.");
    #endif
    TextDrawShowForPlayer(playerid, text2);
    wpicked[playerid] = 1;
    SetTimerEx("HideText", 2000, false, "d", playerid);
}



Re: i don't understand anything of PVar code here - Andy_McKinley - 19.04.2012

he gave me an example like this:
Код:
Example:
SetPVarInt(playerid,CombatShotgun,GetPVarInt(playerid,CombatShotgun)+210);
in pm
and said: 7 means add 7 to whatever the PVar is currently at, but if you're getting 210 ammo, then it should be 210
but seriously it feels like I am stupid now because I have no idea what this is.