SA-MP Forums Archive
List of integers in GetPVarInt - 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: List of integers in GetPVarInt (/showthread.php?tid=337791)



List of integers in GetPVarInt - stormchaser206 - 27.04.2012

Does anyone know what the integers you can use for GetPVarInt are?


Re: List of integers in GetPVarInt - ViniBorn - 27.04.2012

How so?


Re: List of integers in GetPVarInt - stormchaser206 - 27.04.2012

If you dont know what i mean...
I mean like for example, money. (money is what it says on the function example on the wiki)
I need a list of them.


Re: List of integers in GetPVarInt - ViniBorn - 27.04.2012

Most functions work with integers.

Usually what works with life and coordinates, is float ...
Ex: GetPlayerHealt, GetPlayerPos, GetVehiclePos


Re: List of integers in GetPVarInt - ReneG - 27.04.2012

Ummm, pretty self explanatory. Anything that's an integer can be used with GetPVarInt.


Re: List of integers in GetPVarInt - stormchaser206 - 27.04.2012

is there a kills or somthing?


Re: List of integers in GetPVarInt - antonio112 - 28.04.2012

All those variables you create yourself. For example, minutes on, hours on, kills, deaths, etc etc. You can basically use everything in variables. The thing is, you need to set the variables first. Let me give you an example:

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
// We check if killerid is a valid player id and give him one kill
    if(killerid != INVALID_PLAYER_ID)
        SetPVarInt(playerid, "Kills", GetPVarInt(playerid, "Kills") + 1);
    SetPVarInt(playerid, "Deaths", GetPVarInt(playerid, "Deaths") + 1); // Here we set a variable called "Deaths" to the player who died
    return 1;
}
// We create a command that resets a player kills
YCMD:resetkills(playerid, params[], help)
{
        #pragma unused help, params
        DeletePVar(playerid, "Kills");
        return 1;
}
// A command that resets deaths
YCMD:resetdeaths(playerid, params[], help)
{
        #pragma unused help, params
        DeletePVar(playerid, "Deaths");
        return 1;
}
// A command to check kills and deaths:
YCMD:checkstats(playerid, params[], help)
{
        #pragma unused help, params
        new str[128];
        format(str, sizeof str, "You have %i kills and %i deaths.", GetPVarInt(playerid, "Kills"), GetPVarInt(playerid, "Deaths"))
        SendClientMessage(playerid, -1, str);
        return 1;
}
Now, you might wonder, why do I delete those variables. Well, instead of setting a player variable to 0, it's better to delete it. You can of course, set it to 0 using "SetPVarInt(playerid, "Deaths", 0);

Now, the "Kills" and "Deaths" variables, you can name it whatever you want. It doesn't matter.


Re: List of integers in GetPVarInt - ReneG - 28.04.2012

It's actually better to use regular variables. Go ahead and learn it, but PVars use more RAM than a regular variable.