PVarInt how does it work?
#1

And here folks, I'm converting a gamemode here, adapting my login and registry system that saves in variables that were created in the enum, this gamemode uses these functions:

Quote:

GetPVarInt: Get the previously set integer from a player variable.
SetPVarString: Set a string for a player variable.
GetPVarString: Get the previously set string from a player variable.
SetPVarFloat: Set a float for a player variable.
GetPVarFloat: Get the previously set float from a player variable.
DeletePVar: Delete a player variable.

More so far, I do not know how to start, I do not know how it works, what do I want? I want to know more about this system and if it is worth converting it to enum or do not need it, I do not understand it, it saves it as? If n has enum for this? Train loco, remembering that the gamemode was separate, as it so separates, in the folder gamemodes, had gamemode OnPlayerConect and etc ... was everything part in publics to gamemode.
Reply
#2

It saves it at is it says that it does Int / String / Float read it up on the wiki

https://sampwiki.blast.hk/wiki/GetPVarInt
Reply
#3

Only use PVars on things you need the value of in the gamemode while in filterscripts too.
Reply
#4

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Only use PVars on things you need the value of in the gamemode while in filterscripts too.
Actually they can be useful in other cases, one of their didadvantages is that they are slower than normal variables, but deleted automatically on disconnect and you don't have to create global variables if you want to share something between functions (yeah i know you could use parameters)
Reply
#5

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Actually they can be useful in other cases, one of their didadvantages is that they are slower than normal variables, but deleted automatically on disconnect and you don't have to create global variables if you want to share something between functions (yeah i know you could use parameters)
No, there are not useful anywhere else. That's called laziness. A large amount of variables can be reset to their initial value on disconnect. A really huge amount in a few ms.

Global variables? The p in pvar = player.
Reply
#6

Okay, how do I convert, to put in the enum?


PHP код:
enum pInfo
{
     
pPlayerLogged,
     
pAdmin
};
SetPVarInt(playerid"PlayerLogged"1);
DeletePVar(i"PlayerLogged");
admin GetPVarInt(targetid"Admin"),
GetPVarInt(i"Admin") <= 
Reply
#7

Quote:
Originally Posted by SukMathcuck
Посмотреть сообщение
Okay, how do I convert, to put in the enum?


PHP код:
enum pInfo
{
     
pPlayerLogged,
     
pAdmin
};
SetPVarInt(playerid"PlayerLogged"1);
DeletePVar(i"PlayerLogged");
admin GetPVarInt(targetid"Admin"),
GetPVarInt(i"Admin") <= 
You are kinda in the wrong section for such a question
Reply
#8

Beauty, can I ask a question related to the forum? How to create something to store VarInt? Because what I see is that it is not storing.
Reply
#9

You're going to want to learn how to make and use enums... It'll help you out in the long term.
Reply
#10

You can use arrays to store them.
pawn Код:
enum pInfo
{
     pPlayerLogged,
     pAdmin
};

new PlayerArray[MAX_PLAYERS][pInfo];

//SetPVarInt(playerid, "PlayerLogged", 1);
PlayerArray[playerid][pPlayerLogged] = 1;

//DeletePVar(i, "PlayerLogged");
//You cannot delete PAWN variables normally. If you wish to reset the value, simply:
PlayerArray[playerid][pPlayerLogged] = 0;

//admin = GetPVarInt(targetid, "Admin"),
admin = PlayerArray[playerid][pAdmin];

//GetPVarInt(i, "Admin") <= 9
PlayerArray[playerid][pAdmin] <= 9

//To reset the array totally, loop through it and set the default value.
for(new i = 0; pInfo:i < pInfo; pInfo:i++)
    PlayerArray[playerid][pInfo:i] = 0;
The above code I posted was just to make you familiar with the syntax, but I strongly recommend you to read tutorials on arrays and enumerators. You can try the link below, it's one of the best tutorials I've seen here on enumerators.
https://sampforum.blast.hk/showthread.php?tid=318307
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)