SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 04/12/2017, 12:09 PM   #1
DavidGravelli
Huge Clucker
 
DavidGravelli's Avatar
 
Join Date: May 2014
Posts: 225
Reputation: 36
Default Which one is the best? PlayerInfo or GetPVarInt

Which one is the best? PlayerInfo or GetPVarInt ?
Comment.
DavidGravelli is offline   Reply With Quote
Old 04/12/2017, 12:12 PM   #2
BeckzyBoi
Beta Tester
 
Join Date: Dec 2006
Posts: 1,679
Reputation: 122
Default Re: Which one is the best? PlayerInfo or GetPVarInt

GetPVarInt is certainly slower, but uses less memory I guess

Edit: PVars are also reset to 0 when then player disconnects, so no need to reset them in OnPlayerConnect (unless they need to be set to something other than 0)
__________________
BeckzyBoi is offline   Reply With Quote
Old 04/12/2017, 12:26 PM   #3
Mauzen
Godfather
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 5,128
Reputation: 1548
Default Re: Which one is the best? PlayerInfo or GetPVarInt

PVars store the value AND the identifier, so they actually use more memory. Only reason I can think of right now is to use them for cross-script variables, or maybe for stuff that gets accessed just very rarely. Whenever you can use just normal variables.
Mauzen is offline   Reply With Quote
Old 04/12/2017, 03:09 PM   #4
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,247
Reputation: 373
Default Re: Which one is the best? PlayerInfo or GetPVarInt

PVars are, like Mauzen said, only really useful for adding new variables run-time and for cross-script variables.
There's literally no advantage over regular variables in other scenarios (except that you can index PVars by a name, although that is rarely a requirement).
NaS is offline   Reply With Quote
Old 04/12/2017, 03:13 PM   #5
Kaperstone
High-roller
 
Kaperstone's Avatar
 
Join Date: May 2011
Location: Vladivostok, Russia
Posts: 3,280
Reputation: 757
Default Re: Which one is the best? PlayerInfo or GetPVarInt

If you're asking this, then you probably don't need (G/S/P)Var.
__________________
Find me on GitHub SEF Community (Official NEF Successor) SALobby Community SA:MP Reviews Find me on Steam
Kaperstone is offline   Reply With Quote
Old 04/12/2017, 10:14 PM   #6
Mobtiesgangsa
Big Clucker
 
Mobtiesgangsa's Avatar
 
Join Date: Oct 2016
Location: Skopje, Macedonia
Posts: 52
Reputation: 3
Default Re: Which one is the best? PlayerInfo or GetPVarInt

pVars for me is good to know it can be very important sometimes down the line but for me its easy to put few variables in an enumeration than adding a new variable for the maximum amounts of players MAX_PLAYERS i usual learn'd quite well and i'm practical using it.
__________________
As once told a programmer that in case your written code has a problem to not worry cuz one day you will figure a solution on how to overcome your problem
Mobtiesgangsa is offline   Reply With Quote
Old 04/12/2017, 10:40 PM   #7
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,554
Reputation: 2998
Default Re: Which one is the best? PlayerInfo or GetPVarInt

Neither: Proper modularisation, with variables for different systems kept isolated and separate. So all player info is split among small special-purpose variables, not one monster array; with PVars used soley when you need to share data between scripts since they are both much larger and much slower.
Y_Less is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GetPVarInt or just a var? Anuris Scripting Help 1 24/11/2014 05:18 PM
GetPVarInt audriuxxx Scripting Help 0 06/02/2013 08:23 PM
[FilterScript] Reklez's Playerinfo Textdraw - Check your playerinfo stats Reklez Filterscripts 9 09/04/2012 11:48 AM
GetPVarInt jaskiller Scripting Help 2 14/01/2012 05:39 PM
SetpVarInt-GetPvarInt vassilis Scripting Help 3 22/12/2011 12:24 PM


All times are GMT. The time now is 02:41 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.