SA-MP Forums Archive
Checking if PVar is set - 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: Checking if PVar is set (/showthread.php?tid=468801)



Checking if PVar is set - dusk - 10.10.2013

Hello, i need a way to check if a player-variable (PVar) has been set. Because if you GetPVarInt from any variable it returns 0, which is a valid player ID.(Yes i'm storing them).




So is there a way to check if it's set?


This is irrelevant to the problem:
You may want to give me a link to the thread "PVars - when, and when not, to use them", i will explain why i am using them: I use them for selling a house, to store stuff like who is selling, what house is sold and the price. In my opinion(which may be wrong,i'm only human) houses won't be sold often in the server. So having global array of 500 slots is pretty useless. I assume that PVars use memory only when they are set(although more then a normal variable), and when are deleted they memory is up for grasp again.


Re: Checking if PVar is set - xVIP3Rx - 10.10.2013

I think you could check if it's giving an output ? So it has been set ? And maybe i'm wrong..


Re: Checking if PVar is set - dusk - 10.10.2013

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
I think you could check if it's giving an output ? So it has been set ? And maybe i'm wrong..
This was my first try. It outputs "0" even if the pvar was NEVER set.


Re: Checking if PVar is set - xVIP3Rx - 10.10.2013

Umm, Did you try to: Set the pvar for every player for any number, Like 1.. Then check it, So every time it gives 1 output that means he isn't selling the house or whatever you're using it for.. but I think that will be the same, The pvar will be always set and that what you don't want..


Re: Checking if PVar is set - dusk - 10.10.2013

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
Umm, Did you try to: Set the pvar for every player for any number, Like 1.. Then check it, So every time it gives 1 output that means he isn't selling the house or whatever you're using it for.. but I think that will be the same, The pvar will be always set and that what you don't want..
In this case, they would be always stored in memory. And they would be equal(even worse) to using normal global variables.

I'm afraid, this is not an option... Thanks for trying of course


Re: Checking if PVar is set - xVIP3Rx - 10.10.2013

I think there is no way, if there was any I think most of the scripters would've used it, Anyway check this thread and you might find another ideas


Re: Checking if PVar is set - dusk - 11.10.2013

Nothing to look at, just a bump