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, 11:09 AM   #1
DavidGravelli
Huge Clucker
 
DavidGravelli's Avatar
 
Join Date: May 2014
Location: Belgium
Posts: 252
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, 11:12 AM   #2
BeckzyBoi
Beta Tester
 
Join Date: Dec 2006
Posts: 1,695
Reputation: 127
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, 11:26 AM   #3
Mauzen
Banned
 
Join Date: Jun 2007
Location: Western Germany
Posts: 5,100
Reputation: 1597
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, 02:09 PM   #4
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,549
Reputation: 457
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, 02:13 PM   #5
Kaperstone
Banned
 
Join Date: May 2011
Location: Russia
Posts: 3,348
Reputation: 824
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.
Kaperstone is offline   Reply With Quote
Old 04/12/2017, 09:14 PM   #6
Mobtiesgangsa
Big Clucker
 
Mobtiesgangsa's Avatar
 
Join Date: Oct 2016
Location: Skopje, Macedonia
Posts: 108
Reputation: 10
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.
__________________
YSI User

Code:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	switch(success)
	{
	    case COMMAND_UNDEFINED:
	    {
		    TextDrawShowForPlayer(playerid, cmdinfo[playerid]);
		    SetTimerEx("UnknownCommand", 3000, false, "d", playerid);
	    }
	}
	return COMMAND_OK;
}
Mobtiesgangsa is offline   Reply With Quote
Old 04/12/2017, 09:40 PM   #7
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,985
Reputation: 3150
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 04:18 PM
GetPVarInt audriuxxx Scripting Help 0 06/02/2013 07:23 PM
[FilterScript] Reklez's Playerinfo Textdraw - Check your playerinfo stats Reklez Filterscripts 9 09/04/2012 10:48 AM
GetPVarInt jaskiller Scripting Help 2 14/01/2012 04:39 PM
SetpVarInt-GetPvarInt vassilis Scripting Help 3 22/12/2011 11:24 AM


All times are GMT. The time now is 07:22 AM.


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