PVarInts
#1

Hey,

For my server I am completely changing everything I do. I'm bored of my old scripting methods, however I was wondering if ++ = +1 and -- doesn't work then would -1 work? Or set the int to -1, when using SetPVarInt?

Thanks in advance.

Sorry if it's a noob question normally I wouldn't use -1.

-Snowman
Reply
#2

In my experience, when adding to the value of a PVar, you need to first retrieve the current value, then add the value you're trying to add (that could get confusing). Here's an example:

Instead of doing this:
pawn Код:
SetPVarInt(playerid, "(...)", Value++);
or perhaps this:
pawn Код:
SetPVarInt(playerid, "(...)", GetPVarInt(playerid, "(...)")++);
you need to do this:
pawn Код:
SetPVarInt(playerid, "(...)", GetPVarInt(playerid, "(...)")+iValue);
That's one of the various reasons I tend not to use PVar's for values that are accessed very often.
Reply
#3

Very confusing.. How would I take away a int. Like this?

pawn Код:
SetPVarInt(playerid, "IncorrectLogin", GetPVarInt(playerid, "IncorrectLogin")-iValue);
Or is that completely wrong?

Thanks in advance,

-Snowman.
Reply
#4

Quote:
Originally Posted by Snowman12
Посмотреть сообщение
Very confusing.. How would I take away a int. Like this?

pawn Код:
SetPVarInt(playerid, "IncorrectLogin", GetPVarInt(playerid, "IncorrectLogin")-iValue);
Or is that completely wrong?

Thanks in advance,

-Snowman.
It's correct.
You can also use it like this:
pawn Код:
SetPVarInt(playerid, "IncorrectLogin", --GetPVarInt(playerid, "IncorrectLogin")); // IncorrectLogin = IncorrectLogin-1
and so on.
Reply
#5

Thanks .

Off Topic:
Accept my MSN request please .
Reply
#6

Well no nothing is 'wrong' with my code, I'm just getting bored of the old style and looking to develop into newer ways.
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Why? Is there something wrong with your old code? It sounds like up till now you have been using normal variables which are MUCH better for 99% of things than PVars. They're faster and (contrary to popular belief) smaller.
The only advantage to PVars are that they use less memory, right?
Reply
#8

I personally think they save more time and look alot better. But thats just my thinking.
Reply
#9

I think I was mistaken in my post above. PVars were supposed to be more memory efficient, but that isn't the case I'm assuming?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)